Created
January 1, 2021 19:56
-
-
Save dcaponi/b9919931dbddfa8ee0eb8cb8083bdad2 to your computer and use it in GitHub Desktop.
Builts the auth url to an IdP using PKCE flow
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const PKCEAuthCodeFirstStep = () => { | |
let oidcURL = `${process.env.OIDC_IDP_URL}/auth`; | |
let queryParams = [`client_id=${process.env.OIDC_CLIENT_ID}`]; | |
let codeVerifier = createCodeVerifier( 50 ); | |
localStorage.setItem( 'code_verifier', codeVerifier ); | |
return createCodeChallenge( codeVerifier ).then( codeChallenge => { | |
queryParams.push(`code_challenge=${codeChallenge}`); | |
queryParams.push(`redirect_uri=http://localhost/login_oidc`); | |
queryParams.push(`code_challenge_method=S256`); | |
queryParams.push(`response_type=code`); | |
queryParams.push(`scope=openid`); | |
return `${oidcURL}?${queryParams.join("&")}`; | |
} ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment