@backstage/plugin-auth-backend-module-openshift-provider 0.1.5-next.1 → 0.1.5
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 +10 -0
- package/dist/authenticator.cjs.js +4 -4
- package/dist/authenticator.cjs.js.map +1 -1
- package/dist/resolvers.cjs.js +3 -3
- package/dist/resolvers.cjs.js.map +1 -1
- package/package.json +11 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @backstage/plugin-auth-backend-module-openshift-provider
|
|
2
2
|
|
|
3
|
+
## 0.1.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- a49a40d: Updated dependency `zod` to `^3.25.76 || ^4.0.0` & migrated to `/v3` or `/v4` imports.
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @backstage/backend-plugin-api@1.8.0
|
|
10
|
+
- @backstage/catalog-model@1.7.7
|
|
11
|
+
- @backstage/plugin-auth-node@0.6.14
|
|
12
|
+
|
|
3
13
|
## 0.1.5-next.1
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
|
@@ -3,15 +3,15 @@
|
|
|
3
3
|
var pluginAuthNode = require('@backstage/plugin-auth-node');
|
|
4
4
|
var node_crypto = require('node:crypto');
|
|
5
5
|
var OAuth2Strategy = require('passport-oauth2');
|
|
6
|
-
var
|
|
6
|
+
var v3 = require('zod/v3');
|
|
7
7
|
|
|
8
8
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
9
9
|
|
|
10
10
|
var OAuth2Strategy__default = /*#__PURE__*/_interopDefaultCompat(OAuth2Strategy);
|
|
11
11
|
|
|
12
|
-
const OpenShiftUser =
|
|
13
|
-
metadata:
|
|
14
|
-
name:
|
|
12
|
+
const OpenShiftUser = v3.z.object({
|
|
13
|
+
metadata: v3.z.object({
|
|
14
|
+
name: v3.z.string()
|
|
15
15
|
})
|
|
16
16
|
});
|
|
17
17
|
const openshiftAuthenticator = pluginAuthNode.createOAuthAuthenticator({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authenticator.cjs.js","sources":["../src/authenticator.ts"],"sourcesContent":["/*\n * Copyright 2025 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 {\n createOAuthAuthenticator,\n PassportOAuthAuthenticatorHelper,\n PassportOAuthDoneCallback,\n PassportProfile,\n} from '@backstage/plugin-auth-node';\nimport { createHash } from 'node:crypto';\nimport OAuth2Strategy from 'passport-oauth2';\nimport { z } from 'zod';\n\n/** @public */\nexport interface OpenShiftAuthenticatorContext {\n openshiftApiServerUrl: string;\n helper: PassportOAuthAuthenticatorHelper;\n}\n\n/** @private\n * Schema for user.openshift.io/v1,\n * see https://docs.redhat.com/en/documentation/openshift_container_platform/latest/html/user_and_group_apis/user-user-openshift-io-v1#user-user-openshift-io-v1\n */\nconst OpenShiftUser = z.object({\n metadata: z.object({\n name: z.string(),\n }),\n});\n\n/** @public */\nexport const openshiftAuthenticator = createOAuthAuthenticator<\n OpenShiftAuthenticatorContext,\n PassportProfile\n>({\n defaultProfileTransform:\n PassportOAuthAuthenticatorHelper.defaultProfileTransform,\n scopes: {\n required: ['user:full'],\n },\n initialize({ callbackUrl, config }) {\n const clientId = config.getString('clientId');\n const clientSecret = config.getString('clientSecret');\n const authorizationUrl = config.getString('authorizationUrl');\n const tokenUrl = config.getString('tokenUrl');\n const openshiftApiServerUrl = config.getString('openshiftApiServerUrl');\n\n // userUrl: `${openshiftApiServerUrl}/apis/user.openshift.io/v1/users/~`,\n const strategy = new OAuth2Strategy(\n {\n clientID: clientId,\n clientSecret: clientSecret,\n callbackURL: callbackUrl,\n authorizationURL: authorizationUrl,\n tokenURL: tokenUrl,\n passReqToCallback: false,\n },\n (\n accessToken: any,\n refreshToken: string,\n params: any,\n fullProfile: PassportProfile,\n done: PassportOAuthDoneCallback,\n ) => {\n done(undefined, { fullProfile, params, accessToken }, { refreshToken });\n },\n );\n\n strategy.userProfile = function userProfile(\n accessToken: string,\n done: (err?: unknown, profile?: any) => void,\n ): void {\n this._oauth2.useAuthorizationHeaderforGET(true);\n\n this._oauth2.get(\n `${openshiftApiServerUrl}/apis/user.openshift.io/v1/users/~`,\n accessToken,\n (error, data, _) => {\n if (error !== null && error.statusCode !== 200) {\n done(new Error(`HTTP error! Status: ${error.statusCode}`));\n return;\n }\n\n if (!data) {\n done(new Error('No data provided!'));\n return;\n }\n\n if (typeof data !== 'string') {\n done(new Error('Data of type Buffer is not supported!'));\n return;\n }\n\n const user = OpenShiftUser.parse(JSON.parse(data));\n done(null, { displayName: user.metadata.name });\n },\n );\n };\n\n return {\n openshiftApiServerUrl,\n helper: PassportOAuthAuthenticatorHelper.from(strategy),\n };\n },\n async start(input, { helper }) {\n return helper.start(input, {\n accessType: 'offline',\n prompt: 'consent',\n });\n },\n async authenticate(input, { helper }) {\n // Same workaround as the GitHub provider; see https://github.com/backstage/backstage/issues/25383\n const { fullProfile, session } = await helper.authenticate(input);\n session.refreshToken = session.accessToken;\n session.refreshTokenExpiresInSeconds = session.expiresInSeconds;\n return { fullProfile, session };\n },\n async refresh(input, { helper }) {\n // Because the session is refreshed on login, this override is crucial,\n // see https://github.com/backstage/backstage/issues/25383\n const accessToken = input.refreshToken;\n\n const fullProfile = await helper.fetchProfile(accessToken).catch(error => {\n if (error.oauthError?.statusCode === 401) {\n throw new Error('Invalid access token');\n }\n throw error;\n });\n\n return {\n fullProfile,\n session: {\n accessToken,\n tokenType: 'bearer',\n scope: input.scope,\n refreshToken: input.refreshToken,\n },\n };\n },\n async logout(input, { openshiftApiServerUrl, helper }) {\n // Due to the implementation of createOAuthRouteHandlers, only the refresh token is set.\n // In this provider, the refresh token actually IS the access token.\n const accessToken = input.refreshToken;\n if (!accessToken) {\n throw new Error('access token/refresh token needs to be set for logout');\n }\n\n // Check if access token is still valid.\n try {\n await helper.fetchProfile(accessToken);\n } catch {\n // Invalid token, no need to delete OAuthAccessToken.\n return;\n }\n\n // Calculate token name, see:\n // https://docs.redhat.com/en/documentation/openshift_container_platform/latest/html/oauth_apis/oauthaccesstoken-oauth-openshift-io-v1#apis-oauth-openshift-io-v1-oauthaccesstokens\n const tokenName = createHash('sha256')\n .update(accessToken.slice('sha256~'.length))\n .digest()\n .toString('base64url');\n\n const response = await fetch(\n `${openshiftApiServerUrl}/apis/oauth.openshift.io/v1/oauthaccesstokens/sha256~${tokenName}`,\n { method: 'DELETE', headers: { Authorization: `Bearer ${accessToken}` } },\n );\n\n if (response.status === 401) {\n throw new Error('unauthorized');\n }\n },\n});\n"],"names":["z","createOAuthAuthenticator","PassportOAuthAuthenticatorHelper","OAuth2Strategy","createHash"],"mappings":";;;;;;;;;;;AAoCA,MAAM,aAAA,GAAgBA,
|
|
1
|
+
{"version":3,"file":"authenticator.cjs.js","sources":["../src/authenticator.ts"],"sourcesContent":["/*\n * Copyright 2025 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 {\n createOAuthAuthenticator,\n PassportOAuthAuthenticatorHelper,\n PassportOAuthDoneCallback,\n PassportProfile,\n} from '@backstage/plugin-auth-node';\nimport { createHash } from 'node:crypto';\nimport OAuth2Strategy from 'passport-oauth2';\nimport { z } from 'zod/v3';\n\n/** @public */\nexport interface OpenShiftAuthenticatorContext {\n openshiftApiServerUrl: string;\n helper: PassportOAuthAuthenticatorHelper;\n}\n\n/** @private\n * Schema for user.openshift.io/v1,\n * see https://docs.redhat.com/en/documentation/openshift_container_platform/latest/html/user_and_group_apis/user-user-openshift-io-v1#user-user-openshift-io-v1\n */\nconst OpenShiftUser = z.object({\n metadata: z.object({\n name: z.string(),\n }),\n});\n\n/** @public */\nexport const openshiftAuthenticator = createOAuthAuthenticator<\n OpenShiftAuthenticatorContext,\n PassportProfile\n>({\n defaultProfileTransform:\n PassportOAuthAuthenticatorHelper.defaultProfileTransform,\n scopes: {\n required: ['user:full'],\n },\n initialize({ callbackUrl, config }) {\n const clientId = config.getString('clientId');\n const clientSecret = config.getString('clientSecret');\n const authorizationUrl = config.getString('authorizationUrl');\n const tokenUrl = config.getString('tokenUrl');\n const openshiftApiServerUrl = config.getString('openshiftApiServerUrl');\n\n // userUrl: `${openshiftApiServerUrl}/apis/user.openshift.io/v1/users/~`,\n const strategy = new OAuth2Strategy(\n {\n clientID: clientId,\n clientSecret: clientSecret,\n callbackURL: callbackUrl,\n authorizationURL: authorizationUrl,\n tokenURL: tokenUrl,\n passReqToCallback: false,\n },\n (\n accessToken: any,\n refreshToken: string,\n params: any,\n fullProfile: PassportProfile,\n done: PassportOAuthDoneCallback,\n ) => {\n done(undefined, { fullProfile, params, accessToken }, { refreshToken });\n },\n );\n\n strategy.userProfile = function userProfile(\n accessToken: string,\n done: (err?: unknown, profile?: any) => void,\n ): void {\n this._oauth2.useAuthorizationHeaderforGET(true);\n\n this._oauth2.get(\n `${openshiftApiServerUrl}/apis/user.openshift.io/v1/users/~`,\n accessToken,\n (error, data, _) => {\n if (error !== null && error.statusCode !== 200) {\n done(new Error(`HTTP error! Status: ${error.statusCode}`));\n return;\n }\n\n if (!data) {\n done(new Error('No data provided!'));\n return;\n }\n\n if (typeof data !== 'string') {\n done(new Error('Data of type Buffer is not supported!'));\n return;\n }\n\n const user = OpenShiftUser.parse(JSON.parse(data));\n done(null, { displayName: user.metadata.name });\n },\n );\n };\n\n return {\n openshiftApiServerUrl,\n helper: PassportOAuthAuthenticatorHelper.from(strategy),\n };\n },\n async start(input, { helper }) {\n return helper.start(input, {\n accessType: 'offline',\n prompt: 'consent',\n });\n },\n async authenticate(input, { helper }) {\n // Same workaround as the GitHub provider; see https://github.com/backstage/backstage/issues/25383\n const { fullProfile, session } = await helper.authenticate(input);\n session.refreshToken = session.accessToken;\n session.refreshTokenExpiresInSeconds = session.expiresInSeconds;\n return { fullProfile, session };\n },\n async refresh(input, { helper }) {\n // Because the session is refreshed on login, this override is crucial,\n // see https://github.com/backstage/backstage/issues/25383\n const accessToken = input.refreshToken;\n\n const fullProfile = await helper.fetchProfile(accessToken).catch(error => {\n if (error.oauthError?.statusCode === 401) {\n throw new Error('Invalid access token');\n }\n throw error;\n });\n\n return {\n fullProfile,\n session: {\n accessToken,\n tokenType: 'bearer',\n scope: input.scope,\n refreshToken: input.refreshToken,\n },\n };\n },\n async logout(input, { openshiftApiServerUrl, helper }) {\n // Due to the implementation of createOAuthRouteHandlers, only the refresh token is set.\n // In this provider, the refresh token actually IS the access token.\n const accessToken = input.refreshToken;\n if (!accessToken) {\n throw new Error('access token/refresh token needs to be set for logout');\n }\n\n // Check if access token is still valid.\n try {\n await helper.fetchProfile(accessToken);\n } catch {\n // Invalid token, no need to delete OAuthAccessToken.\n return;\n }\n\n // Calculate token name, see:\n // https://docs.redhat.com/en/documentation/openshift_container_platform/latest/html/oauth_apis/oauthaccesstoken-oauth-openshift-io-v1#apis-oauth-openshift-io-v1-oauthaccesstokens\n const tokenName = createHash('sha256')\n .update(accessToken.slice('sha256~'.length))\n .digest()\n .toString('base64url');\n\n const response = await fetch(\n `${openshiftApiServerUrl}/apis/oauth.openshift.io/v1/oauthaccesstokens/sha256~${tokenName}`,\n { method: 'DELETE', headers: { Authorization: `Bearer ${accessToken}` } },\n );\n\n if (response.status === 401) {\n throw new Error('unauthorized');\n }\n },\n});\n"],"names":["z","createOAuthAuthenticator","PassportOAuthAuthenticatorHelper","OAuth2Strategy","createHash"],"mappings":";;;;;;;;;;;AAoCA,MAAM,aAAA,GAAgBA,KAAE,MAAA,CAAO;AAAA,EAC7B,QAAA,EAAUA,KAAE,MAAA,CAAO;AAAA,IACjB,IAAA,EAAMA,KAAE,MAAA;AAAO,GAChB;AACH,CAAC,CAAA;AAGM,MAAM,yBAAyBC,uCAAA,CAGpC;AAAA,EACA,yBACEC,+CAAA,CAAiC,uBAAA;AAAA,EACnC,MAAA,EAAQ;AAAA,IACN,QAAA,EAAU,CAAC,WAAW;AAAA,GACxB;AAAA,EACA,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,gBAAA,GAAmB,MAAA,CAAO,SAAA,CAAU,kBAAkB,CAAA;AAC5D,IAAA,MAAM,QAAA,GAAW,MAAA,CAAO,SAAA,CAAU,UAAU,CAAA;AAC5C,IAAA,MAAM,qBAAA,GAAwB,MAAA,CAAO,SAAA,CAAU,uBAAuB,CAAA;AAGtE,IAAA,MAAM,WAAW,IAAIC,+BAAA;AAAA,MACnB;AAAA,QACE,QAAA,EAAU,QAAA;AAAA,QACV,YAAA;AAAA,QACA,WAAA,EAAa,WAAA;AAAA,QACb,gBAAA,EAAkB,gBAAA;AAAA,QAClB,QAAA,EAAU,QAAA;AAAA,QACV,iBAAA,EAAmB;AAAA,OACrB;AAAA,MACA,CACE,WAAA,EACA,YAAA,EACA,MAAA,EACA,aACA,IAAA,KACG;AACH,QAAA,IAAA,CAAK,MAAA,EAAW,EAAE,WAAA,EAAa,MAAA,EAAQ,aAAY,EAAG,EAAE,cAAc,CAAA;AAAA,MACxE;A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MAAQ;AAEN,MAAA;AAAA,IACF;AAIA,IAAA,MAAM,SAAA,GAAYE,sBAAA,CAAW,QAAQ,CAAA,CAClC,OAAO,WAAA,CAAY,KAAA,CAAM,SAAA,CAAU,MAAM,CAAC,CAAA,CAC1C,MAAA,EAAO,CACP,SAAS,WAAW,CAAA;AAEvB,IAAA,MAAM,WAAW,MAAM,KAAA;AAAA,MACrB,CAAA,EAAG,qBAAqB,CAAA,qDAAA,EAAwD,SAAS,CAAA,CAAA;AAAA,MACzF,EAAE,QAAQ,QAAA,EAAU,OAAA,EAAS,EAAE,aAAA,EAAe,CAAA,OAAA,EAAU,WAAW,CAAA,CAAA,EAAG;AAAE,KAC1E;AAEA,IAAA,IAAI,QAAA,CAAS,WAAW,GAAA,EAAK;AAC3B,MAAA,MAAM,IAAI,MAAM,cAAc,CAAA;AAAA,IAChC;AAAA,EACF;AACF,CAAC;;;;"}
|
package/dist/resolvers.cjs.js
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
var pluginAuthNode = require('@backstage/plugin-auth-node');
|
|
4
4
|
var catalogModel = require('@backstage/catalog-model');
|
|
5
|
-
var
|
|
5
|
+
var v3 = require('zod/v3');
|
|
6
6
|
|
|
7
7
|
exports.openshiftSignInResolvers = void 0;
|
|
8
8
|
((openshiftSignInResolvers2) => {
|
|
9
9
|
openshiftSignInResolvers2.displayNameMatchingUserEntityName = pluginAuthNode.createSignInResolverFactory({
|
|
10
|
-
optionsSchema:
|
|
11
|
-
dangerouslyAllowSignInWithoutUserInCatalog:
|
|
10
|
+
optionsSchema: v3.z.object({
|
|
11
|
+
dangerouslyAllowSignInWithoutUserInCatalog: v3.z.boolean().optional()
|
|
12
12
|
}).optional(),
|
|
13
13
|
create(options = {}) {
|
|
14
14
|
return async (info, ctx) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolvers.cjs.js","sources":["../src/resolvers.ts"],"sourcesContent":["/*\n * Copyright 2025 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 {\n createSignInResolverFactory,\n OAuthAuthenticatorResult,\n PassportProfile,\n SignInInfo,\n} from '@backstage/plugin-auth-node';\n\nimport {\n DEFAULT_NAMESPACE,\n stringifyEntityRef,\n} from '@backstage/catalog-model';\nimport { z } from 'zod';\n\nexport namespace openshiftSignInResolvers {\n export const displayNameMatchingUserEntityName = 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 { displayName } = info.profile;\n\n if (!displayName) {\n throw new Error(\n `OpenShift user profile does not contain a displayName`,\n );\n }\n\n const userRef = stringifyEntityRef({\n kind: 'User',\n name: displayName,\n namespace: DEFAULT_NAMESPACE,\n });\n\n return await ctx.signInWithCatalogUser(\n { entityRef: userRef },\n {\n dangerousEntityRefFallback:\n options?.dangerouslyAllowSignInWithoutUserInCatalog\n ? { entityRef: { name: displayName } }\n : undefined,\n },\n );\n };\n },\n });\n}\n"],"names":["openshiftSignInResolvers","createSignInResolverFactory","z","stringifyEntityRef","DEFAULT_NAMESPACE"],"mappings":";;;;;;AA6BiBA;AAAA,CAAV,CAAUA,yBAAAA,KAAV;AACE,EAAMA,yBAAAA,CAAA,oCAAoCC,0CAAA,CAA4B;AAAA,IAC3E,aAAA,EAAeC,
|
|
1
|
+
{"version":3,"file":"resolvers.cjs.js","sources":["../src/resolvers.ts"],"sourcesContent":["/*\n * Copyright 2025 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 {\n createSignInResolverFactory,\n OAuthAuthenticatorResult,\n PassportProfile,\n SignInInfo,\n} from '@backstage/plugin-auth-node';\n\nimport {\n DEFAULT_NAMESPACE,\n stringifyEntityRef,\n} from '@backstage/catalog-model';\nimport { z } from 'zod/v3';\n\nexport namespace openshiftSignInResolvers {\n export const displayNameMatchingUserEntityName = 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 { displayName } = info.profile;\n\n if (!displayName) {\n throw new Error(\n `OpenShift user profile does not contain a displayName`,\n );\n }\n\n const userRef = stringifyEntityRef({\n kind: 'User',\n name: displayName,\n namespace: DEFAULT_NAMESPACE,\n });\n\n return await ctx.signInWithCatalogUser(\n { entityRef: userRef },\n {\n dangerousEntityRefFallback:\n options?.dangerouslyAllowSignInWithoutUserInCatalog\n ? { entityRef: { name: displayName } }\n : undefined,\n },\n );\n };\n },\n });\n}\n"],"names":["openshiftSignInResolvers","createSignInResolverFactory","z","stringifyEntityRef","DEFAULT_NAMESPACE"],"mappings":";;;;;;AA6BiBA;AAAA,CAAV,CAAUA,yBAAAA,KAAV;AACE,EAAMA,yBAAAA,CAAA,oCAAoCC,0CAAA,CAA4B;AAAA,IAC3E,aAAA,EAAeC,KACZ,MAAA,CAAO;AAAA,MACN,0CAAA,EAA4CA,IAAA,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,WAAA,EAAY,GAAI,IAAA,CAAK,OAAA;AAE7B,QAAA,IAAI,CAAC,WAAA,EAAa;AAChB,UAAA,MAAM,IAAI,KAAA;AAAA,YACR,CAAA,qDAAA;AAAA,WACF;AAAA,QACF;AAEA,QAAA,MAAM,UAAUC,+BAAA,CAAmB;AAAA,UACjC,IAAA,EAAM,MAAA;AAAA,UACN,IAAA,EAAM,WAAA;AAAA,UACN,SAAA,EAAWC;AAAA,SACZ,CAAA;AAED,QAAA,OAAO,MAAM,GAAA,CAAI,qBAAA;AAAA,UACf,EAAE,WAAW,OAAA,EAAQ;AAAA,UACrB;AAAA,YACE,0BAAA,EACE,SAAS,0CAAA,GACL,EAAE,WAAW,EAAE,IAAA,EAAM,WAAA,EAAY,EAAE,GACnC;AAAA;AACR,SACF;AAAA,MACF,CAAA;AAAA,IACF;AAAA,GACD,CAAA;AAAA,CAAA,EArCcJ,gCAAA,KAAAA,gCAAA,GAAA,EAAA,CAAA,CAAA;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-auth-backend-module-openshift-provider",
|
|
3
|
-
"version": "0.1.5
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "The OpenShift backend module for the auth plugin.",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "backend-plugin-module",
|
|
@@ -37,19 +37,19 @@
|
|
|
37
37
|
"test": "backstage-cli package test"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@backstage/backend-plugin-api": "1.8.0
|
|
41
|
-
"@backstage/catalog-model": "1.7.
|
|
42
|
-
"@backstage/plugin-auth-node": "0.6.14
|
|
43
|
-
"@backstage/types": "1.2.2",
|
|
40
|
+
"@backstage/backend-plugin-api": "^1.8.0",
|
|
41
|
+
"@backstage/catalog-model": "^1.7.7",
|
|
42
|
+
"@backstage/plugin-auth-node": "^0.6.14",
|
|
43
|
+
"@backstage/types": "^1.2.2",
|
|
44
44
|
"passport-oauth2": "^1.8.0",
|
|
45
|
-
"zod": "^3.
|
|
45
|
+
"zod": "^3.25.76 || ^4.0.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@backstage/backend-defaults": "0.16.0
|
|
49
|
-
"@backstage/backend-test-utils": "1.11.1
|
|
50
|
-
"@backstage/cli": "0.36.0
|
|
51
|
-
"@backstage/config": "1.3.6",
|
|
52
|
-
"@backstage/plugin-auth-backend": "0.27.
|
|
48
|
+
"@backstage/backend-defaults": "^0.16.0",
|
|
49
|
+
"@backstage/backend-test-utils": "^1.11.1",
|
|
50
|
+
"@backstage/cli": "^0.36.0",
|
|
51
|
+
"@backstage/config": "^1.3.6",
|
|
52
|
+
"@backstage/plugin-auth-backend": "^0.27.2",
|
|
53
53
|
"express": "^4.22.0",
|
|
54
54
|
"msw": "^2.7.3",
|
|
55
55
|
"supertest": "^7.1.0"
|