@backstage/plugin-auth-backend-module-microsoft-provider 0.3.3-next.1 → 0.3.3
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 +18 -0
- package/config.d.ts +13 -3
- package/dist/index.d.ts +6 -2
- package/dist/resolvers.cjs.js +27 -10
- package/dist/resolvers.cjs.js.map +1 -1
- package/package.json +11 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @backstage/plugin-auth-backend-module-microsoft-provider
|
|
2
2
|
|
|
3
|
+
## 0.3.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 5cc1f7f: Introduce `dangerouslyAllowSignInWithoutUserInCatalog` auth resolver config.
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @backstage/plugin-auth-node@0.6.3
|
|
10
|
+
- @backstage/backend-plugin-api@1.3.1
|
|
11
|
+
|
|
12
|
+
## 0.3.3-next.2
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- 5cc1f7f: Introduce `dangerouslyAllowSignInWithoutUserInCatalog` auth resolver config.
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
- @backstage/plugin-auth-node@0.6.3-next.2
|
|
19
|
+
- @backstage/backend-plugin-api@1.3.1-next.2
|
|
20
|
+
|
|
3
21
|
## 0.3.3-next.1
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/config.d.ts
CHANGED
|
@@ -34,13 +34,23 @@ export interface Config {
|
|
|
34
34
|
skipUserProfile?: boolean;
|
|
35
35
|
signIn?: {
|
|
36
36
|
resolvers: Array<
|
|
37
|
-
| {
|
|
37
|
+
| {
|
|
38
|
+
resolver: 'emailMatchingUserEntityAnnotation';
|
|
39
|
+
dangerouslyAllowSignInWithoutUserInCatalog?: boolean;
|
|
40
|
+
}
|
|
38
41
|
| {
|
|
39
42
|
resolver: 'emailLocalPartMatchingUserEntityName';
|
|
40
43
|
allowedDomains?: string[];
|
|
44
|
+
dangerouslyAllowSignInWithoutUserInCatalog?: boolean;
|
|
45
|
+
}
|
|
46
|
+
| {
|
|
47
|
+
resolver: 'emailMatchingUserEntityProfileEmail';
|
|
48
|
+
dangerouslyAllowSignInWithoutUserInCatalog?: boolean;
|
|
49
|
+
}
|
|
50
|
+
| {
|
|
51
|
+
resolver: 'userIdMatchingUserEntityAnnotation';
|
|
52
|
+
dangerouslyAllowSignInWithoutUserInCatalog?: boolean;
|
|
41
53
|
}
|
|
42
|
-
| { resolver: 'emailMatchingUserEntityProfileEmail' }
|
|
43
|
-
| { resolver: 'userIdMatchingUserEntityAnnotation' }
|
|
44
54
|
>;
|
|
45
55
|
};
|
|
46
56
|
sessionDuration?: HumanDuration | string;
|
package/dist/index.d.ts
CHANGED
|
@@ -20,11 +20,15 @@ declare namespace microsoftSignInResolvers {
|
|
|
20
20
|
/**
|
|
21
21
|
* Looks up the user by matching their Microsoft email to the email entity annotation.
|
|
22
22
|
*/
|
|
23
|
-
const emailMatchingUserEntityAnnotation: _backstage_plugin_auth_node.SignInResolverFactory<OAuthAuthenticatorResult<PassportProfile>,
|
|
23
|
+
const emailMatchingUserEntityAnnotation: _backstage_plugin_auth_node.SignInResolverFactory<OAuthAuthenticatorResult<PassportProfile>, {
|
|
24
|
+
dangerouslyAllowSignInWithoutUserInCatalog?: boolean | undefined;
|
|
25
|
+
} | undefined>;
|
|
24
26
|
/**
|
|
25
27
|
* Looks up the user by matching their Microsoft user id to the user id entity annotation.
|
|
26
28
|
*/
|
|
27
|
-
const userIdMatchingUserEntityAnnotation: _backstage_plugin_auth_node.SignInResolverFactory<OAuthAuthenticatorResult<PassportProfile>,
|
|
29
|
+
const userIdMatchingUserEntityAnnotation: _backstage_plugin_auth_node.SignInResolverFactory<OAuthAuthenticatorResult<PassportProfile>, {
|
|
30
|
+
dangerouslyAllowSignInWithoutUserInCatalog?: boolean | undefined;
|
|
31
|
+
} | undefined>;
|
|
28
32
|
}
|
|
29
33
|
|
|
30
34
|
/**
|
package/dist/resolvers.cjs.js
CHANGED
|
@@ -1,38 +1,55 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var pluginAuthNode = require('@backstage/plugin-auth-node');
|
|
4
|
+
var zod = require('zod');
|
|
4
5
|
|
|
5
6
|
exports.microsoftSignInResolvers = void 0;
|
|
6
7
|
((microsoftSignInResolvers2) => {
|
|
7
8
|
microsoftSignInResolvers2.emailMatchingUserEntityAnnotation = pluginAuthNode.createSignInResolverFactory({
|
|
8
|
-
|
|
9
|
+
optionsSchema: zod.z.object({
|
|
10
|
+
dangerouslyAllowSignInWithoutUserInCatalog: zod.z.boolean().optional()
|
|
11
|
+
}).optional(),
|
|
12
|
+
create(options = {}) {
|
|
9
13
|
return async (info, ctx) => {
|
|
10
14
|
const { profile } = info;
|
|
11
15
|
if (!profile.email) {
|
|
12
16
|
throw new Error("Microsoft profile contained no email");
|
|
13
17
|
}
|
|
14
|
-
return ctx.signInWithCatalogUser(
|
|
15
|
-
|
|
16
|
-
|
|
18
|
+
return ctx.signInWithCatalogUser(
|
|
19
|
+
{
|
|
20
|
+
annotations: {
|
|
21
|
+
"microsoft.com/email": profile.email
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
dangerousEntityRefFallback: options?.dangerouslyAllowSignInWithoutUserInCatalog ? { entityRef: { name: profile.email } } : void 0
|
|
17
26
|
}
|
|
18
|
-
|
|
27
|
+
);
|
|
19
28
|
};
|
|
20
29
|
}
|
|
21
30
|
});
|
|
22
31
|
microsoftSignInResolvers2.userIdMatchingUserEntityAnnotation = pluginAuthNode.createSignInResolverFactory(
|
|
23
32
|
{
|
|
24
|
-
|
|
33
|
+
optionsSchema: zod.z.object({
|
|
34
|
+
dangerouslyAllowSignInWithoutUserInCatalog: zod.z.boolean().optional()
|
|
35
|
+
}).optional(),
|
|
36
|
+
create(options = {}) {
|
|
25
37
|
return async (info, ctx) => {
|
|
26
38
|
const { result } = info;
|
|
27
39
|
const id = result.fullProfile.id;
|
|
28
40
|
if (!id) {
|
|
29
41
|
throw new Error("Microsoft profile contained no id");
|
|
30
42
|
}
|
|
31
|
-
return ctx.signInWithCatalogUser(
|
|
32
|
-
|
|
33
|
-
|
|
43
|
+
return ctx.signInWithCatalogUser(
|
|
44
|
+
{
|
|
45
|
+
annotations: {
|
|
46
|
+
"graph.microsoft.com/user-id": id
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
dangerousEntityRefFallback: options?.dangerouslyAllowSignInWithoutUserInCatalog ? { entityRef: { name: id } } : void 0
|
|
34
51
|
}
|
|
35
|
-
|
|
52
|
+
);
|
|
36
53
|
};
|
|
37
54
|
}
|
|
38
55
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolvers.cjs.js","sources":["../src/resolvers.ts"],"sourcesContent":["/*\n * Copyright 2023 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 OAuthAuthenticatorResult,\n createSignInResolverFactory,\n PassportProfile,\n SignInInfo,\n} from '@backstage/plugin-auth-node';\n\n/**\n * Available sign-in resolvers for the Microsoft auth provider.\n *\n * @public\n */\nexport namespace microsoftSignInResolvers {\n /**\n * Looks up the user by matching their Microsoft email to the email entity annotation.\n */\n export const emailMatchingUserEntityAnnotation = createSignInResolverFactory({\n create() {\n return async (\n info: SignInInfo<OAuthAuthenticatorResult<PassportProfile>>,\n ctx,\n ) => {\n const { profile } = info;\n\n if (!profile.email) {\n throw new Error('Microsoft profile contained no email');\n }\n\n return ctx.signInWithCatalogUser({\n
|
|
1
|
+
{"version":3,"file":"resolvers.cjs.js","sources":["../src/resolvers.ts"],"sourcesContent":["/*\n * Copyright 2023 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 OAuthAuthenticatorResult,\n createSignInResolverFactory,\n PassportProfile,\n SignInInfo,\n} from '@backstage/plugin-auth-node';\nimport { z } from 'zod';\n\n/**\n * Available sign-in resolvers for the Microsoft auth provider.\n *\n * @public\n */\nexport namespace microsoftSignInResolvers {\n /**\n * Looks up the user by matching their Microsoft email to the email entity annotation.\n */\n export const emailMatchingUserEntityAnnotation = 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('Microsoft profile contained no email');\n }\n\n return ctx.signInWithCatalogUser(\n {\n annotations: {\n 'microsoft.com/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 * Looks up the user by matching their Microsoft user id to the user id entity annotation.\n */\n export const userIdMatchingUserEntityAnnotation = createSignInResolverFactory(\n {\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 { result } = info;\n\n const id = result.fullProfile.id;\n\n if (!id) {\n throw new Error('Microsoft profile contained no id');\n }\n\n return ctx.signInWithCatalogUser(\n {\n annotations: {\n 'graph.microsoft.com/user-id': id,\n },\n },\n {\n dangerousEntityRefFallback:\n options?.dangerouslyAllowSignInWithoutUserInCatalog\n ? { entityRef: { name: id } }\n : undefined,\n },\n );\n };\n },\n },\n );\n}\n"],"names":["microsoftSignInResolvers","createSignInResolverFactory","z"],"mappings":";;;;;AA6BiBA;AAAA,CAAV,CAAUA,yBAAV,KAAA;AAIE,EAAMA,yBAAAA,CAAA,oCAAoCC,0CAA4B,CAAA;AAAA,IAC3E,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,UAAM,MAAA,IAAI,MAAM,sCAAsC,CAAA;AAAA;AAGxD,QAAA,OAAO,GAAI,CAAA,qBAAA;AAAA,UACT;AAAA,YACE,WAAa,EAAA;AAAA,cACX,uBAAuB,OAAQ,CAAA;AAAA;AACjC,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;AAIM,EAAMF,0BAAA,kCAAqC,GAAAC,0CAAA;AAAA,IAChD;AAAA,MACE,aAAA,EAAeC,MACZ,MAAO,CAAA;AAAA,QACN,0CAA4C,EAAAA,KAAA,CAAE,OAAQ,EAAA,CAAE,QAAS;AAAA,OAClE,EACA,QAAS,EAAA;AAAA,MACZ,MAAA,CAAO,OAAU,GAAA,EAAI,EAAA;AACnB,QAAO,OAAA,OACL,MACA,GACG,KAAA;AACH,UAAM,MAAA,EAAE,QAAW,GAAA,IAAA;AAEnB,UAAM,MAAA,EAAA,GAAK,OAAO,WAAY,CAAA,EAAA;AAE9B,UAAA,IAAI,CAAC,EAAI,EAAA;AACP,YAAM,MAAA,IAAI,MAAM,mCAAmC,CAAA;AAAA;AAGrD,UAAA,OAAO,GAAI,CAAA,qBAAA;AAAA,YACT;AAAA,cACE,WAAa,EAAA;AAAA,gBACX,6BAA+B,EAAA;AAAA;AACjC,aACF;AAAA,YACA;AAAA,cACE,0BAAA,EACE,SAAS,0CACL,GAAA,EAAE,WAAW,EAAE,IAAA,EAAM,EAAG,EAAA,EACxB,GAAA,KAAA;AAAA;AACR,WACF;AAAA,SACF;AAAA;AACF;AACF,GACF;AAAA,CA5Ee,EAAAF,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-microsoft-provider",
|
|
3
|
-
"version": "0.3.3
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"description": "The microsoft-provider backend module for the auth plugin.",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "backend-plugin-module",
|
|
@@ -37,19 +37,20 @@
|
|
|
37
37
|
"test": "backstage-cli package test"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@backstage/backend-plugin-api": "1.3.1
|
|
41
|
-
"@backstage/plugin-auth-node": "0.6.3
|
|
40
|
+
"@backstage/backend-plugin-api": "^1.3.1",
|
|
41
|
+
"@backstage/plugin-auth-node": "^0.6.3",
|
|
42
42
|
"express": "^4.18.2",
|
|
43
43
|
"jose": "^5.0.0",
|
|
44
|
-
"passport-microsoft": "^1.0.0"
|
|
44
|
+
"passport-microsoft": "^1.0.0",
|
|
45
|
+
"zod": "^3.22.4"
|
|
45
46
|
},
|
|
46
47
|
"devDependencies": {
|
|
47
|
-
"@backstage/backend-defaults": "0.10.0
|
|
48
|
-
"@backstage/backend-test-utils": "1.5.0
|
|
49
|
-
"@backstage/cli": "0.32.1
|
|
50
|
-
"@backstage/config": "1.3.2",
|
|
51
|
-
"@backstage/plugin-auth-backend": "0.25.0
|
|
52
|
-
"@backstage/types": "1.2.1",
|
|
48
|
+
"@backstage/backend-defaults": "^0.10.0",
|
|
49
|
+
"@backstage/backend-test-utils": "^1.5.0",
|
|
50
|
+
"@backstage/cli": "^0.32.1",
|
|
51
|
+
"@backstage/config": "^1.3.2",
|
|
52
|
+
"@backstage/plugin-auth-backend": "^0.25.0",
|
|
53
|
+
"@backstage/types": "^1.2.1",
|
|
53
54
|
"@types/passport-microsoft": "^1.0.0",
|
|
54
55
|
"msw": "^1.0.0",
|
|
55
56
|
"supertest": "^7.0.0"
|