From 35233735e81fb58dbdf91200933a91a3f9f2074c Mon Sep 17 00:00:00 2001 From: David Zemon Date: Thu, 30 Jun 2022 09:32:24 -0500 Subject: [PATCH] feat: [#12248] Switch to new okta strategy This new Okta passport strategy support custom authorization server IDs Signed-off-by: David Zemon --- plugins/auth-backend/package.json | 2 +- .../src/providers/okta/provider.ts | 4 +++ yarn.lock | 27 +++++++++++-------- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/plugins/auth-backend/package.json b/plugins/auth-backend/package.json index d6b027e6ea..5ef20a1ccf 100644 --- a/plugins/auth-backend/package.json +++ b/plugins/auth-backend/package.json @@ -40,6 +40,7 @@ "@backstage/config": "^1.0.1", "@backstage/errors": "^1.1.0-next.0", "@backstage/types": "^1.0.0", + "@davidzemon/passport-okta-oauth": "^0.0.4-2", "@google-cloud/firestore": "^5.0.2", "@types/express": "^4.17.6", "@types/passport": "^1.0.3", @@ -68,7 +69,6 @@ "passport-google-oauth20": "^2.0.0", "passport-microsoft": "^1.0.0", "passport-oauth2": "^1.6.1", - "passport-okta-oauth": "^0.0.1", "passport-onelogin-oauth": "^0.0.1", "passport-saml": "^3.1.2", "uuid": "^8.0.0", diff --git a/plugins/auth-backend/src/providers/okta/provider.ts b/plugins/auth-backend/src/providers/okta/provider.ts index de9d128641..b11df1291e 100644 --- a/plugins/auth-backend/src/providers/okta/provider.ts +++ b/plugins/auth-backend/src/providers/okta/provider.ts @@ -55,6 +55,7 @@ type PrivateInfo = { export type OktaAuthProviderOptions = OAuthProviderOptions & { audience: string; + authServerId?: string; signInResolver?: SignInResolver; authHandler: AuthHandler; resolverContext: AuthResolverContext; @@ -94,6 +95,7 @@ export class OktaAuthProvider implements OAuthHandlers { clientSecret: options.clientSecret, callbackURL: options.callbackUrl, audience: options.audience, + authServerID: options.authServerId, passReqToCallback: false, store: this.store, response_type: 'code', @@ -220,6 +222,7 @@ export const okta = createAuthProviderIntegration({ const clientId = envConfig.getString('clientId'); const clientSecret = envConfig.getString('clientSecret'); const audience = envConfig.getString('audience'); + const authServerId = envConfig.getString('authServerId'); const customCallbackUrl = envConfig.getOptionalString('callbackUrl'); const callbackUrl = customCallbackUrl || @@ -240,6 +243,7 @@ export const okta = createAuthProviderIntegration({ const provider = new OktaAuthProvider({ audience, + authServerId, clientId, clientSecret, callbackUrl, diff --git a/yarn.lock b/yarn.lock index f06a187ebf..474e2f2370 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2126,6 +2126,15 @@ dependencies: "@date-io/core" "^1.3.13" +"@davidzemon/passport-okta-oauth@^0.0.4-2": + version "0.0.4-2" + resolved "https://registry.npmjs.org/@davidzemon/passport-okta-oauth/-/passport-okta-oauth-0.0.4-2.tgz#67155fa1f591a30e65bb8b1c8a1433280ec515e2" + integrity sha512-RYyDc1w12LbpTfnTzxmVfyyvkVYYPHoH4TIUAozv27TY1VgY/QEpla2G7fidXDFlu/6itsK0s678s2idd2jhhg== + dependencies: + passport-oauth "^1.0.0" + pkginfo "^0.4.1" + uid2 "^1.0.0" + "@elastic/elasticsearch-mock@^1.0.0": version "1.0.0" resolved "https://registry.npmjs.org/@elastic/elasticsearch-mock/-/elasticsearch-mock-1.0.0.tgz#1fbaf6bf220cd74a34494ff3a8673551d9dfc66f" @@ -20349,7 +20358,7 @@ passport-oauth2@1.6.1, passport-oauth2@1.x.x, passport-oauth2@^1.1.2, passport-o uid2 "0.0.x" utils-merge "1.x.x" -passport-oauth@1.0.0: +passport-oauth@1.0.0, passport-oauth@^1.0.0: version "1.0.0" resolved "https://registry.npmjs.org/passport-oauth/-/passport-oauth-1.0.0.tgz#90aff63387540f02089af28cdad39ea7f80d77df" integrity sha1-kK/2M4dUDwIImvKM2tOep/gNd98= @@ -20357,15 +20366,6 @@ passport-oauth@1.0.0: passport-oauth1 "1.x.x" passport-oauth2 "1.x.x" -passport-okta-oauth@^0.0.1: - version "0.0.1" - resolved "https://registry.npmjs.org/passport-okta-oauth/-/passport-okta-oauth-0.0.1.tgz#c8bcee02af3d56ca79d3cca776f2df7cf15a5748" - integrity sha1-yLzuAq89Vsp508yndvLffPFaV0g= - dependencies: - passport-oauth "1.0.0" - pkginfo "0.2.x" - uid2 "0.0.3" - passport-onelogin-oauth@^0.0.1: version "0.0.1" resolved "https://registry.npmjs.org/passport-onelogin-oauth/-/passport-onelogin-oauth-0.0.1.tgz#6e991ac6720783fdd80d4caa08c36cc71ef19962" @@ -20760,7 +20760,7 @@ pkginfo@0.2.x: resolved "https://registry.npmjs.org/pkginfo/-/pkginfo-0.2.3.tgz#7239c42a5ef6c30b8f328439d9b9ff71042490f8" integrity sha1-cjnEKl72wwuPMoQ52bn/cQQkkPg= -pkginfo@0.4.x: +pkginfo@0.4.x, pkginfo@^0.4.1: version "0.4.1" resolved "https://registry.npmjs.org/pkginfo/-/pkginfo-0.4.1.tgz#b5418ef0439de5425fc4995042dced14fb2a84ff" integrity sha1-tUGO8EOd5UJfxJlQQtztFPsqhP8= @@ -25269,6 +25269,11 @@ uid2@0.0.3, uid2@0.0.x: resolved "https://registry.npmjs.org/uid2/-/uid2-0.0.3.tgz#483126e11774df2f71b8b639dcd799c376162b82" integrity sha1-SDEm4Rd03y9xuLY53NeZw3YWK4I= +uid2@^1.0.0: + version "1.0.0" + resolved "https://registry.npmjs.org/uid2/-/uid2-1.0.0.tgz#ef8d95a128d7c5c44defa1a3d052eecc17a06bfb" + integrity sha512-+I6aJUv63YAcY9n4mQreLUt0d4lvwkkopDNmpomkAUz0fAkEMV9pRWxN0EjhW1YfRhcuyHg2v3mwddCDW1+LFQ== + unbox-primitive@^1.0.1, unbox-primitive@^1.0.2: version "1.0.2" resolved "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.2.tgz#29032021057d5e6cdbd08c5129c226dff8ed6f9e"