@backstage/plugin-auth-backend-module-auth0-provider 0.1.1-next.0 → 0.1.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 +16 -0
- package/dist/authenticator.cjs.js +75 -0
- package/dist/authenticator.cjs.js.map +1 -0
- package/dist/index.cjs.js +4 -111
- package/dist/index.cjs.js.map +1 -1
- package/dist/module.cjs.js +31 -0
- package/dist/module.cjs.js.map +1 -0
- package/dist/strategy.cjs.js +23 -0
- package/dist/strategy.cjs.js.map +1 -0
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @backstage/plugin-auth-backend-module-auth0-provider
|
|
2
2
|
|
|
3
|
+
## 0.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
- @backstage/plugin-auth-node@0.5.3
|
|
9
|
+
- @backstage/backend-plugin-api@1.0.1
|
|
10
|
+
|
|
11
|
+
## 0.1.1-next.1
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies
|
|
16
|
+
- @backstage/plugin-auth-node@0.5.3-next.1
|
|
17
|
+
- @backstage/backend-plugin-api@1.0.1-next.1
|
|
18
|
+
|
|
3
19
|
## 0.1.1-next.0
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var pluginAuthNode = require('@backstage/plugin-auth-node');
|
|
4
|
+
var strategy = require('./strategy.cjs.js');
|
|
5
|
+
|
|
6
|
+
const auth0Authenticator = pluginAuthNode.createOAuthAuthenticator({
|
|
7
|
+
defaultProfileTransform: pluginAuthNode.PassportOAuthAuthenticatorHelper.defaultProfileTransform,
|
|
8
|
+
initialize({ callbackUrl, config }) {
|
|
9
|
+
const clientID = config.getString("clientId");
|
|
10
|
+
const clientSecret = config.getString("clientSecret");
|
|
11
|
+
const domain = config.getString("domain");
|
|
12
|
+
const audience = config.getOptionalString("audience");
|
|
13
|
+
const connection = config.getOptionalString("connection");
|
|
14
|
+
const connectionScope = config.getOptionalString("connectionScope");
|
|
15
|
+
const callbackURL = config.getOptionalString("callbackUrl") ?? callbackUrl;
|
|
16
|
+
const store = {
|
|
17
|
+
store(_req, cb) {
|
|
18
|
+
cb(null, null);
|
|
19
|
+
},
|
|
20
|
+
verify(_req, _state, cb) {
|
|
21
|
+
cb(null, true);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
const helper = pluginAuthNode.PassportOAuthAuthenticatorHelper.from(
|
|
25
|
+
new strategy.Auth0Strategy(
|
|
26
|
+
{
|
|
27
|
+
clientID,
|
|
28
|
+
clientSecret,
|
|
29
|
+
callbackURL,
|
|
30
|
+
domain,
|
|
31
|
+
store,
|
|
32
|
+
// We need passReqToCallback set to false to get params, but there's
|
|
33
|
+
// no matching type signature for that, so instead behold this beauty
|
|
34
|
+
passReqToCallback: false
|
|
35
|
+
},
|
|
36
|
+
(accessToken, refreshToken, params, fullProfile, done) => {
|
|
37
|
+
done(
|
|
38
|
+
void 0,
|
|
39
|
+
{
|
|
40
|
+
fullProfile,
|
|
41
|
+
accessToken,
|
|
42
|
+
params
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
refreshToken
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
)
|
|
50
|
+
);
|
|
51
|
+
return { helper, audience, connection, connectionScope };
|
|
52
|
+
},
|
|
53
|
+
async start(input, { helper, audience, connection, connectionScope: connection_scope }) {
|
|
54
|
+
return helper.start(input, {
|
|
55
|
+
accessType: "offline",
|
|
56
|
+
prompt: "consent",
|
|
57
|
+
...audience ? { audience } : {},
|
|
58
|
+
...connection ? { connection } : {},
|
|
59
|
+
...connection_scope ? { connection_scope } : {}
|
|
60
|
+
});
|
|
61
|
+
},
|
|
62
|
+
async authenticate(input, { helper, audience, connection, connectionScope: connection_scope }) {
|
|
63
|
+
return helper.authenticate(input, {
|
|
64
|
+
...audience ? { audience } : {},
|
|
65
|
+
...connection ? { connection } : {},
|
|
66
|
+
...connection_scope ? { connection_scope } : {}
|
|
67
|
+
});
|
|
68
|
+
},
|
|
69
|
+
async refresh(input, { helper }) {
|
|
70
|
+
return helper.refresh(input);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
exports.auth0Authenticator = auth0Authenticator;
|
|
75
|
+
//# 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 express from 'express';\nimport {\n createOAuthAuthenticator,\n PassportOAuthAuthenticatorHelper,\n PassportOAuthDoneCallback,\n PassportProfile,\n} from '@backstage/plugin-auth-node';\nimport { Auth0Strategy } from './strategy';\n\n/** @public */\nexport const auth0Authenticator = createOAuthAuthenticator({\n defaultProfileTransform:\n PassportOAuthAuthenticatorHelper.defaultProfileTransform,\n initialize({ callbackUrl, config }) {\n const clientID = config.getString('clientId');\n const clientSecret = config.getString('clientSecret');\n const domain = config.getString('domain');\n const audience = config.getOptionalString('audience');\n const connection = config.getOptionalString('connection');\n const connectionScope = config.getOptionalString('connectionScope');\n const callbackURL = config.getOptionalString('callbackUrl') ?? callbackUrl;\n // Due to passport-auth0 forcing options.state = true,\n // passport-oauth2 requires express-session to be installed\n // so that the 'state' parameter of the oauth2 flow can be stored.\n // This implementation of StateStore matches the NullStore found within\n // passport-oauth2, which is the StateStore implementation used when options.state = false,\n // allowing us to avoid using express-session in order to integrate with auth0.\n const store = {\n store(_req: express.Request, cb: any) {\n cb(null, null);\n },\n verify(_req: express.Request, _state: string, cb: any) {\n cb(null, true);\n },\n };\n\n const helper = PassportOAuthAuthenticatorHelper.from(\n new Auth0Strategy(\n {\n clientID,\n clientSecret,\n callbackURL,\n domain,\n store,\n // We need passReqToCallback set to false to get params, but there's\n // no matching type signature for that, so instead behold this beauty\n passReqToCallback: false as true,\n },\n (\n accessToken: string,\n refreshToken: string,\n params: any,\n fullProfile: PassportProfile,\n done: PassportOAuthDoneCallback,\n ) => {\n done(\n undefined,\n {\n fullProfile,\n accessToken,\n params,\n },\n {\n refreshToken,\n },\n );\n },\n ),\n );\n return { helper, audience, connection, connectionScope };\n },\n\n async start(\n input,\n { helper, audience, connection, connectionScope: connection_scope },\n ) {\n return helper.start(input, {\n accessType: 'offline',\n prompt: 'consent',\n ...(audience ? { audience } : {}),\n ...(connection ? { connection } : {}),\n ...(connection_scope ? { connection_scope } : {}),\n });\n },\n\n async authenticate(\n input,\n { helper, audience, connection, connectionScope: connection_scope },\n ) {\n return helper.authenticate(input, {\n ...(audience ? { audience } : {}),\n ...(connection ? { connection } : {}),\n ...(connection_scope ? { connection_scope } : {}),\n });\n },\n\n async refresh(input, { helper }) {\n return helper.refresh(input);\n },\n});\n"],"names":["createOAuthAuthenticator","PassportOAuthAuthenticatorHelper","Auth0Strategy"],"mappings":";;;;;AA0BO,MAAM,qBAAqBA,uCAAyB,CAAA;AAAA,EACzD,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,CAAA;AAC5C,IAAM,MAAA,YAAA,GAAe,MAAO,CAAA,SAAA,CA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Y,eAAgB,EAAA,CAAA;AAAA,GACzD;AAAA,EAEA,MAAM,MACJ,KACA,EAAA,EAAE,QAAQ,QAAU,EAAA,UAAA,EAAY,eAAiB,EAAA,gBAAA,EACjD,EAAA;AACA,IAAO,OAAA,MAAA,CAAO,MAAM,KAAO,EAAA;AAAA,MACzB,UAAY,EAAA,SAAA;AAAA,MACZ,MAAQ,EAAA,SAAA;AAAA,MACR,GAAI,QAAA,GAAW,EAAE,QAAA,KAAa,EAAC;AAAA,MAC/B,GAAI,UAAA,GAAa,EAAE,UAAA,KAAe,EAAC;AAAA,MACnC,GAAI,gBAAA,GAAmB,EAAE,gBAAA,KAAqB,EAAC;AAAA,KAChD,CAAA,CAAA;AAAA,GACH;AAAA,EAEA,MAAM,aACJ,KACA,EAAA,EAAE,QAAQ,QAAU,EAAA,UAAA,EAAY,eAAiB,EAAA,gBAAA,EACjD,EAAA;AACA,IAAO,OAAA,MAAA,CAAO,aAAa,KAAO,EAAA;AAAA,MAChC,GAAI,QAAA,GAAW,EAAE,QAAA,KAAa,EAAC;AAAA,MAC/B,GAAI,UAAA,GAAa,EAAE,UAAA,KAAe,EAAC;AAAA,MACnC,GAAI,gBAAA,GAAmB,EAAE,gBAAA,KAAqB,EAAC;AAAA,KAChD,CAAA,CAAA;AAAA,GACH;AAAA,EAEA,MAAM,OAAA,CAAQ,KAAO,EAAA,EAAE,QAAU,EAAA;AAC/B,IAAO,OAAA,MAAA,CAAO,QAAQ,KAAK,CAAA,CAAA;AAAA,GAC7B;AACF,CAAC;;;;"}
|
package/dist/index.cjs.js
CHANGED
|
@@ -2,118 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var backendPluginApi = require('@backstage/backend-plugin-api');
|
|
5
|
+
var authenticator = require('./authenticator.cjs.js');
|
|
6
|
+
var module$1 = require('./module.cjs.js');
|
|
8
7
|
|
|
9
|
-
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
10
8
|
|
|
11
|
-
var Auth0InternalStrategy__default = /*#__PURE__*/_interopDefaultCompat(Auth0InternalStrategy);
|
|
12
9
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const optionsWithURLs = {
|
|
16
|
-
...options,
|
|
17
|
-
authorizationURL: `https://${options.domain}/authorize`,
|
|
18
|
-
tokenURL: `https://${options.domain}/oauth/token`,
|
|
19
|
-
userInfoURL: `https://${options.domain}/userinfo`,
|
|
20
|
-
apiUrl: `https://${options.domain}/api`
|
|
21
|
-
};
|
|
22
|
-
super(optionsWithURLs, verify);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const auth0Authenticator = pluginAuthNode.createOAuthAuthenticator({
|
|
27
|
-
defaultProfileTransform: pluginAuthNode.PassportOAuthAuthenticatorHelper.defaultProfileTransform,
|
|
28
|
-
initialize({ callbackUrl, config }) {
|
|
29
|
-
const clientID = config.getString("clientId");
|
|
30
|
-
const clientSecret = config.getString("clientSecret");
|
|
31
|
-
const domain = config.getString("domain");
|
|
32
|
-
const audience = config.getOptionalString("audience");
|
|
33
|
-
const connection = config.getOptionalString("connection");
|
|
34
|
-
const connectionScope = config.getOptionalString("connectionScope");
|
|
35
|
-
const callbackURL = config.getOptionalString("callbackUrl") ?? callbackUrl;
|
|
36
|
-
const store = {
|
|
37
|
-
store(_req, cb) {
|
|
38
|
-
cb(null, null);
|
|
39
|
-
},
|
|
40
|
-
verify(_req, _state, cb) {
|
|
41
|
-
cb(null, true);
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
const helper = pluginAuthNode.PassportOAuthAuthenticatorHelper.from(
|
|
45
|
-
new Auth0Strategy(
|
|
46
|
-
{
|
|
47
|
-
clientID,
|
|
48
|
-
clientSecret,
|
|
49
|
-
callbackURL,
|
|
50
|
-
domain,
|
|
51
|
-
store,
|
|
52
|
-
// We need passReqToCallback set to false to get params, but there's
|
|
53
|
-
// no matching type signature for that, so instead behold this beauty
|
|
54
|
-
passReqToCallback: false
|
|
55
|
-
},
|
|
56
|
-
(accessToken, refreshToken, params, fullProfile, done) => {
|
|
57
|
-
done(
|
|
58
|
-
void 0,
|
|
59
|
-
{
|
|
60
|
-
fullProfile,
|
|
61
|
-
accessToken,
|
|
62
|
-
params
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
refreshToken
|
|
66
|
-
}
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
)
|
|
70
|
-
);
|
|
71
|
-
return { helper, audience, connection, connectionScope };
|
|
72
|
-
},
|
|
73
|
-
async start(input, { helper, audience, connection, connectionScope: connection_scope }) {
|
|
74
|
-
return helper.start(input, {
|
|
75
|
-
accessType: "offline",
|
|
76
|
-
prompt: "consent",
|
|
77
|
-
...audience ? { audience } : {},
|
|
78
|
-
...connection ? { connection } : {},
|
|
79
|
-
...connection_scope ? { connection_scope } : {}
|
|
80
|
-
});
|
|
81
|
-
},
|
|
82
|
-
async authenticate(input, { helper, audience, connection, connectionScope: connection_scope }) {
|
|
83
|
-
return helper.authenticate(input, {
|
|
84
|
-
...audience ? { audience } : {},
|
|
85
|
-
...connection ? { connection } : {},
|
|
86
|
-
...connection_scope ? { connection_scope } : {}
|
|
87
|
-
});
|
|
88
|
-
},
|
|
89
|
-
async refresh(input, { helper }) {
|
|
90
|
-
return helper.refresh(input);
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
const authModuleAuth0Provider = backendPluginApi.createBackendModule({
|
|
95
|
-
pluginId: "auth",
|
|
96
|
-
moduleId: "auth0-provider",
|
|
97
|
-
register(reg) {
|
|
98
|
-
reg.registerInit({
|
|
99
|
-
deps: {
|
|
100
|
-
providers: pluginAuthNode.authProvidersExtensionPoint
|
|
101
|
-
},
|
|
102
|
-
async init({ providers }) {
|
|
103
|
-
providers.registerProvider({
|
|
104
|
-
providerId: "auth0",
|
|
105
|
-
factory: pluginAuthNode.createOAuthProviderFactory({
|
|
106
|
-
authenticator: auth0Authenticator,
|
|
107
|
-
signInResolverFactories: {
|
|
108
|
-
...pluginAuthNode.commonSignInResolvers
|
|
109
|
-
}
|
|
110
|
-
})
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
exports.auth0Authenticator = auth0Authenticator;
|
|
118
|
-
exports.default = authModuleAuth0Provider;
|
|
10
|
+
exports.auth0Authenticator = authenticator.auth0Authenticator;
|
|
11
|
+
exports.default = module$1.authModuleAuth0Provider;
|
|
119
12
|
//# sourceMappingURL=index.cjs.js.map
|
package/dist/index.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":["../src/strategy.ts","../src/authenticator.ts","../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 Auth0InternalStrategy from 'passport-auth0';\nimport type { StateStore } from 'passport-oauth2';\n\n/** @public */\nexport interface Auth0StrategyOptionsWithRequest {\n clientID: string;\n clientSecret: string;\n callbackURL: string;\n domain: string;\n passReqToCallback: true;\n store: StateStore;\n}\n\n/** @public */\nexport class Auth0Strategy extends Auth0InternalStrategy {\n constructor(\n options: Auth0StrategyOptionsWithRequest,\n verify: Auth0InternalStrategy.VerifyFunction,\n ) {\n const optionsWithURLs = {\n ...options,\n authorizationURL: `https://${options.domain}/authorize`,\n tokenURL: `https://${options.domain}/oauth/token`,\n userInfoURL: `https://${options.domain}/userinfo`,\n apiUrl: `https://${options.domain}/api`,\n };\n super(optionsWithURLs, verify);\n }\n}\n","/*\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 express from 'express';\nimport {\n createOAuthAuthenticator,\n PassportOAuthAuthenticatorHelper,\n PassportOAuthDoneCallback,\n PassportProfile,\n} from '@backstage/plugin-auth-node';\nimport { Auth0Strategy } from './strategy';\n\n/** @public */\nexport const auth0Authenticator = createOAuthAuthenticator({\n defaultProfileTransform:\n PassportOAuthAuthenticatorHelper.defaultProfileTransform,\n initialize({ callbackUrl, config }) {\n const clientID = config.getString('clientId');\n const clientSecret = config.getString('clientSecret');\n const domain = config.getString('domain');\n const audience = config.getOptionalString('audience');\n const connection = config.getOptionalString('connection');\n const connectionScope = config.getOptionalString('connectionScope');\n const callbackURL = config.getOptionalString('callbackUrl') ?? callbackUrl;\n // Due to passport-auth0 forcing options.state = true,\n // passport-oauth2 requires express-session to be installed\n // so that the 'state' parameter of the oauth2 flow can be stored.\n // This implementation of StateStore matches the NullStore found within\n // passport-oauth2, which is the StateStore implementation used when options.state = false,\n // allowing us to avoid using express-session in order to integrate with auth0.\n const store = {\n store(_req: express.Request, cb: any) {\n cb(null, null);\n },\n verify(_req: express.Request, _state: string, cb: any) {\n cb(null, true);\n },\n };\n\n const helper = PassportOAuthAuthenticatorHelper.from(\n new Auth0Strategy(\n {\n clientID,\n clientSecret,\n callbackURL,\n domain,\n store,\n // We need passReqToCallback set to false to get params, but there's\n // no matching type signature for that, so instead behold this beauty\n passReqToCallback: false as true,\n },\n (\n accessToken: string,\n refreshToken: string,\n params: any,\n fullProfile: PassportProfile,\n done: PassportOAuthDoneCallback,\n ) => {\n done(\n undefined,\n {\n fullProfile,\n accessToken,\n params,\n },\n {\n refreshToken,\n },\n );\n },\n ),\n );\n return { helper, audience, connection, connectionScope };\n },\n\n async start(\n input,\n { helper, audience, connection, connectionScope: connection_scope },\n ) {\n return helper.start(input, {\n accessType: 'offline',\n prompt: 'consent',\n ...(audience ? { audience } : {}),\n ...(connection ? { connection } : {}),\n ...(connection_scope ? { connection_scope } : {}),\n });\n },\n\n async authenticate(\n input,\n { helper, audience, connection, connectionScope: connection_scope },\n ) {\n return helper.authenticate(input, {\n ...(audience ? { audience } : {}),\n ...(connection ? { connection } : {}),\n ...(connection_scope ? { connection_scope } : {}),\n });\n },\n\n async refresh(input, { helper }) {\n return helper.refresh(input);\n },\n});\n","/*\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 createOAuthProviderFactory,\n} from '@backstage/plugin-auth-node';\nimport { auth0Authenticator } from './authenticator';\n\n/** @public */\nexport const authModuleAuth0Provider = createBackendModule({\n pluginId: 'auth',\n moduleId: 'auth0-provider',\n register(reg) {\n reg.registerInit({\n deps: {\n providers: authProvidersExtensionPoint,\n },\n async init({ providers }) {\n providers.registerProvider({\n providerId: 'auth0',\n factory: createOAuthProviderFactory({\n authenticator: auth0Authenticator,\n signInResolverFactories: {\n ...commonSignInResolvers,\n },\n }),\n });\n },\n });\n },\n});\n"],"names":["Auth0InternalStrategy","createOAuthAuthenticator","PassportOAuthAuthenticatorHelper","createBackendModule","authProvidersExtensionPoint","createOAuthProviderFactory","commonSignInResolvers"],"mappings":";;;;;;;;;;;;AA8BO,MAAM,sBAAsBA,sCAAsB,CAAA;AAAA,EACvD,WAAA,CACE,SACA,MACA,EAAA;AACA,IAAA,MAAM,eAAkB,GAAA;AAAA,MACtB,GAAG,OAAA;AAAA,MACH,gBAAA,EAAkB,CAAW,QAAA,EAAA,OAAA,CAAQ,MAAM,CAAA,UAAA,CAAA;AAAA,MAC3C,QAAA,EAAU,CAAW,QAAA,EAAA,OAAA,CAAQ,MAAM,CAAA,YAAA,CAAA;AAAA,MACnC,WAAA,EAAa,CAAW,QAAA,EAAA,OAAA,CAAQ,MAAM,CAAA,SAAA,CAAA;AAAA,MACtC,MAAA,EAAQ,CAAW,QAAA,EAAA,OAAA,CAAQ,MAAM,CAAA,IAAA,CAAA;AAAA,KACnC,CAAA;AACA,IAAA,KAAA,CAAM,iBAAiB,MAAM,CAAA,CAAA;AAAA,GAC/B;AACF;;AClBO,MAAM,qBAAqBC,uCAAyB,CAAA;AAAA,EACzD,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,CAAA;AAC5C,IAAM,MAAA,YAAA,GAAe,MAAO,CAAA,SAAA,CAAU,cAAc,CAAA,CAAA;AACpD,IAAM,MAAA,MAAA,GAAS,MAAO,CAAA,SAAA,CAAU,QAAQ,CAAA,CAAA;AACxC,IAAM,MAAA,QAAA,GAAW,MAAO,CAAA,iBAAA,CAAkB,UAAU,CAAA,CAAA;AACpD,IAAM,MAAA,UAAA,GAAa,MAAO,CAAA,iBAAA,CAAkB,YAAY,CAAA,CAAA;AACxD,IAAM,MAAA,eAAA,GAAkB,MAAO,CAAA,iBAAA,CAAkB,iBAAiB,CAAA,CAAA;AAClE,IAAA,MAA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Content":[],"names":[],"mappings":";;;;;;;;;;"}
|
|
@@ -0,0 +1,31 @@
|
|
|
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
|
+
|
|
7
|
+
const authModuleAuth0Provider = backendPluginApi.createBackendModule({
|
|
8
|
+
pluginId: "auth",
|
|
9
|
+
moduleId: "auth0-provider",
|
|
10
|
+
register(reg) {
|
|
11
|
+
reg.registerInit({
|
|
12
|
+
deps: {
|
|
13
|
+
providers: pluginAuthNode.authProvidersExtensionPoint
|
|
14
|
+
},
|
|
15
|
+
async init({ providers }) {
|
|
16
|
+
providers.registerProvider({
|
|
17
|
+
providerId: "auth0",
|
|
18
|
+
factory: pluginAuthNode.createOAuthProviderFactory({
|
|
19
|
+
authenticator: authenticator.auth0Authenticator,
|
|
20
|
+
signInResolverFactories: {
|
|
21
|
+
...pluginAuthNode.commonSignInResolvers
|
|
22
|
+
}
|
|
23
|
+
})
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
exports.authModuleAuth0Provider = authModuleAuth0Provider;
|
|
31
|
+
//# 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 createOAuthProviderFactory,\n} from '@backstage/plugin-auth-node';\nimport { auth0Authenticator } from './authenticator';\n\n/** @public */\nexport const authModuleAuth0Provider = createBackendModule({\n pluginId: 'auth',\n moduleId: 'auth0-provider',\n register(reg) {\n reg.registerInit({\n deps: {\n providers: authProvidersExtensionPoint,\n },\n async init({ providers }) {\n providers.registerProvider({\n providerId: 'auth0',\n factory: createOAuthProviderFactory({\n authenticator: auth0Authenticator,\n signInResolverFactories: {\n ...commonSignInResolvers,\n },\n }),\n });\n },\n });\n },\n});\n"],"names":["createBackendModule","authProvidersExtensionPoint","createOAuthProviderFactory","auth0Authenticator","commonSignInResolvers"],"mappings":";;;;;;AAyBO,MAAM,0BAA0BA,oCAAoB,CAAA;AAAA,EACzD,QAAU,EAAA,MAAA;AAAA,EACV,QAAU,EAAA,gBAAA;AAAA,EACV,SAAS,GAAK,EAAA;AACZ,IAAA,GAAA,CAAI,YAAa,CAAA;AAAA,MACf,IAAM,EAAA;AAAA,QACJ,SAAW,EAAAC,0CAAA;AAAA,OACb;AAAA,MACA,MAAM,IAAA,CAAK,EAAE,SAAA,EAAa,EAAA;AACxB,QAAA,SAAA,CAAU,gBAAiB,CAAA;AAAA,UACzB,UAAY,EAAA,OAAA;AAAA,UACZ,SAASC,yCAA2B,CAAA;AAAA,YAClC,aAAe,EAAAC,gCAAA;AAAA,YACf,uBAAyB,EAAA;AAAA,cACvB,GAAGC,oCAAA;AAAA,aACL;AAAA,WACD,CAAA;AAAA,SACF,CAAA,CAAA;AAAA,OACH;AAAA,KACD,CAAA,CAAA;AAAA,GACH;AACF,CAAC;;;;"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var Auth0InternalStrategy = require('passport-auth0');
|
|
4
|
+
|
|
5
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
6
|
+
|
|
7
|
+
var Auth0InternalStrategy__default = /*#__PURE__*/_interopDefaultCompat(Auth0InternalStrategy);
|
|
8
|
+
|
|
9
|
+
class Auth0Strategy extends Auth0InternalStrategy__default.default {
|
|
10
|
+
constructor(options, verify) {
|
|
11
|
+
const optionsWithURLs = {
|
|
12
|
+
...options,
|
|
13
|
+
authorizationURL: `https://${options.domain}/authorize`,
|
|
14
|
+
tokenURL: `https://${options.domain}/oauth/token`,
|
|
15
|
+
userInfoURL: `https://${options.domain}/userinfo`,
|
|
16
|
+
apiUrl: `https://${options.domain}/api`
|
|
17
|
+
};
|
|
18
|
+
super(optionsWithURLs, verify);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
exports.Auth0Strategy = Auth0Strategy;
|
|
23
|
+
//# sourceMappingURL=strategy.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strategy.cjs.js","sources":["../src/strategy.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 Auth0InternalStrategy from 'passport-auth0';\nimport type { StateStore } from 'passport-oauth2';\n\n/** @public */\nexport interface Auth0StrategyOptionsWithRequest {\n clientID: string;\n clientSecret: string;\n callbackURL: string;\n domain: string;\n passReqToCallback: true;\n store: StateStore;\n}\n\n/** @public */\nexport class Auth0Strategy extends Auth0InternalStrategy {\n constructor(\n options: Auth0StrategyOptionsWithRequest,\n verify: Auth0InternalStrategy.VerifyFunction,\n ) {\n const optionsWithURLs = {\n ...options,\n authorizationURL: `https://${options.domain}/authorize`,\n tokenURL: `https://${options.domain}/oauth/token`,\n userInfoURL: `https://${options.domain}/userinfo`,\n apiUrl: `https://${options.domain}/api`,\n };\n super(optionsWithURLs, verify);\n }\n}\n"],"names":["Auth0InternalStrategy"],"mappings":";;;;;;;;AA8BO,MAAM,sBAAsBA,sCAAsB,CAAA;AAAA,EACvD,WAAA,CACE,SACA,MACA,EAAA;AACA,IAAA,MAAM,eAAkB,GAAA;AAAA,MACtB,GAAG,OAAA;AAAA,MACH,gBAAA,EAAkB,CAAW,QAAA,EAAA,OAAA,CAAQ,MAAM,CAAA,UAAA,CAAA;AAAA,MAC3C,QAAA,EAAU,CAAW,QAAA,EAAA,OAAA,CAAQ,MAAM,CAAA,YAAA,CAAA;AAAA,MACnC,WAAA,EAAa,CAAW,QAAA,EAAA,OAAA,CAAQ,MAAM,CAAA,SAAA,CAAA;AAAA,MACtC,MAAA,EAAQ,CAAW,QAAA,EAAA,OAAA,CAAQ,MAAM,CAAA,IAAA,CAAA;AAAA,KACnC,CAAA;AACA,IAAA,KAAA,CAAM,iBAAiB,MAAM,CAAA,CAAA;AAAA,GAC/B;AACF;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-auth-backend-module-auth0-provider",
|
|
3
|
-
"version": "0.1.1
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "The auth0-provider backend module for the auth plugin.",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "backend-plugin-module",
|
|
@@ -34,17 +34,17 @@
|
|
|
34
34
|
"test": "backstage-cli package test"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@backstage/backend-plugin-api": "^1.0.1
|
|
38
|
-
"@backstage/plugin-auth-node": "^0.5.3
|
|
37
|
+
"@backstage/backend-plugin-api": "^1.0.1",
|
|
38
|
+
"@backstage/plugin-auth-node": "^0.5.3",
|
|
39
39
|
"express": "^4.17.1",
|
|
40
40
|
"passport-auth0": "^1.4.3",
|
|
41
41
|
"passport-oauth2": "^1.6.1"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@backstage/backend-defaults": "^0.5.1
|
|
45
|
-
"@backstage/backend-test-utils": "^1.0.1
|
|
46
|
-
"@backstage/cli": "^0.28.0
|
|
47
|
-
"@backstage/plugin-auth-backend": "^0.23.1
|
|
44
|
+
"@backstage/backend-defaults": "^0.5.1",
|
|
45
|
+
"@backstage/backend-test-utils": "^1.0.1",
|
|
46
|
+
"@backstage/cli": "^0.28.0",
|
|
47
|
+
"@backstage/plugin-auth-backend": "^0.23.1",
|
|
48
48
|
"@types/passport-auth0": "^1.0.5",
|
|
49
49
|
"@types/passport-oauth2": "^1.4.15",
|
|
50
50
|
"supertest": "^7.0.0"
|