@backstage/plugin-auth-backend-module-bitbucket-server-provider 0.2.6-next.0 → 0.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @backstage/plugin-auth-backend-module-bitbucket-server-provider
2
2
 
3
+ ## 0.2.6
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+ - @backstage/plugin-auth-node@0.6.6
9
+ - @backstage/backend-plugin-api@1.4.2
10
+
3
11
  ## 0.2.6-next.0
4
12
 
5
13
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"authenticator.cjs.js","sources":["../src/authenticator.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Strategy as OAuth2Strategy, VerifyCallback } from 'passport-oauth2';\nimport {\n createOAuthAuthenticator,\n PassportOAuthAuthenticatorHelper,\n PassportProfile,\n} from '@backstage/plugin-auth-node';\nimport { fetchProfile } from './helpers';\n\n/** @public */\nexport const bitbucketServerAuthenticator = createOAuthAuthenticator({\n defaultProfileTransform:\n PassportOAuthAuthenticatorHelper.defaultProfileTransform,\n initialize({ callbackUrl, config }) {\n const clientID = config.getString('clientId');\n const clientSecret = config.getString('clientSecret');\n const host = config.getString('host');\n const callbackURL = config.getOptionalString('callbackUrl') ?? callbackUrl;\n\n const helper = PassportOAuthAuthenticatorHelper.from(\n new OAuth2Strategy(\n {\n clientID,\n clientSecret,\n callbackURL,\n authorizationURL: `https://${host}/rest/oauth2/latest/authorize`,\n tokenURL: `https://${host}/rest/oauth2/latest/token`,\n },\n (\n accessToken: string,\n refreshToken: string,\n params: any,\n fullProfile: PassportProfile,\n done: VerifyCallback,\n ) => {\n done(\n undefined,\n { fullProfile, params, accessToken },\n { refreshToken },\n );\n },\n ),\n );\n\n return { helper, host };\n },\n\n async start(input, { helper }) {\n return helper.start(input, {\n accessType: 'offline',\n prompt: 'consent',\n });\n },\n\n async authenticate(input, { helper, host }) {\n const result = await helper.authenticate(input);\n\n // The OAuth2 strategy does not return a user profile, so we fetch it manually\n const fullProfile = await fetchProfile({\n host,\n accessToken: result.session.accessToken,\n });\n\n return { ...result, fullProfile };\n },\n\n async refresh(input, { helper, host }) {\n const result = await helper.refresh(input);\n\n // The OAuth2 strategy does not return a user profile, so we fetch it manually\n const fullProfile = await fetchProfile({\n host,\n accessToken: result.session.accessToken,\n });\n\n return { ...result, fullProfile };\n },\n});\n"],"names":["createOAuthAuthenticator","PassportOAuthAuthenticatorHelper","OAuth2Strategy","fetchProfile"],"mappings":";;;;;;AAyBO,MAAM,+BAA+BA,uCAAyB,CAAA;AAAA,EACnE,yBACEC,+CAAiC,CAAA,uBAAA;AAAA,EACnC,UAAW,CAAA,EAAE,WAAa,EAAA,MAAA,EAAU,EAAA;AAClC,IAAM,MAAA,QAAA,GAAW,MAAO,CAAA,SAAA,CAAU,UAAU,CAAA;AAC5C,IAAM,MAAA,YAAA,GAAe,MAAO,CAAA,SAAA,CAAU,cAAc,CAAA;AACpD,IAAM,MAAA,IAAA,GAAO,MAAO,CAAA,SAAA,CAAU,MAAM,CAAA;AACpC,IAAA,MAAM,WAAc,GAAA,MAAA,CAAO,iBAAkB,CAAA,aAAa,CAAK,IAAA,WAAA;AAE/D,IAAA,MAAM,SAASA,+CAAiC,CAAA,IAAA;AAAA,MAC9C,IAAIC,uBAAA;AAAA,QACF;AAAA,UACE,QAAA;AAAA,UACA,YAAA;AAAA,UACA,WAAA;AAAA,UACA,gBAAA,EAAkB,WAAW,IA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;AAEpC,CAAC;;;;"}
1
+ {"version":3,"file":"authenticator.cjs.js","sources":["../src/authenticator.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Strategy as OAuth2Strategy, VerifyCallback } from 'passport-oauth2';\nimport {\n createOAuthAuthenticator,\n PassportOAuthAuthenticatorHelper,\n PassportProfile,\n} from '@backstage/plugin-auth-node';\nimport { fetchProfile } from './helpers';\n\n/** @public */\nexport const bitbucketServerAuthenticator = createOAuthAuthenticator({\n defaultProfileTransform:\n PassportOAuthAuthenticatorHelper.defaultProfileTransform,\n initialize({ callbackUrl, config }) {\n const clientID = config.getString('clientId');\n const clientSecret = config.getString('clientSecret');\n const host = config.getString('host');\n const callbackURL = config.getOptionalString('callbackUrl') ?? callbackUrl;\n\n const helper = PassportOAuthAuthenticatorHelper.from(\n new OAuth2Strategy(\n {\n clientID,\n clientSecret,\n callbackURL,\n authorizationURL: `https://${host}/rest/oauth2/latest/authorize`,\n tokenURL: `https://${host}/rest/oauth2/latest/token`,\n },\n (\n accessToken: string,\n refreshToken: string,\n params: any,\n fullProfile: PassportProfile,\n done: VerifyCallback,\n ) => {\n done(\n undefined,\n { fullProfile, params, accessToken },\n { refreshToken },\n );\n },\n ),\n );\n\n return { helper, host };\n },\n\n async start(input, { helper }) {\n return helper.start(input, {\n accessType: 'offline',\n prompt: 'consent',\n });\n },\n\n async authenticate(input, { helper, host }) {\n const result = await helper.authenticate(input);\n\n // The OAuth2 strategy does not return a user profile, so we fetch it manually\n const fullProfile = await fetchProfile({\n host,\n accessToken: result.session.accessToken,\n });\n\n return { ...result, fullProfile };\n },\n\n async refresh(input, { helper, host }) {\n const result = await helper.refresh(input);\n\n // The OAuth2 strategy does not return a user profile, so we fetch it manually\n const fullProfile = await fetchProfile({\n host,\n accessToken: result.session.accessToken,\n });\n\n return { ...result, fullProfile };\n },\n});\n"],"names":["createOAuthAuthenticator","PassportOAuthAuthenticatorHelper","OAuth2Strategy","fetchProfile"],"mappings":";;;;;;AAyBO,MAAM,+BAA+BA,uCAAA,CAAyB;AAAA,EACnE,yBACEC,+CAAA,CAAiC,uBAAA;AAAA,EACnC,UAAA,CAAW,EAAE,WAAA,EAAa,MAAA,EAAO,EAAG;AAClC,IAAA,MAAM,QAAA,GAAW,MAAA,CAAO,SAAA,CAAU,UAAU,CAAA;AAC5C,IAAA,MAAM,YAAA,GAAe,MAAA,CAAO,SAAA,CAAU,cAAc,CAAA;AACpD,IAAA,MAAM,IAAA,GAAO,MAAA,CAAO,SAAA,CAAU,MAAM,CAAA;AACpC,IAAA,MAAM,WAAA,GAAc,MAAA,CAAO,iBAAA,CAAkB,aAAa,CAAA,IAAK,WAAA;AAE/D,IAAA,MAAM,SAASA,+CAAA,CAAiC,IAAA;AAAA,MAC9C,IAAIC,uBAAA;AAAA,QACF;AAAA,UACE,QAAA;AAAA,UACA,YAAA;AAAA,UACA,WAAA;AAAA,UACA,gBAAA,EAAkB,WAAW,IAAI,CAAA,6BAAA,CAAA;AAAA,UACjC,QAAA,EAAU,WAAW,IAAI,CAAA,yBAAA;AAAA,SAC3B;AAAA,QACA,CACE,WAAA,EACA,YAAA,EACA,MAAA,EACA,aACA,IAAA,KACG;AACH,UAAA,IAAA;AAAA,YACE,MAAA;AAAA,YACA,EAAE,WAAA,EAAa,MAAA,EAAQ,WAAA,EAAY;AAAA,YACnC,EAAE,YAAA;AAAa,WACjB;AAAA,QACF;AAAA;AACF,KACF;AAEA,IAAA,OAAO,EAAE,QAAQ,IAAA,EAAK;AAAA,EACxB,CAAA;AAAA,EAEA,MAAM,KAAA,CAAM,KAAA,EAAO,EAAE,QAAO,EAAG;AAC7B,IAAA,OAAO,MAAA,CAAO,MAAM,KAAA,EAAO;AAAA,MACzB,UAAA,EAAY,SAAA;AAAA,MACZ,MAAA,EAAQ;AAAA,KACT,CAAA;AAAA,EACH,CAAA;AAAA,EAEA,MAAM,YAAA,CAAa,KAAA,EAAO,EAAE,MAAA,EAAQ,MAAK,EAAG;AAC1C,IAAA,MAAM,MAAA,GAAS,MAAM,MAAA,CAAO,YAAA,CAAa,KAAK,CAAA;AAG9C,IAAA,MAAM,WAAA,GAAc,MAAMC,oBAAA,CAAa;AAAA,MACrC,IAAA;AAAA,MACA,WAAA,EAAa,OAAO,OAAA,CAAQ;AAAA,KAC7B,CAAA;AAED,IAAA,OAAO,EAAE,GAAG,MAAA,EAAQ,WAAA,EAAY;AAAA,EAClC,CAAA;AAAA,EAEA,MAAM,OAAA,CAAQ,KAAA,EAAO,EAAE,MAAA,EAAQ,MAAK,EAAG;AACrC,IAAA,MAAM,MAAA,GAAS,MAAM,MAAA,CAAO,OAAA,CAAQ,KAAK,CAAA;AAGzC,IAAA,MAAM,WAAA,GAAc,MAAMA,oBAAA,CAAa;AAAA,MACrC,IAAA;AAAA,MACA,WAAA,EAAa,OAAO,OAAA,CAAQ;AAAA,KAC7B,CAAA;AAED,IAAA,OAAO,EAAE,GAAG,MAAA,EAAQ,WAAA,EAAY;AAAA,EAClC;AACF,CAAC;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.cjs.js","sources":["../src/helpers.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { PassportProfile } from '@backstage/plugin-auth-node';\n\nexport async function fetchProfile(options: {\n host: string;\n accessToken: string;\n}): Promise<PassportProfile> {\n const { host, accessToken } = options;\n // Get current user name\n let whoAmIResponse;\n try {\n whoAmIResponse = await fetch(\n `https://${host}/plugins/servlet/applinks/whoami`,\n {\n headers: {\n Authorization: `Bearer ${accessToken}`,\n },\n },\n );\n } catch (e) {\n throw new Error(`Failed to retrieve the username of the logged in user`);\n }\n\n // A response.ok check here would be worthless as the Bitbucket API always returns 200 OK for this call\n const username = whoAmIResponse.headers.get('X-Ausername');\n if (!username) {\n throw new Error(`Failed to retrieve the username of the logged in user`);\n }\n\n let userResponse;\n try {\n userResponse = await fetch(\n `https://${host}/rest/api/latest/users/${username}?avatarSize=256`,\n {\n headers: {\n Authorization: `Bearer ${accessToken}`,\n },\n },\n );\n } catch (e) {\n throw new Error(`Failed to retrieve the user '${username}'`);\n }\n\n if (!userResponse.ok) {\n throw new Error(`Failed to retrieve the user '${username}'`);\n }\n\n const user = await userResponse.json();\n\n const passportProfile = {\n provider: 'bitbucketServer',\n id: user.id.toString(),\n displayName: user.displayName,\n username: user.name,\n emails: [\n {\n value: user.emailAddress,\n },\n ],\n } as PassportProfile;\n\n if (user.avatarUrl) {\n passportProfile.photos = [{ value: `https://${host}${user.avatarUrl}` }];\n }\n\n return passportProfile;\n}\n"],"names":[],"mappings":";;AAkBA,eAAsB,aAAa,OAGN,EAAA;AAC3B,EAAM,MAAA,EAAE,IAAM,EAAA,WAAA,EAAgB,GAAA,OAAA;AAE9B,EAAI,IAAA,cAAA;AACJ,EAAI,IAAA;AACF,IAAA,cAAA,GAAiB,MAAM,KAAA;AAAA,MACrB,WAAW,IAAI,CAAA,gCAAA,CAAA;AAAA,MACf;AAAA,QACE,OAAS,EAAA;AAAA,UACP,aAAA,EAAe,UAAU,WAAW,CAAA;AAAA;AACtC;AACF,KACF;AAAA,WACO,CAAG,EAAA;AACV,IAAM,MAAA,IAAI,M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I,CAAA;AAAA;AAGzE,EAAO,OAAA,eAAA;AACT;;;;"}
1
+ {"version":3,"file":"helpers.cjs.js","sources":["../src/helpers.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { PassportProfile } from '@backstage/plugin-auth-node';\n\nexport async function fetchProfile(options: {\n host: string;\n accessToken: string;\n}): Promise<PassportProfile> {\n const { host, accessToken } = options;\n // Get current user name\n let whoAmIResponse;\n try {\n whoAmIResponse = await fetch(\n `https://${host}/plugins/servlet/applinks/whoami`,\n {\n headers: {\n Authorization: `Bearer ${accessToken}`,\n },\n },\n );\n } catch (e) {\n throw new Error(`Failed to retrieve the username of the logged in user`);\n }\n\n // A response.ok check here would be worthless as the Bitbucket API always returns 200 OK for this call\n const username = whoAmIResponse.headers.get('X-Ausername');\n if (!username) {\n throw new Error(`Failed to retrieve the username of the logged in user`);\n }\n\n let userResponse;\n try {\n userResponse = await fetch(\n `https://${host}/rest/api/latest/users/${username}?avatarSize=256`,\n {\n headers: {\n Authorization: `Bearer ${accessToken}`,\n },\n },\n );\n } catch (e) {\n throw new Error(`Failed to retrieve the user '${username}'`);\n }\n\n if (!userResponse.ok) {\n throw new Error(`Failed to retrieve the user '${username}'`);\n }\n\n const user = await userResponse.json();\n\n const passportProfile = {\n provider: 'bitbucketServer',\n id: user.id.toString(),\n displayName: user.displayName,\n username: user.name,\n emails: [\n {\n value: user.emailAddress,\n },\n ],\n } as PassportProfile;\n\n if (user.avatarUrl) {\n passportProfile.photos = [{ value: `https://${host}${user.avatarUrl}` }];\n }\n\n return passportProfile;\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;AAAA,IACtB,QAAA,EAAU,iBAAA;AAAA,IACV,EAAA,EAAI,IAAA,CAAK,EAAA,CAAG,QAAA,EAAS;AAAA,IACrB,aAAa,IAAA,CAAK,WAAA;AAAA,IAClB,UAAU,IAAA,CAAK,IAAA;AAAA,IACf,MAAA,EAAQ;AAAA,MACN;AAAA,QACE,OAAO,IAAA,CAAK;AAAA;AACd;AACF,GACF;AAEA,EAAA,IAAI,KAAK,SAAA,EAAW;AAClB,IAAA,eAAA,CAAgB,MAAA,GAAS,CAAC,EAAE,KAAA,EAAO,CAAA,QAAA,EAAW,IAAI,CAAA,EAAG,IAAA,CAAK,SAAS,CAAA,CAAA,EAAI,CAAA;AAAA,EACzE;AAEA,EAAA,OAAO,eAAA;AACT;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"module.cjs.js","sources":["../src/module.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { createBackendModule } from '@backstage/backend-plugin-api';\nimport {\n authProvidersExtensionPoint,\n commonSignInResolvers,\n createOAuthProviderFactory,\n} from '@backstage/plugin-auth-node';\nimport { bitbucketServerAuthenticator } from './authenticator';\nimport { bitbucketServerSignInResolvers } from './resolvers';\n\n/** @public */\nexport const authModuleBitbucketServerProvider = createBackendModule({\n pluginId: 'auth',\n moduleId: 'bitbucket-server-provider',\n register(reg) {\n reg.registerInit({\n deps: {\n providers: authProvidersExtensionPoint,\n },\n async init({ providers }) {\n providers.registerProvider({\n providerId: 'bitbucketServer',\n factory: createOAuthProviderFactory({\n authenticator: bitbucketServerAuthenticator,\n signInResolverFactories: {\n ...bitbucketServerSignInResolvers,\n ...commonSignInResolvers,\n },\n }),\n });\n },\n });\n },\n});\n"],"names":["createBackendModule","authProvidersExtensionPoint","createOAuthProviderFactory","bitbucketServerAuthenticator","bitbucketServerSignInResolvers","commonSignInResolvers"],"mappings":";;;;;;;AAyBO,MAAM,oCAAoCA,oCAAoB,CAAA;AAAA,EACnE,QAAU,EAAA,MAAA;AAAA,EACV,QAAU,EAAA,2BAAA;AAAA,EACV,SAAS,GAAK,EAAA;AACZ,IAAA,GAAA,CAAI,YAAa,CAAA;AAAA,MACf,IAAM,EAAA;AAAA,QACJ,SAAW,EAAAC;AAAA,OACb;AAAA,MACA,MAAM,IAAA,CAAK,EAAE,SAAA,EAAa,EAAA;AACxB,QAAA,SAAA,CAAU,gBAAiB,CAAA;AAAA,UACzB,UAAY,EAAA,iBAAA;AAAA,UACZ,SAASC,yCAA2B,CAAA;AAAA,YAClC,aAAe,EAAAC,0CAAA;AAAA,YACf,uBAAyB,EAAA;AAAA,cACvB,GAAGC,wCAAA;AAAA,cACH,GAAGC;AAAA;AACL,WACD;AAAA,SACF,CAAA;AAAA;AACH,KACD,CAAA;AAAA;AAEL,CAAC;;;;"}
1
+ {"version":3,"file":"module.cjs.js","sources":["../src/module.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { createBackendModule } from '@backstage/backend-plugin-api';\nimport {\n authProvidersExtensionPoint,\n commonSignInResolvers,\n createOAuthProviderFactory,\n} from '@backstage/plugin-auth-node';\nimport { bitbucketServerAuthenticator } from './authenticator';\nimport { bitbucketServerSignInResolvers } from './resolvers';\n\n/** @public */\nexport const authModuleBitbucketServerProvider = createBackendModule({\n pluginId: 'auth',\n moduleId: 'bitbucket-server-provider',\n register(reg) {\n reg.registerInit({\n deps: {\n providers: authProvidersExtensionPoint,\n },\n async init({ providers }) {\n providers.registerProvider({\n providerId: 'bitbucketServer',\n factory: createOAuthProviderFactory({\n authenticator: bitbucketServerAuthenticator,\n signInResolverFactories: {\n ...bitbucketServerSignInResolvers,\n ...commonSignInResolvers,\n },\n }),\n });\n },\n });\n },\n});\n"],"names":["createBackendModule","authProvidersExtensionPoint","createOAuthProviderFactory","bitbucketServerAuthenticator","bitbucketServerSignInResolvers","commonSignInResolvers"],"mappings":";;;;;;;AAyBO,MAAM,oCAAoCA,oCAAA,CAAoB;AAAA,EACnE,QAAA,EAAU,MAAA;AAAA,EACV,QAAA,EAAU,2BAAA;AAAA,EACV,SAAS,GAAA,EAAK;AACZ,IAAA,GAAA,CAAI,YAAA,CAAa;AAAA,MACf,IAAA,EAAM;AAAA,QACJ,SAAA,EAAWC;AAAA,OACb;AAAA,MACA,MAAM,IAAA,CAAK,EAAE,SAAA,EAAU,EAAG;AACxB,QAAA,SAAA,CAAU,gBAAA,CAAiB;AAAA,UACzB,UAAA,EAAY,iBAAA;AAAA,UACZ,SAASC,yCAAA,CAA2B;AAAA,YAClC,aAAA,EAAeC,0CAAA;AAAA,YACf,uBAAA,EAAyB;AAAA,cACvB,GAAGC,wCAAA;AAAA,cACH,GAAGC;AAAA;AACL,WACD;AAAA,SACF,CAAA;AAAA,MACH;AAAA,KACD,CAAA;AAAA,EACH;AACF,CAAC;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"resolvers.cjs.js","sources":["../src/resolvers.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport {\n createSignInResolverFactory,\n OAuthAuthenticatorResult,\n PassportProfile,\n SignInInfo,\n} from '@backstage/plugin-auth-node';\nimport { z } from 'zod';\n\n/**\n * Available sign-in resolvers for the Bitbucket Server auth provider.\n *\n * @public\n */\nexport namespace bitbucketServerSignInResolvers {\n /**\n * Looks up the user by matching their email to the entity email.\n */\n export const emailMatchingUserEntityProfileEmail =\n createSignInResolverFactory({\n optionsSchema: z\n .object({\n dangerouslyAllowSignInWithoutUserInCatalog: z.boolean().optional(),\n })\n .optional(),\n create(options = {}) {\n return async (\n info: SignInInfo<OAuthAuthenticatorResult<PassportProfile>>,\n ctx,\n ) => {\n const { profile } = info;\n\n if (!profile.email) {\n throw new Error(\n 'Login failed, user profile does not contain an email',\n );\n }\n\n return ctx.signInWithCatalogUser(\n {\n filter: {\n 'spec.profile.email': profile.email,\n },\n },\n {\n dangerousEntityRefFallback:\n options?.dangerouslyAllowSignInWithoutUserInCatalog\n ? { entityRef: { name: profile.email } }\n : undefined,\n },\n );\n };\n },\n });\n}\n"],"names":["bitbucketServerSignInResolvers","createSignInResolverFactory","z"],"mappings":";;;;;AA4BiBA;AAAA,CAAV,CAAUA,+BAAV,KAAA;AAIE,EAAMA,+BAAAA,CAAA,sCACXC,0CAA4B,CAAA;AAAA,IAC1B,aAAA,EAAeC,MACZ,MAAO,CAAA;AAAA,MACN,0CAA4C,EAAAA,KAAA,CAAE,OAAQ,EAAA,CAAE,QAAS;AAAA,KAClE,EACA,QAAS,EAAA;AAAA,IACZ,MAAA,CAAO,OAAU,GAAA,EAAI,EAAA;AACnB,MAAO,OAAA,OACL,MACA,GACG,KAAA;AACH,QAAM,MAAA,EAAE,SAAY,GAAA,IAAA;AAEpB,QAAI,IAAA,CAAC,QAAQ,KAAO,EAAA;AAClB,UAAA,MAAM,IAAI,KAAA;AAAA,YACR;AAAA,WACF;AAAA;AAGF,QAAA,OAAO,GAAI,CAAA,qBAAA;AAAA,UACT;AAAA,YACE,MAAQ,EAAA;AAAA,cACN,sBAAsB,OAAQ,CAAA;AAAA;AAChC,WACF;AAAA,UACA;AAAA,YACE,0BAAA,EACE,OAAS,EAAA,0CAAA,GACL,EAAE,SAAA,EAAW,EAAE,IAAM,EAAA,OAAA,CAAQ,KAAM,EAAA,EACnC,GAAA,KAAA;AAAA;AACR,SACF;AAAA,OACF;AAAA;AACF,GACD,CAAA;AAAA,CAvCY,EAAAF,sCAAA,KAAAA,sCAAA,GAAA,EAAA,CAAA,CAAA;;"}
1
+ {"version":3,"file":"resolvers.cjs.js","sources":["../src/resolvers.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport {\n createSignInResolverFactory,\n OAuthAuthenticatorResult,\n PassportProfile,\n SignInInfo,\n} from '@backstage/plugin-auth-node';\nimport { z } from 'zod';\n\n/**\n * Available sign-in resolvers for the Bitbucket Server auth provider.\n *\n * @public\n */\nexport namespace bitbucketServerSignInResolvers {\n /**\n * Looks up the user by matching their email to the entity email.\n */\n export const emailMatchingUserEntityProfileEmail =\n createSignInResolverFactory({\n optionsSchema: z\n .object({\n dangerouslyAllowSignInWithoutUserInCatalog: z.boolean().optional(),\n })\n .optional(),\n create(options = {}) {\n return async (\n info: SignInInfo<OAuthAuthenticatorResult<PassportProfile>>,\n ctx,\n ) => {\n const { profile } = info;\n\n if (!profile.email) {\n throw new Error(\n 'Login failed, user profile does not contain an email',\n );\n }\n\n return ctx.signInWithCatalogUser(\n {\n filter: {\n 'spec.profile.email': profile.email,\n },\n },\n {\n dangerousEntityRefFallback:\n options?.dangerouslyAllowSignInWithoutUserInCatalog\n ? { entityRef: { name: profile.email } }\n : undefined,\n },\n );\n };\n },\n });\n}\n"],"names":["bitbucketServerSignInResolvers","createSignInResolverFactory","z"],"mappings":";;;;;AA4BiBA;AAAA,CAAV,CAAUA,+BAAAA,KAAV;AAIE,EAAMA,+BAAAA,CAAA,sCACXC,0CAAA,CAA4B;AAAA,IAC1B,aAAA,EAAeC,MACZ,MAAA,CAAO;AAAA,MACN,0CAAA,EAA4CA,KAAA,CAAE,OAAA,EAAQ,CAAE,QAAA;AAAS,KAClE,EACA,QAAA,EAAS;AAAA,IACZ,MAAA,CAAO,OAAA,GAAU,EAAC,EAAG;AACnB,MAAA,OAAO,OACL,MACA,GAAA,KACG;AACH,QAAA,MAAM,EAAE,SAAQ,GAAI,IAAA;AAEpB,QAAA,IAAI,CAAC,QAAQ,KAAA,EAAO;AAClB,UAAA,MAAM,IAAI,KAAA;AAAA,YACR;AAAA,WACF;AAAA,QACF;AAEA,QAAA,OAAO,GAAA,CAAI,qBAAA;AAAA,UACT;AAAA,YACE,MAAA,EAAQ;AAAA,cACN,sBAAsB,OAAA,CAAQ;AAAA;AAChC,WACF;AAAA,UACA;AAAA,YACE,0BAAA,EACE,OAAA,EAAS,0CAAA,GACL,EAAE,SAAA,EAAW,EAAE,IAAA,EAAM,OAAA,CAAQ,KAAA,EAAM,EAAE,GACrC;AAAA;AACR,SACF;AAAA,MACF,CAAA;AAAA,IACF;AAAA,GACD,CAAA;AAAA,CAAA,EAvCYF,sCAAA,KAAAA,sCAAA,GAAA,EAAA,CAAA,CAAA;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-auth-backend-module-bitbucket-server-provider",
3
- "version": "0.2.6-next.0",
3
+ "version": "0.2.6",
4
4
  "description": "The bitbucket-server-provider backend module for the auth plugin.",
5
5
  "backstage": {
6
6
  "role": "backend-plugin-module",
@@ -37,18 +37,18 @@
37
37
  "test": "backstage-cli package test"
38
38
  },
39
39
  "dependencies": {
40
- "@backstage/backend-plugin-api": "1.4.2-next.0",
41
- "@backstage/plugin-auth-node": "0.6.6-next.0",
40
+ "@backstage/backend-plugin-api": "^1.4.2",
41
+ "@backstage/plugin-auth-node": "^0.6.6",
42
42
  "passport": "^0.7.0",
43
43
  "passport-oauth2": "^1.6.1",
44
44
  "zod": "^3.22.4"
45
45
  },
46
46
  "devDependencies": {
47
- "@backstage/backend-defaults": "0.11.2-next.0",
48
- "@backstage/backend-test-utils": "1.7.1-next.0",
49
- "@backstage/cli": "0.33.2-next.0",
50
- "@backstage/plugin-auth-backend": "0.25.3-next.0",
51
- "@backstage/types": "1.2.1",
47
+ "@backstage/backend-defaults": "^0.12.0",
48
+ "@backstage/backend-test-utils": "^1.8.0",
49
+ "@backstage/cli": "^0.34.0",
50
+ "@backstage/plugin-auth-backend": "^0.25.3",
51
+ "@backstage/types": "^1.2.1",
52
52
  "@types/passport-oauth2": "^1.4.15",
53
53
  "supertest": "^7.0.0"
54
54
  },