Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SDK-3548] Introduce authorizationParams to hold properties sent to Auth0 #959

Merged
merged 8 commits into from
Aug 18, 2022

Conversation

ewanharris
Copy link
Contributor

@ewanharris ewanharris commented Aug 17, 2022

Changes

Moves all properties that are intended to be sent to Auth0 as part of the auth process into a authorizationParams or logoutParams object.

The code changes in this PR in summary:

  • The existing BaseLoginOptions has now become AuthorizationParams, this holds the parameters that will be sent to the Authorization Server (Auth0) and is where custom parameters to send along also can be set
  • A new BaseLoginOptions interface was added that simply contains authorizationParams?: AuthorizationParams and the existing interfaces continue to extend that, with the exception of GetTokenSilentlyOptions which only contains a subset of AuthorizationParams properties by nature
  • LogoutUrlOptions and LogoutOptions now contain a logoutParams object that holds parameters to be sent to the logout endpoint, this object also supports the same custom parameters allowance like authorizationParams,

As a developer using the SDK, a summary is that any properties relevant to the Authorization Server (Auth0) or custom parameters that were provided now need to be moved into a authorizationParams object and for Logout Endpoint related parameters or again any custom parameters provided to the Logout Endpoint should now be provided in a logoutParams object. An example (but not exhaustive) diff of these changes follows.

  • Auth0Client constructor
const auth0 = new Auth0Client({
  clientId: '<AUTH0_CLIENT_ID>',
  domain: '<AUTH0_DOMAIN>',
- scope: '<MY_SCOPE>',
- redirect_uri: '<MY_CALLBACK_URL>',
- custom_param: 'custom value'
+ authorizationParams: {
+   redirect_uri: '<MY_CALLBACK_URL>',
+   custom_param: 'custom value',
+   scope: '<MY_SCOPE>'
+ }
});
  • createAuth0Client helper
const auth0 = await createAuth0Client({
  clientId: '<AUTH0_CLIENT_ID>',
  domain: '<AUTH0_DOMAIN>',
- scope: '<MY_SCOPE>',
- redirect_uri: '<MY_CALLBACK_URL>'
- custom_param: 'custom value'
+ authorizationParams: {
+   redirect_uri: '<MY_CALLBACK_URL>'
+   custom_param: 'custom value',
+   scope: '<MY_SCOPE>'
+ }
});

This change should also be made to the buildAuthorizeUrl, checkSession, getTokenSilently, getTokenWithPopup login, loginWithPopup, and loginWithRedirect APIs.

  • auth0.buildLogoutUrl
auth0.buildLogoutUrl({
- returnTo: '<MY_RETURNTO_URL>'
- custom_param: 'custom value'
+ logoutParams: {
+   returnTo: '<MY_RETURNTO_URL>'
+   custom_param: 'custom value'
+ }
});
  • auth0. logout
auth0. logout({
  localOnly: true,
- returnTo: '<MY_RETURNTO_URL>'
- custom_param: 'custom value'
+ logoutParams: {
+   returnTo: '<MY_RETURNTO_URL>'
+   custom_param: 'custom value'
+ }
});

Checklist

@ewanharris ewanharris marked this pull request as ready for review August 18, 2022 10:22
@ewanharris ewanharris requested a review from a team as a code owner August 18, 2022 10:22
src/Auth0Client.ts Outdated Show resolved Hide resolved
src/Auth0Client.ts Outdated Show resolved Hide resolved
src/Auth0Client.ts Outdated Show resolved Hide resolved
src/Auth0Client.ts Show resolved Hide resolved
src/Auth0Client.ts Show resolved Hide resolved
@ewanharris ewanharris enabled auto-merge (squash) August 18, 2022 15:05
@ewanharris ewanharris merged commit b0541c8 into v2 Aug 18, 2022
@ewanharris ewanharris deleted the refactor/SDK-3548 branch August 18, 2022 15:47
@frederikprijck frederikprijck mentioned this pull request Oct 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants