Skip to content

Commit

Permalink
default scope to openid for non oidc conformant, disable sso properly…
Browse files Browse the repository at this point in the history
…, validate reponseType with popup
  • Loading branch information
glena committed Jan 6, 2017
1 parent 1a757d2 commit f127809
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 20 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"zuul-ngrok": "gnandretta/zuul-ngrok#upgrade-ngrok"
},
"dependencies": {
"auth0-js": "8.0.3",
"auth0-js": "8.0.4",
"blueimp-md5": "2.3.1",
"fbjs": "^0.3.1",
"immutable": "^3.7.3",
Expand Down
12 changes: 12 additions & 0 deletions src/core/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,10 @@ function extractAuthOptions(options) {
nonce
} = options.auth || {};

let {
oidcConformant
} = options;

audience = typeof audience === "string" ? audience : undefined;
connectionScopes = typeof connectionScopes === "object" ? connectionScopes : {};
params = typeof params === "object" ? params : {};
Expand All @@ -234,6 +238,14 @@ function extractAuthOptions(options) {
warn(options, "Usage of scope 'openid profile' is not recommended. See https://auth0.com/docs/scopes for more details.");
}

if (oidcConformant && !redirect && responseType.indexOf('id_token') > -1) {
throw new Error("It is not posible to request an 'id_token' while using popup mode.");
}

if (oidcConformant && !params.scope) {
params.scope = 'openid';
}

return Immutable.fromJS({
audience,
connectionScopes,
Expand Down
32 changes: 15 additions & 17 deletions src/core/remote_data.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,23 @@ export function syncRemoteData(m) {
});
}

if (!l.oidcConformant(m)) {
m = sync(m, "sso", {
conditionFn: l.auth.sso,
waitFn: m => isSuccess(m, "client"),
syncFn: (m, cb) => fetchSSOData(l.id(m), isADEnabled(m), cb),
successFn: (m, result) => m.mergeIn(["sso"], Immutable.fromJS(result)),
errorFn: (m, error) => {
// location.origin is not supported in all browsers
let origin = location.protocol + "//" + location.hostname;
if (location.port) {
origin += ":" + location.port;
}
m = sync(m, "sso", {
conditionFn: (m) => l.auth.sso(m) && !l.oidcConformant(m),
waitFn: m => isSuccess(m, "client"),
syncFn: (m, cb) => fetchSSOData(l.id(m), isADEnabled(m), cb),
successFn: (m, result) => m.mergeIn(["sso"], Immutable.fromJS(result)),
errorFn: (m, error) => {
// location.origin is not supported in all browsers
let origin = location.protocol + "//" + location.hostname;
if (location.port) {
origin += ":" + location.port;
}

const appSettingsUrl = `https://manage.auth0.com/#/applications/${l.clientID(m)}/settings`;
const appSettingsUrl = `https://manage.auth0.com/#/applications/${l.clientID(m)}/settings`;

l.warn(m, `There was an error fetching the SSO data. This could simply mean that there was a problem with the network. But, if a "Origin" error has been logged before this warning, please add "${origin}" to the "Allowed Origins (CORS)" list in the Auth0 dashboard: ${appSettingsUrl}`);
}
});
}
l.warn(m, `There was an error fetching the SSO data. This could simply mean that there was a problem with the network. But, if a "Origin" error has been logged before this warning, please add "${origin}" to the "Allowed Origins (CORS)" list in the Auth0 dashboard: ${appSettingsUrl}`);
}
});

return m;
}
4 changes: 2 additions & 2 deletions support/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
const domain = "auth0-tests-lock.auth0.com";
const options = {
auth: {
responseType: 'id_token token',
responseType: 'id_token'
},
oidcConformant: false
oidcConformant: true
};

const lock = new Auth0Lock(cid, domain, options);
Expand Down

0 comments on commit f127809

Please sign in to comment.