Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ Once the library is loaded, you have to provide the environmental details along
oidc: true,
identityProxyPreference: "XHR", // can be either "XHR" or "serviceWorker"
renewStrategy: "authCode", // can be either "authCode" or "refreshToken"
attemptSilentAuthGrant: true, // if false, appAuthHelper won't use iframes to attempt to make silent auth code grants
redirectUri: "appAuthHelperRedirect.html", // can be a relative or absolute url
serviceWorkerUri: "appAuthServiceWorker.js" // can be a relative or absolute url
});
Expand All @@ -132,6 +133,7 @@ Once the library is loaded, you have to provide the environmental details along
- oidc [default: true] - indicate whether or not you want to get back an id_token
- identityProxyPreference [default: serviceWorker] - Preferred identity proxy implementation (serviceWorker or XHR)
- renewStrategy [default: authCode] - Preferred method for obtaining fresh (and down-scoped) access tokens (authCode or refreshToken); see "How it works" for details.
- attemptSilentAuthGrant [default: true] - By default appAuthHelper will try to silently acquire access tokens using a silent auth code grant in a hidden iframe. This may not always be possible, and may cause some issues with various OP vendors or in the context of third-party cookie restrictions. If set to false, the default renewStrategy will become "refreshToken".
- redirectUri [default: appAuthHelperRedirect.html] - The redirect uri registered in the OP
- serviceWorkerUri [default: appAuthServiceWorker.js] - Path to the service worker script. Make sure it is located low enough in your URL path so that its scope encapsulates all application code making network requests. See [Why is my service worker failing to register?](https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API/Using_Service_Workers#Why_is_my_service_worker_failing_to_register) if you have questions.

Expand Down
6 changes: 5 additions & 1 deletion appAuthHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* @param {Object} config - configuration needed for working with the OP
* @param {string} config.clientId - The id of this RP client within the OP
* @param {boolean} [config.oidc=true] - indicate whether or not you want OIDC included
* @param {boolean} config.attemptSilentAuthGrant - indicate whether or not you want to try a silent auth code grant in a hidden iframe
* @param {string} config.authorizationEndpoint - Full URL to the OP authorization endpoint
* @param {string} config.tokenEndpoint - Full URL to the OP token endpoint
* @param {string} config.revocationEndpoint - Full URL to the OP revocation endpoint
Expand Down Expand Up @@ -43,7 +44,10 @@
this.tokensAvailableHandler = config.tokensAvailableHandler;
this.interactionRequiredHandler = config.interactionRequiredHandler;
this.appAuthConfig.oidc = typeof config.oidc !== "undefined" ? !!config.oidc : true;
this.appAuthConfig.renewStrategy = config.renewStrategy || "authCode";

this.appAuthConfig.attemptSilentAuthGrant = typeof config.attemptSilentAuthGrant !== "undefined" ? !!config.attemptSilentAuthGrant : true;
this.appAuthConfig.renewStrategy = config.renewStrategy || (this.appAuthConfig.attemptSilentAuthGrant ? "authCode" : "refreshToken");

this.pendingResourceServerRenewals = [];
this.identityProxyPreference = config.identityProxyPreference || "serviceWorker";

Expand Down
2 changes: 1 addition & 1 deletion appAuthHelperBundle.js

Large diffs are not rendered by default.

12 changes: 11 additions & 1 deletion appAuthHelperFetchTokens.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,17 @@
idToken: data.idToken
}, TRUSTED_ORIGIN);
}, () => {
tokenManager.silentAuthzRequest();
if (e.data.config.attemptSilentAuthGrant) {
tokenManager.silentAuthzRequest();
} else {
tokenManager.getAuthzURL().then((url) =>
parent.postMessage({
message: "appAuth-interactionRequired",
error: "Stored tokens unavailable and silent auth code grant not attempted",
authorizationUrl: url
}, TRUSTED_ORIGIN)
);
}
});
break;
case "makeRSRequest":
Expand Down
2 changes: 1 addition & 1 deletion appAuthHelperFetchTokensBundle.js

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "appauthhelper",
"version": "0.5.0",
"version": "0.5.1",
"description": "Wrapper for AppAuthJS to assist with silent token acquisition and renewal",
"main": "appAuthHelper.js",
"scripts": {
Expand Down