@backstage/plugin-auth-backend-module-microsoft-provider 0.3.19-next.0 → 0.3.19
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 +9 -0
- package/dist/strategy.cjs.js +1 -1
- package/dist/strategy.cjs.js.map +1 -1
- package/package.json +9 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @backstage/plugin-auth-backend-module-microsoft-provider
|
|
2
2
|
|
|
3
|
+
## 0.3.19
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 736d84e: Use locale-insensitive Unicode casing for consistent string handling across environments.
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @backstage/plugin-auth-node@0.7.6
|
|
10
|
+
- @backstage/backend-plugin-api@1.10.1
|
|
11
|
+
|
|
3
12
|
## 0.3.19-next.0
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
package/dist/strategy.cjs.js
CHANGED
|
@@ -29,7 +29,7 @@ class ExtendedMicrosoftStrategy extends passportMicrosoft.Strategy {
|
|
|
29
29
|
}
|
|
30
30
|
hasGraphReadScope(accessToken) {
|
|
31
31
|
const { aud, scp } = jose.decodeJwt(accessToken);
|
|
32
|
-
return aud === "00000003-0000-0000-c000-000000000000" && !!scp && scp.split(" ").map((s) => s.
|
|
32
|
+
return aud === "00000003-0000-0000-c000-000000000000" && !!scp && scp.split(" ").map((s) => s.toLowerCase()).some(
|
|
33
33
|
(s) => [
|
|
34
34
|
"https://graph.microsoft.com/user.read",
|
|
35
35
|
"https://graph.microsoft.com/user.read.all",
|
package/dist/strategy.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"strategy.cjs.js","sources":["../src/strategy.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 { PassportProfile } from '@backstage/plugin-auth-node';\nimport { decodeJwt } from 'jose';\nimport { Strategy as MicrosoftStrategy } from 'passport-microsoft';\n\nexport class ExtendedMicrosoftStrategy extends MicrosoftStrategy {\n private shouldSkipUserProfile = false;\n\n public setSkipUserProfile(shouldSkipUserProfile: boolean): void {\n this.shouldSkipUserProfile = shouldSkipUserProfile;\n }\n\n userProfile(\n accessToken: string,\n done: (err?: unknown, profile?: PassportProfile) => void,\n ): void {\n if (this.skipUserProfile(accessToken)) {\n done(null, undefined);\n return;\n }\n\n super.userProfile(\n accessToken,\n (err?: unknown, profile?: PassportProfile) => {\n if (!profile || profile.photos) {\n done(err, profile);\n return;\n }\n\n this.getProfilePhotos(accessToken).then(photos => {\n profile.photos = photos;\n done(err, profile);\n });\n },\n );\n }\n\n private hasGraphReadScope(accessToken: string): boolean {\n const { aud, scp } = decodeJwt(accessToken);\n return (\n aud === '00000003-0000-0000-c000-000000000000' &&\n !!scp &&\n (scp as string)\n .split(' ')\n .map(s => s.
|
|
1
|
+
{"version":3,"file":"strategy.cjs.js","sources":["../src/strategy.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 { PassportProfile } from '@backstage/plugin-auth-node';\nimport { decodeJwt } from 'jose';\nimport { Strategy as MicrosoftStrategy } from 'passport-microsoft';\n\nexport class ExtendedMicrosoftStrategy extends MicrosoftStrategy {\n private shouldSkipUserProfile = false;\n\n public setSkipUserProfile(shouldSkipUserProfile: boolean): void {\n this.shouldSkipUserProfile = shouldSkipUserProfile;\n }\n\n userProfile(\n accessToken: string,\n done: (err?: unknown, profile?: PassportProfile) => void,\n ): void {\n if (this.skipUserProfile(accessToken)) {\n done(null, undefined);\n return;\n }\n\n super.userProfile(\n accessToken,\n (err?: unknown, profile?: PassportProfile) => {\n if (!profile || profile.photos) {\n done(err, profile);\n return;\n }\n\n this.getProfilePhotos(accessToken).then(photos => {\n profile.photos = photos;\n done(err, profile);\n });\n },\n );\n }\n\n private hasGraphReadScope(accessToken: string): boolean {\n const { aud, scp } = decodeJwt(accessToken);\n return (\n aud === '00000003-0000-0000-c000-000000000000' &&\n !!scp &&\n (scp as string)\n .split(' ')\n .map(s => s.toLowerCase())\n .some(s =>\n [\n 'https://graph.microsoft.com/user.read',\n 'https://graph.microsoft.com/user.read.all',\n 'user.read',\n 'user.read.all',\n ].includes(s),\n )\n );\n }\n\n private skipUserProfile(accessToken: string): boolean {\n try {\n return this.shouldSkipUserProfile || !this.hasGraphReadScope(accessToken);\n } catch {\n // If there is any error with checking the scope\n // we fall back to not skipping the user profile\n // which may still result in an auth failure\n // e.g. due to a foreign scope.\n return false;\n }\n }\n\n private async getProfilePhotos(\n accessToken: string,\n ): Promise<Array<{ value: string }> | undefined> {\n return this.getCurrentUserPhoto(accessToken, '96x96').then(photo =>\n photo ? [{ value: photo }] : undefined,\n );\n }\n\n private async getCurrentUserPhoto(\n accessToken: string,\n size: string,\n ): Promise<string | undefined> {\n try {\n const res = await fetch(\n `https://graph.microsoft.com/v1.0/me/photos/${size}/$value`,\n {\n headers: {\n Authorization: `Bearer ${accessToken}`,\n },\n },\n );\n const data = await res.arrayBuffer();\n\n return `data:image/jpeg;base64,${Buffer.from(data).toString('base64')}`;\n } catch (error) {\n return undef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;AAAA,KACd;AAAA,EAEN;AAAA,EAEQ,gBAAgB,WAAA,EAA8B;AACpD,IAAA,IAAI;AACF,MAAA,OAAO,IAAA,CAAK,qBAAA,IAAyB,CAAC,IAAA,CAAK,kBAAkB,WAAW,CAAA;AAAA,IAC1E,CAAA,CAAA,MAAQ;AAKN,MAAA,OAAO,KAAA;AAAA,IACT;AAAA,EACF;AAAA,EAEA,MAAc,iBACZ,WAAA,EAC+C;AAC/C,IAAA,OAAO,IAAA,CAAK,mBAAA,CAAoB,WAAA,EAAa,OAAO,CAAA,CAAE,IAAA;AAAA,MAAK,WACzD,KAAA,GAAQ,CAAC,EAAE,KAAA,EAAO,KAAA,EAAO,CAAA,GAAI;AAAA,KAC/B;AAAA,EACF;AAAA,EAEA,MAAc,mBAAA,CACZ,WAAA,EACA,IAAA,EAC6B;AAC7B,IAAA,IAAI;AACF,MAAA,MAAM,MAAM,MAAM,KAAA;AAAA,QAChB,8CAA8C,IAAI,CAAA,OAAA,CAAA;AAAA,QAClD;AAAA,UACE,OAAA,EAAS;AAAA,YACP,aAAA,EAAe,UAAU,WAAW,CAAA;AAAA;AACtC;AACF,OACF;AACA,MAAA,MAAM,IAAA,GAAO,MAAM,GAAA,CAAI,WAAA,EAAY;AAEnC,MAAA,OAAO,0BAA0B,MAAA,CAAO,IAAA,CAAK,IAAI,CAAA,CAAE,QAAA,CAAS,QAAQ,CAAC,CAAA,CAAA;AAAA,IACvE,SAAS,KAAA,EAAO;AACd,MAAA,OAAO,MAAA;AAAA,IACT;AAAA,EACF;AACF;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-auth-backend-module-microsoft-provider",
|
|
3
|
-
"version": "0.3.19
|
|
3
|
+
"version": "0.3.19",
|
|
4
4
|
"description": "The microsoft-provider backend module for the auth plugin.",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "backend-plugin-module",
|
|
@@ -37,20 +37,20 @@
|
|
|
37
37
|
"test": "backstage-cli package test"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@backstage/backend-plugin-api": "1.10.1
|
|
41
|
-
"@backstage/plugin-auth-node": "0.7.
|
|
40
|
+
"@backstage/backend-plugin-api": "^1.10.1",
|
|
41
|
+
"@backstage/plugin-auth-node": "^0.7.6",
|
|
42
42
|
"express": "^4.22.0",
|
|
43
43
|
"jose": "^5.0.0",
|
|
44
44
|
"passport-microsoft": "^1.0.0",
|
|
45
45
|
"zod": "^3.25.76 || ^4.0.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@backstage/backend-defaults": "0.
|
|
49
|
-
"@backstage/backend-test-utils": "1.11.7
|
|
50
|
-
"@backstage/cli": "0.36.6
|
|
51
|
-
"@backstage/config": "1.3.
|
|
52
|
-
"@backstage/plugin-auth-backend": "0.30.1
|
|
53
|
-
"@backstage/types": "1.2.2",
|
|
48
|
+
"@backstage/backend-defaults": "^0.18.0",
|
|
49
|
+
"@backstage/backend-test-utils": "^1.11.7",
|
|
50
|
+
"@backstage/cli": "^0.36.6",
|
|
51
|
+
"@backstage/config": "^1.3.9",
|
|
52
|
+
"@backstage/plugin-auth-backend": "^0.30.1",
|
|
53
|
+
"@backstage/types": "^1.2.2",
|
|
54
54
|
"@types/passport-microsoft": "^1.0.0",
|
|
55
55
|
"msw": "^2.0.0",
|
|
56
56
|
"supertest": "^7.0.0"
|