@mongodb-js/oidc-plugin
Advanced tools
Comparing version 0.1.2 to 0.1.3
@@ -19,3 +19,3 @@ import type { MongoDBOIDCLogEventsMap, OIDCCallbackContext, IdPServerInfo, IdPServerResponse, TypedEventEmitter } from './types'; | ||
private getAuthState; | ||
private getRedirectURI; | ||
private getConfiguredRedirectURI; | ||
private getOIDCClient; | ||
@@ -22,0 +22,0 @@ private openBrowser; |
@@ -225,9 +225,8 @@ "use strict"; | ||
} | ||
getRedirectURI() { | ||
getConfiguredRedirectURI() { | ||
if (!this.isFlowAllowed('auth-code')) | ||
return ''; | ||
// TODO(MONGOSH-1394): Properly standardize a port | ||
return this.options.redirectURI ?? 'http://localhost:27097/redirect'; | ||
} | ||
async getOIDCClient(state) { | ||
async getOIDCClient(state, redirectURIs) { | ||
const serverMetadata = state.serverOIDCMetadata; | ||
@@ -245,3 +244,8 @@ const scope = [ | ||
issuer: state.client.issuer, | ||
client: state.client, | ||
// need to re-create Client here because redirect_uris might | ||
// differ between calls to this method | ||
client: new state.client.issuer.Client({ | ||
...state.client.metadata, | ||
redirect_uris: redirectURIs, | ||
}), | ||
}; | ||
@@ -252,3 +256,3 @@ } | ||
client_id: serverMetadata.clientId, | ||
redirect_uris: [this.getRedirectURI()], | ||
redirect_uris: redirectURIs, | ||
response_types: ['code'], | ||
@@ -380,3 +384,2 @@ token_endpoint_auth_method: 'none', | ||
this.verifyValidUrl(state.serverOIDCMetadata, 'issuer'); | ||
const { scope, client } = await this.getOIDCClient(state); | ||
const codeVerifier = openid_client_2.generators.codeVerifier(); | ||
@@ -386,3 +389,3 @@ const codeChallenge = openid_client_2.generators.codeChallenge(codeVerifier); | ||
const server = new rfc_8252_http_server_1.RFC8252HTTPServer({ | ||
redirectUrl: this.getRedirectURI(), | ||
redirectUrl: this.getConfiguredRedirectURI(), | ||
logger: this.logger, | ||
@@ -393,2 +396,5 @@ redirectServerRequestHandler: this.options.redirectServerRequestHandler, | ||
let paramsUrl = ''; | ||
let scope; | ||
let client; | ||
let actualRedirectURI; | ||
try { | ||
@@ -406,2 +412,6 @@ await (0, util_1.withAbortCheck)(signal, async ({ signalCheck, signalPromise }) => { | ||
]); | ||
actualRedirectURI = server.listeningRedirectUrl; | ||
({ scope, client } = await this.getOIDCClient(state, [ | ||
actualRedirectURI, | ||
])); | ||
const authCodeFlowUrl = client.authorizationUrl({ | ||
@@ -458,3 +468,3 @@ scope, | ||
const params = client.callbackParams(paramsUrl); | ||
const tokenSet = await client.callback(this.getRedirectURI(), params, { | ||
const tokenSet = await client.callback(actualRedirectURI, params, { | ||
code_verifier: codeVerifier, | ||
@@ -461,0 +471,0 @@ state: oidcStateParam, |
@@ -16,3 +16,3 @@ { | ||
"homepage": "https://github.com/mongodb-js/oidc-plugin", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"repository": { | ||
@@ -19,0 +19,0 @@ "type": "git", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
150334
2086