fix(auth): support pkce when using basic auth header (#7038)

* support pkce when using basic auth header

* test(auth): useBasicAuthenticationWithAccessCodeGrant + usePkceWithAuthorizationCodeGrant
This commit is contained in:
Dan Dumont
2021-03-10 13:30:20 -05:00
committed by GitHub
parent dc694bacd8
commit f23a9d6924
3 changed files with 62 additions and 21 deletions

View File

@@ -152,7 +152,7 @@ export const authorizeAccessCodeWithFormParams = ( { auth, redirectUrl } ) => (
}
export const authorizeAccessCodeWithBasicAuthentication = ( { auth, redirectUrl } ) => ( { authActions } ) => {
let { schema, name, clientId, clientSecret } = auth
let { schema, name, clientId, clientSecret, codeVerifier } = auth
let headers = {
Authorization: "Basic " + btoa(clientId + ":" + clientSecret)
}
@@ -160,7 +160,8 @@ export const authorizeAccessCodeWithBasicAuthentication = ( { auth, redirectUrl
grant_type: "authorization_code",
code: auth.code,
client_id: clientId,
redirect_uri: redirectUrl
redirect_uri: redirectUrl,
code_verifier: codeVerifier
}
return authActions.authorizeRequest({body: buildFormData(form), name, url: schema.get("tokenUrl"), auth, headers})
@@ -277,4 +278,4 @@ export const persistAuthorizationIfNeeded = () => ( { authSelectors, getConfigs
const authorized = authSelectors.authorized()
localStorage.setItem("authorized", JSON.stringify(authorized.toJS()))
}
}
}