Add all supported scopes from discovery doc (#9015)

Fixes #9010
This commit is contained in:
Harshavardhana 2020-02-21 08:06:05 +05:30 committed by GitHub
parent 8fb37a8417
commit 852fb320f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 40 additions and 39 deletions

View File

@ -148,7 +148,8 @@ export class Login extends React.Component {
<OpenIDLoginButton <OpenIDLoginButton
className="btn openid-btn" className="btn openid-btn"
clientId={this.state.clientId} clientId={this.state.clientId}
authorizationEndpoint={this.state.discoveryDoc.authorization_endpoint} authEp={this.state.discoveryDoc.authorization_endpoint}
authScopes={this.state.discoveryDoc.scopes_supported}
> >
Log in with OpenID Log in with OpenID
</OpenIDLoginButton> </OpenIDLoginButton>

View File

@ -66,6 +66,7 @@ export class OpenIDLogin extends React.Component {
const authURL = buildOpenIDAuthURL( const authURL = buildOpenIDAuthURL(
this.state.discoveryDoc.authorization_endpoint, this.state.discoveryDoc.authorization_endpoint,
this.state.discoveryDoc.scopes_supported,
redirectURI, redirectURI,
this.state.clientID, this.state.clientID,
nonce nonce

View File

@ -27,7 +27,7 @@ export class OpenIDLoginButton extends React.Component {
handleClick(event) { handleClick(event) {
event.stopPropagation() event.stopPropagation()
const { authorizationEndpoint, clientId } = this.props const { authEp, authScopes, clientId } = this.props
let redirectURI = window.location.href.split("#")[0] let redirectURI = window.location.href.split("#")[0]
if (redirectURI.endsWith('/')) { if (redirectURI.endsWith('/')) {
@ -40,7 +40,7 @@ export class OpenIDLoginButton extends React.Component {
const nonce = getRandomString(16) const nonce = getRandomString(16)
storage.setItem(OPEN_ID_NONCE_KEY, nonce) storage.setItem(OPEN_ID_NONCE_KEY, nonce)
const authURL = buildOpenIDAuthURL(authorizationEndpoint, redirectURI, clientId, nonce) const authURL = buildOpenIDAuthURL(authEp, authScopes, redirectURI, clientId, nonce)
window.location = authURL window.location = authURL
} }

View File

@ -16,14 +16,13 @@
export const OPEN_ID_NONCE_KEY = 'openIDKey' export const OPEN_ID_NONCE_KEY = 'openIDKey'
export const buildOpenIDAuthURL = (authorizationEndpoint, redirectURI, clientID, nonce) => { export const buildOpenIDAuthURL = (authEp, authScopes, redirectURI, clientID, nonce) => {
const params = new URLSearchParams() const params = new URLSearchParams()
params.set("response_type", "id_token") params.set("response_type", "id_token")
params.set("scope", "openid") params.set("scope", authScopes.join(" "))
params.set("client_id", clientID) params.set("client_id", clientID)
params.set("redirect_uri", redirectURI) params.set("redirect_uri", redirectURI)
params.set("nonce", nonce) params.set("nonce", nonce)
return `${authorizationEndpoint}?${params.toString()}` return `${authEp}?${params.toString()}`
} }

File diff suppressed because one or more lines are too long

View File

@ -157,7 +157,7 @@ func main() {
TokenURL: ddoc.TokenEndpoint, TokenURL: ddoc.TokenEndpoint,
}, },
RedirectURL: fmt.Sprintf("http://localhost:%d/oauth2/callback", port), RedirectURL: fmt.Sprintf("http://localhost:%d/oauth2/callback", port),
Scopes: []string{"openid"}, Scopes: ddoc.ScopesSupported,
} }
state := randomState() state := randomState()