@backstage/plugin-auth-backend-module-azure-easyauth-provider 0.2.1-next.0 → 0.2.1-next.1
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 +59 -0
- package/dist/authenticator.cjs.js.map +1 -0
- package/dist/index.cjs.js +8 -112
- package/dist/index.cjs.js.map +1 -1
- package/dist/module.cjs.js +48 -0
- package/dist/module.cjs.js.map +1 -0
- package/dist/resolvers.cjs.js +25 -0
- package/dist/resolvers.cjs.js.map +1 -0
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @backstage/plugin-auth-backend-module-azure-easyauth-provider
|
|
2
2
|
|
|
3
|
+
## 0.2.1-next.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
- @backstage/plugin-auth-node@0.5.3-next.1
|
|
9
|
+
- @backstage/backend-plugin-api@1.0.1-next.1
|
|
10
|
+
- @backstage/catalog-model@1.7.0
|
|
11
|
+
- @backstage/errors@1.2.4
|
|
12
|
+
|
|
3
13
|
## 0.2.1-next.0
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var errors = require('@backstage/errors');
|
|
4
|
+
var pluginAuthNode = require('@backstage/plugin-auth-node');
|
|
5
|
+
var jose = require('jose');
|
|
6
|
+
|
|
7
|
+
const ID_TOKEN_HEADER = "x-ms-token-aad-id-token";
|
|
8
|
+
const ACCESS_TOKEN_HEADER = "x-ms-token-aad-access-token";
|
|
9
|
+
const azureEasyAuthAuthenticator = pluginAuthNode.createProxyAuthenticator({
|
|
10
|
+
defaultProfileTransform: async (result) => {
|
|
11
|
+
return {
|
|
12
|
+
profile: {
|
|
13
|
+
displayName: result.fullProfile.displayName,
|
|
14
|
+
email: result.fullProfile.emails?.[0].value,
|
|
15
|
+
picture: result.fullProfile.photos?.[0].value
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
},
|
|
19
|
+
initialize() {
|
|
20
|
+
},
|
|
21
|
+
async authenticate({ req }) {
|
|
22
|
+
const result = await getResult(req);
|
|
23
|
+
return {
|
|
24
|
+
result,
|
|
25
|
+
providerInfo: {
|
|
26
|
+
accessToken: result.accessToken
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
async function getResult(req) {
|
|
32
|
+
const idToken = req.header(ID_TOKEN_HEADER);
|
|
33
|
+
const accessToken = req.header(ACCESS_TOKEN_HEADER);
|
|
34
|
+
if (idToken === void 0) {
|
|
35
|
+
throw new errors.AuthenticationError(`Missing ${ID_TOKEN_HEADER} header`);
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
fullProfile: idTokenToProfile(idToken),
|
|
39
|
+
accessToken
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function idTokenToProfile(idToken) {
|
|
43
|
+
const claims = jose.decodeJwt(idToken);
|
|
44
|
+
if (claims.ver !== "2.0") {
|
|
45
|
+
throw new Error("id_token is not version 2.0 ");
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
id: claims.oid,
|
|
49
|
+
displayName: claims.name,
|
|
50
|
+
provider: "easyauth",
|
|
51
|
+
emails: [{ value: claims.email }],
|
|
52
|
+
username: claims.preferred_username
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
exports.ACCESS_TOKEN_HEADER = ACCESS_TOKEN_HEADER;
|
|
57
|
+
exports.ID_TOKEN_HEADER = ID_TOKEN_HEADER;
|
|
58
|
+
exports.azureEasyAuthAuthenticator = azureEasyAuthAuthenticator;
|
|
59
|
+
//# sourceMappingURL=authenticator.cjs.js.map
|
|
@@ -0,0 +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 { AuthenticationError } from '@backstage/errors';\nimport { createProxyAuthenticator } from '@backstage/plugin-auth-node';\nimport { AzureEasyAuthResult } from './types';\nimport { Request } from 'express';\nimport { Profile } from 'passport';\nimport { decodeJwt } from 'jose';\n\nexport const ID_TOKEN_HEADER = 'x-ms-token-aad-id-token';\nexport const ACCESS_TOKEN_HEADER = 'x-ms-token-aad-access-token';\n\n/** @public */\nexport const azureEasyAuthAuthenticator = createProxyAuthenticator({\n defaultProfileTransform: async (result: AzureEasyAuthResult) => {\n return {\n profile: {\n displayName: result.fullProfile.displayName,\n email: result.fullProfile.emails?.[0].value,\n picture: result.fullProfile.photos?.[0].value,\n },\n };\n },\n initialize() {},\n async authenticate({ req }) {\n const result = await getResult(req);\n return {\n result,\n providerInfo: {\n accessToken: result.accessToken,\n },\n };\n },\n});\n\nasync function getResult(req: Request): Promise<AzureEasyAuthResult> {\n const idToken = req.header(ID_TOKEN_HEADER);\n const accessToken = req.header(ACCESS_TOKEN_HEADER);\n if (idToken === undefined) {\n throw new AuthenticationError(`Missing ${ID_TOKEN_HEADER} header`);\n }\n\n return {\n fullProfile: idTokenToProfile(idToken),\n accessToken: accessToken,\n };\n}\n\nfunction idTokenToProfile(idToken: string) {\n const claims = decodeJwt(idToken);\n\n if (claims.ver !== '2.0') {\n throw new Error('id_token is not version 2.0 ');\n }\n\n return {\n id: claims.oid,\n displayName: claims.name,\n provider: 'easyauth',\n emails: [{ value: claims.email }],\n username: claims.prefer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;AAAA,GACF,CAAA;AACF,CAAA;AAEA,SAAS,iBAAiB,OAAiB,EAAA;AACzC,EAAM,MAAA,MAAA,GAASC,eAAU,OAAO,CAAA,CAAA;AAEhC,EAAI,IAAA,MAAA,CAAO,QAAQ,KAAO,EAAA;AACxB,IAAM,MAAA,IAAI,MAAM,8BAA8B,CAAA,CAAA;AAAA,GAChD;AAEA,EAAO,OAAA;AAAA,IACL,IAAI,MAAO,CAAA,GAAA;AAAA,IACX,aAAa,MAAO,CAAA,IAAA;AAAA,IACpB,QAAU,EAAA,UAAA;AAAA,IACV,QAAQ,CAAC,EAAE,KAAO,EAAA,MAAA,CAAO,OAAO,CAAA;AAAA,IAChC,UAAU,MAAO,CAAA,kBAAA;AAAA,GACnB,CAAA;AACF;;;;;;"}
|
package/dist/index.cjs.js
CHANGED
|
@@ -2,120 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var jose = require('jose');
|
|
5
|
+
var module$1 = require('./module.cjs.js');
|
|
6
|
+
var authenticator = require('./authenticator.cjs.js');
|
|
7
|
+
var resolvers = require('./resolvers.cjs.js');
|
|
9
8
|
|
|
10
|
-
const ID_TOKEN_HEADER = "x-ms-token-aad-id-token";
|
|
11
|
-
const ACCESS_TOKEN_HEADER = "x-ms-token-aad-access-token";
|
|
12
|
-
const azureEasyAuthAuthenticator = pluginAuthNode.createProxyAuthenticator({
|
|
13
|
-
defaultProfileTransform: async (result) => {
|
|
14
|
-
return {
|
|
15
|
-
profile: {
|
|
16
|
-
displayName: result.fullProfile.displayName,
|
|
17
|
-
email: result.fullProfile.emails?.[0].value,
|
|
18
|
-
picture: result.fullProfile.photos?.[0].value
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
},
|
|
22
|
-
initialize() {
|
|
23
|
-
},
|
|
24
|
-
async authenticate({ req }) {
|
|
25
|
-
const result = await getResult(req);
|
|
26
|
-
return {
|
|
27
|
-
result,
|
|
28
|
-
providerInfo: {
|
|
29
|
-
accessToken: result.accessToken
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
async function getResult(req) {
|
|
35
|
-
const idToken = req.header(ID_TOKEN_HEADER);
|
|
36
|
-
const accessToken = req.header(ACCESS_TOKEN_HEADER);
|
|
37
|
-
if (idToken === void 0) {
|
|
38
|
-
throw new errors.AuthenticationError(`Missing ${ID_TOKEN_HEADER} header`);
|
|
39
|
-
}
|
|
40
|
-
return {
|
|
41
|
-
fullProfile: idTokenToProfile(idToken),
|
|
42
|
-
accessToken
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
function idTokenToProfile(idToken) {
|
|
46
|
-
const claims = jose.decodeJwt(idToken);
|
|
47
|
-
if (claims.ver !== "2.0") {
|
|
48
|
-
throw new Error("id_token is not version 2.0 ");
|
|
49
|
-
}
|
|
50
|
-
return {
|
|
51
|
-
id: claims.oid,
|
|
52
|
-
displayName: claims.name,
|
|
53
|
-
provider: "easyauth",
|
|
54
|
-
emails: [{ value: claims.email }],
|
|
55
|
-
username: claims.preferred_username
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
9
|
|
|
59
|
-
exports.azureEasyAuthSignInResolvers = void 0;
|
|
60
|
-
((azureEasyAuthSignInResolvers2) => {
|
|
61
|
-
azureEasyAuthSignInResolvers2.idMatchingUserEntityAnnotation = pluginAuthNode.createSignInResolverFactory({
|
|
62
|
-
create() {
|
|
63
|
-
return async (info, ctx) => {
|
|
64
|
-
const {
|
|
65
|
-
fullProfile: { id }
|
|
66
|
-
} = info.result;
|
|
67
|
-
if (!id) {
|
|
68
|
-
throw new Error("User profile contained no id");
|
|
69
|
-
}
|
|
70
|
-
return await ctx.signInWithCatalogUser({
|
|
71
|
-
annotations: {
|
|
72
|
-
"graph.microsoft.com/user-id": id
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
})(exports.azureEasyAuthSignInResolvers || (exports.azureEasyAuthSignInResolvers = {}));
|
|
79
10
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
deps: {
|
|
86
|
-
providers: pluginAuthNode.authProvidersExtensionPoint
|
|
87
|
-
},
|
|
88
|
-
async init({ providers }) {
|
|
89
|
-
validateAppServiceConfiguration(process.env);
|
|
90
|
-
providers.registerProvider({
|
|
91
|
-
providerId: "azureEasyAuth",
|
|
92
|
-
factory: pluginAuthNode.createProxyAuthProviderFactory({
|
|
93
|
-
authenticator: azureEasyAuthAuthenticator,
|
|
94
|
-
signInResolverFactories: {
|
|
95
|
-
...pluginAuthNode.commonSignInResolvers,
|
|
96
|
-
...exports.azureEasyAuthSignInResolvers
|
|
97
|
-
}
|
|
98
|
-
})
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
}
|
|
11
|
+
exports.default = module$1.authModuleAzureEasyAuthProvider;
|
|
12
|
+
exports.azureEasyAuthAuthenticator = authenticator.azureEasyAuthAuthenticator;
|
|
13
|
+
Object.defineProperty(exports, "azureEasyAuthSignInResolvers", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () { return resolvers.azureEasyAuthSignInResolvers; }
|
|
103
16
|
});
|
|
104
|
-
function validateAppServiceConfiguration(env) {
|
|
105
|
-
if (env.WEBSITE_SKU === void 0) {
|
|
106
|
-
throw new Error("Backstage is not running on Azure App Services");
|
|
107
|
-
}
|
|
108
|
-
if (env.WEBSITE_AUTH_ENABLED?.toLocaleLowerCase("en-US") !== "true") {
|
|
109
|
-
throw new Error("Azure App Services does not have authentication enabled");
|
|
110
|
-
}
|
|
111
|
-
if (env.WEBSITE_AUTH_DEFAULT_PROVIDER?.toLocaleLowerCase("en-US") !== "azureactivedirectory") {
|
|
112
|
-
throw new Error("Authentication provider is not Entra ID");
|
|
113
|
-
}
|
|
114
|
-
if (env.WEBSITE_AUTH_TOKEN_STORE?.toLocaleLowerCase("en-US") !== "true") {
|
|
115
|
-
throw new Error("Token Store is not enabled");
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
exports.azureEasyAuthAuthenticator = azureEasyAuthAuthenticator;
|
|
120
|
-
exports.default = authModuleAzureEasyAuthProvider;
|
|
121
17
|
//# sourceMappingURL=index.cjs.js.map
|
package/dist/index.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":[
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var backendPluginApi = require('@backstage/backend-plugin-api');
|
|
4
|
+
var pluginAuthNode = require('@backstage/plugin-auth-node');
|
|
5
|
+
var authenticator = require('./authenticator.cjs.js');
|
|
6
|
+
var resolvers = require('./resolvers.cjs.js');
|
|
7
|
+
|
|
8
|
+
const authModuleAzureEasyAuthProvider = backendPluginApi.createBackendModule({
|
|
9
|
+
pluginId: "auth",
|
|
10
|
+
moduleId: "azure-easyauth-provider",
|
|
11
|
+
register(reg) {
|
|
12
|
+
reg.registerInit({
|
|
13
|
+
deps: {
|
|
14
|
+
providers: pluginAuthNode.authProvidersExtensionPoint
|
|
15
|
+
},
|
|
16
|
+
async init({ providers }) {
|
|
17
|
+
validateAppServiceConfiguration(process.env);
|
|
18
|
+
providers.registerProvider({
|
|
19
|
+
providerId: "azureEasyAuth",
|
|
20
|
+
factory: pluginAuthNode.createProxyAuthProviderFactory({
|
|
21
|
+
authenticator: authenticator.azureEasyAuthAuthenticator,
|
|
22
|
+
signInResolverFactories: {
|
|
23
|
+
...pluginAuthNode.commonSignInResolvers,
|
|
24
|
+
...resolvers.azureEasyAuthSignInResolvers
|
|
25
|
+
}
|
|
26
|
+
})
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
function validateAppServiceConfiguration(env) {
|
|
33
|
+
if (env.WEBSITE_SKU === void 0) {
|
|
34
|
+
throw new Error("Backstage is not running on Azure App Services");
|
|
35
|
+
}
|
|
36
|
+
if (env.WEBSITE_AUTH_ENABLED?.toLocaleLowerCase("en-US") !== "true") {
|
|
37
|
+
throw new Error("Azure App Services does not have authentication enabled");
|
|
38
|
+
}
|
|
39
|
+
if (env.WEBSITE_AUTH_DEFAULT_PROVIDER?.toLocaleLowerCase("en-US") !== "azureactivedirectory") {
|
|
40
|
+
throw new Error("Authentication provider is not Entra ID");
|
|
41
|
+
}
|
|
42
|
+
if (env.WEBSITE_AUTH_TOKEN_STORE?.toLocaleLowerCase("en-US") !== "true") {
|
|
43
|
+
throw new Error("Token Store is not enabled");
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
exports.authModuleAzureEasyAuthProvider = authModuleAzureEasyAuthProvider;
|
|
48
|
+
//# sourceMappingURL=module.cjs.js.map
|
|
@@ -0,0 +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 */\n\nimport { createBackendModule } from '@backstage/backend-plugin-api';\nimport {\n authProvidersExtensionPoint,\n commonSignInResolvers,\n createProxyAuthProviderFactory,\n} from '@backstage/plugin-auth-node';\nimport { azureEasyAuthAuthenticator } from './authenticator';\nimport { azureEasyAuthSignInResolvers } from './resolvers';\n\n/** @public */\nexport const authModuleAzureEasyAuthProvider = createBackendModule({\n pluginId: 'auth',\n moduleId: 'azure-easyauth-provider',\n register(reg) {\n reg.registerInit({\n deps: {\n providers: authProvidersExtensionPoint,\n },\n async init({ providers }) {\n validateAppServiceConfiguration(process.env);\n providers.registerProvider({\n providerId: 'azureEasyAuth',\n factory: createProxyAuthProviderFactory({\n authenticator: azureEasyAuthAuthenticator,\n signInResolverFactories: {\n ...commonSignInResolvers,\n ...azureEasyAuthSignInResolvers,\n },\n }),\n });\n },\n });\n },\n});\n\nfunction validateAppServiceConfiguration(env: NodeJS.ProcessEnv) {\n // Based on https://github.com/AzureAD/microsoft-identity-web/blob/f7403779d1a91f4a3fec0ed0993bd82f50f299e1/src/Microsoft.Identity.Web/AppServicesAuth/AppServicesAuthenticationInformation.cs#L38-L59\n //\n // It's critical to validate we're really running in a correctly configured Azure App Services,\n // As we rely on App Services to manage & validate the ID and Access Token headers\n // Without that, this users can be trivially impersonated.\n if (env.WEBSITE_SKU === undefined) {\n throw new Error('Backstage is not running on Azure App Services');\n }\n if (env.WEBSITE_AUTH_ENABLED?.toLocaleLowerCase('en-US') !== 'true') {\n throw new Error('Azure App Services does not have authentication enabled');\n }\n if (\n env.WEBSITE_AUTH_DEFAULT_PROVIDER?.toLocaleLowerCase('en-US') !==\n 'azureactivedirectory'\n ) {\n throw new Error('Authentication provider is not Entra ID');\n }\n if (env.WEBSITE_AUTH_TOKEN_STORE?.toLocaleLowerCase('en-US') !== 'true') {\n throw new Error('Token Store is not enabled');\n }\n}\n"],"names":["createBackendModule","authProvidersExtensionPoint","createProxyAuthProviderFactory","azureEasyAuthAuthenticator","commonSignInResolvers","azureEasyAuthSignInResolvers"],"mappings":";;;;;;;AA0BO,MAAM,kCAAkCA,oCAAoB,CAAA;AAAA,EACjE,QAAU,EAAA,MAAA;AAAA,EACV,QAAU,EAAA,yBAAA;AAAA,EACV,SAAS,GAAK,EAAA;AACZ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
|
4
|
+
|
|
5
|
+
exports.azureEasyAuthSignInResolvers = void 0;
|
|
6
|
+
((azureEasyAuthSignInResolvers2) => {
|
|
7
|
+
azureEasyAuthSignInResolvers2.idMatchingUserEntityAnnotation = pluginAuthNode.createSignInResolverFactory({
|
|
8
|
+
create() {
|
|
9
|
+
return async (info, ctx) => {
|
|
10
|
+
const {
|
|
11
|
+
fullProfile: { id }
|
|
12
|
+
} = info.result;
|
|
13
|
+
if (!id) {
|
|
14
|
+
throw new Error("User profile contained no id");
|
|
15
|
+
}
|
|
16
|
+
return await ctx.signInWithCatalogUser({
|
|
17
|
+
annotations: {
|
|
18
|
+
"graph.microsoft.com/user-id": id
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
})(exports.azureEasyAuthSignInResolvers || (exports.azureEasyAuthSignInResolvers = {}));
|
|
25
|
+
//# sourceMappingURL=resolvers.cjs.js.map
|
|
@@ -0,0 +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 */\n\nimport {\n createSignInResolverFactory,\n SignInInfo,\n} from '@backstage/plugin-auth-node';\nimport { AzureEasyAuthResult } from './types';\n\n/** @public */\nexport namespace azureEasyAuthSignInResolvers {\n export const idMatchingUserEntityAnnotation = createSignInResolverFactory({\n create() {\n return async (info: SignInInfo<AzureEasyAuthResult>, ctx) => {\n const {\n fullProfile: { id },\n } = info.result;\n\n if (!id) {\n throw new Error('User profile contained no id');\n }\n\n return await ctx.signInWithCatalogUser({\n annotations: {\n 'graph.microsoft.com/user-id': id,\n },\n });\n };\n },\n });\n}\n"],"names":["azureEasyAuthSignInResolvers","createSignInResolverFactory"],"mappings":";;;;AAuBiBA,8CAAA;AAAA,CAAV,CAAUA,6BAAV,KAAA;AACE,EAAMA,6BAAAA,CAAA,iCAAiCC,0CAA4B,CAAA;AAAA,IACxE,MAAS,GAAA;AACP,MAAO,OAAA,OAAO,MAAuC,GAAQ,KAAA;AAC3D,QAAM,MAAA;AAAA,UACJ,WAAA,EAAa,EAAE,EAAG,EAAA;AAAA,YAChB,IAAK,CAAA,MAAA,CAAA;AAET,QAAA,IAAI,CAAC,EAAI,EAAA;AACP,UAAM,MAAA,IAAI,MAAM,8BAA8B,CAAA,CAAA;AAAA,SAChD;AAEA,QAAO,OAAA,MAAM,IAAI,qBAAsB,CAAA;AAAA,UACrC,WAAa,EAAA;AAAA,YACX,6BAA+B,EAAA,EAAA;AAAA,WACjC;AAAA,SACD,CAAA,CAAA;AAAA,OACH,CAAA;AAAA,KACF;AAAA,GACD,CAAA,CAAA;AAAA,CAnBc,EAAAD,oCAAA,KAAAA,oCAAA,GAAA,EAAA,CAAA,CAAA;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-auth-backend-module-azure-easyauth-provider",
|
|
3
|
-
"version": "0.2.1-next.
|
|
3
|
+
"version": "0.2.1-next.1",
|
|
4
4
|
"description": "The azure-easyauth-provider backend module for the auth plugin.",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "backend-plugin-module",
|
|
@@ -33,18 +33,18 @@
|
|
|
33
33
|
"test": "backstage-cli package test"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@backstage/backend-plugin-api": "
|
|
37
|
-
"@backstage/catalog-model": "
|
|
38
|
-
"@backstage/errors": "
|
|
39
|
-
"@backstage/plugin-auth-node": "
|
|
36
|
+
"@backstage/backend-plugin-api": "1.0.1-next.1",
|
|
37
|
+
"@backstage/catalog-model": "1.7.0",
|
|
38
|
+
"@backstage/errors": "1.2.4",
|
|
39
|
+
"@backstage/plugin-auth-node": "0.5.3-next.1",
|
|
40
40
|
"@types/passport": "^1.0.16",
|
|
41
41
|
"express": "^4.19.2",
|
|
42
42
|
"jose": "^5.0.0",
|
|
43
43
|
"passport": "^0.7.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@backstage/backend-test-utils": "
|
|
47
|
-
"@backstage/cli": "
|
|
48
|
-
"@backstage/plugin-auth-backend": "
|
|
46
|
+
"@backstage/backend-test-utils": "1.0.1-next.2",
|
|
47
|
+
"@backstage/cli": "0.28.0-next.2",
|
|
48
|
+
"@backstage/plugin-auth-backend": "0.23.1-next.1"
|
|
49
49
|
}
|
|
50
50
|
}
|