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

feature(oauth2): allow passing additional form params to token endpoint #9249

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/core/oauth2-authorize.js
Expand Up @@ -127,6 +127,7 @@ export default function authorize ( { auth, authActions, errActions, configs, au
state: state,
redirectUrl: redirectUrl,
callback: callback,
errCb: errActions.newAuthErr
errCb: errActions.newAuthErr,
authConfigs: authConfigs
})
}
8 changes: 5 additions & 3 deletions src/core/plugins/auth/actions.js
Expand Up @@ -137,21 +137,22 @@ export const authorizeApplication = ( auth ) => ( { authActions } ) => {
return authActions.authorizeRequest({body: buildFormData(form), name, url: schema.get("tokenUrl"), auth, headers })
}

export const authorizeAccessCodeWithFormParams = ( { auth, redirectUrl } ) => ( { authActions } ) => {
export const authorizeAccessCodeWithFormParams = ( { auth, redirectUrl, authConfigs } ) => ( { authActions } ) => {
let { schema, name, clientId, clientSecret, codeVerifier } = auth
let form = {
grant_type: "authorization_code",
code: auth.code,
client_id: clientId,
client_secret: clientSecret,
redirect_uri: redirectUrl,
code_verifier: codeVerifier
code_verifier: codeVerifier,
}
Object.assign(form, authConfigs.additionalTokenFormParams || {})

return authActions.authorizeRequest({body: buildFormData(form), name, url: schema.get("tokenUrl"), auth})
}

export const authorizeAccessCodeWithBasicAuthentication = ( { auth, redirectUrl } ) => ( { authActions } ) => {
export const authorizeAccessCodeWithBasicAuthentication = ( { auth, redirectUrl, authConfigs } ) => ( { authActions } ) => {
let { schema, name, clientId, clientSecret, codeVerifier } = auth
let headers = {
Authorization: "Basic " + btoa(clientId + ":" + clientSecret)
Expand All @@ -163,6 +164,7 @@ export const authorizeAccessCodeWithBasicAuthentication = ( { auth, redirectUrl
redirect_uri: redirectUrl,
code_verifier: codeVerifier
}
Object.assign(form, authConfigs.additionalTokenFormParams || {})

return authActions.authorizeRequest({body: buildFormData(form), name, url: schema.get("tokenUrl"), auth, headers})
}
Expand Down