@backstage/plugin-auth-backend-module-onelogin-provider 0.0.0-nightly-20240611021715
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 +13 -0
- package/README.md +8 -0
- package/config.d.ts +34 -0
- package/dist/index.cjs.js +92 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +23 -0
- package/package.json +49 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# @backstage/plugin-auth-backend-module-onelogin-provider
|
|
2
|
+
|
|
3
|
+
## 0.0.0-nightly-20240611021715
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 566d7cb: Separate out the OneLogin provider into its own module
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
- @backstage/backend-plugin-api@0.0.0-nightly-20240611021715
|
|
13
|
+
- @backstage/plugin-auth-node@0.0.0-nightly-20240611021715
|
package/README.md
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# Auth Module: OneLogin Provider
|
|
2
|
+
|
|
3
|
+
This module provides an OneLogin auth provider implementation for `@backstage/plugin-auth-backend`.
|
|
4
|
+
|
|
5
|
+
## Links
|
|
6
|
+
|
|
7
|
+
- [Repository](https://github.com/backstage/backstage/tree/master/plugins/auth-backend-module-onelogin-provider)
|
|
8
|
+
- [Backstage Project Homepage](https://backstage.io)
|
package/config.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2020 The Backstage Authors
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
export interface Config {
|
|
18
|
+
auth?: {
|
|
19
|
+
providers?: {
|
|
20
|
+
/** @visibility frontend */
|
|
21
|
+
onelogin?: {
|
|
22
|
+
[authEnv: string]: {
|
|
23
|
+
clientId: string;
|
|
24
|
+
/**
|
|
25
|
+
* @visibility secret
|
|
26
|
+
*/
|
|
27
|
+
clientSecret: string;
|
|
28
|
+
issuer: string;
|
|
29
|
+
callbackUrl?: string;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var passportOneloginOauth = require('passport-onelogin-oauth');
|
|
6
|
+
var pluginAuthNode = require('@backstage/plugin-auth-node');
|
|
7
|
+
var backendPluginApi = require('@backstage/backend-plugin-api');
|
|
8
|
+
|
|
9
|
+
const oneLoginAuthenticator = pluginAuthNode.createOAuthAuthenticator({
|
|
10
|
+
defaultProfileTransform: pluginAuthNode.PassportOAuthAuthenticatorHelper.defaultProfileTransform,
|
|
11
|
+
initialize({ callbackUrl, config }) {
|
|
12
|
+
const clientId = config.getString("clientId");
|
|
13
|
+
const clientSecret = config.getString("clientSecret");
|
|
14
|
+
const issuer = config.getString("issuer");
|
|
15
|
+
return pluginAuthNode.PassportOAuthAuthenticatorHelper.from(
|
|
16
|
+
new passportOneloginOauth.Strategy(
|
|
17
|
+
{
|
|
18
|
+
clientID: clientId,
|
|
19
|
+
clientSecret,
|
|
20
|
+
callbackURL: callbackUrl,
|
|
21
|
+
issuer,
|
|
22
|
+
passReqToCallback: false
|
|
23
|
+
},
|
|
24
|
+
(accessToken, refreshToken, params, fullProfile, done) => {
|
|
25
|
+
done(
|
|
26
|
+
void 0,
|
|
27
|
+
{ fullProfile, params, accessToken },
|
|
28
|
+
{ refreshToken }
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
)
|
|
32
|
+
);
|
|
33
|
+
},
|
|
34
|
+
async start(input, helper) {
|
|
35
|
+
input.scope = "openid";
|
|
36
|
+
return helper.start(input, {
|
|
37
|
+
accessType: "offline",
|
|
38
|
+
prompt: "consent"
|
|
39
|
+
});
|
|
40
|
+
},
|
|
41
|
+
async authenticate(input, helper) {
|
|
42
|
+
return helper.authenticate(input);
|
|
43
|
+
},
|
|
44
|
+
async refresh(input, helper) {
|
|
45
|
+
input.scope = "openid";
|
|
46
|
+
return helper.refresh(input);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
exports.oneLoginSignInResolvers = void 0;
|
|
51
|
+
((oneLoginSignInResolvers2) => {
|
|
52
|
+
oneLoginSignInResolvers2.usernameMatchingUserEntityName = pluginAuthNode.createSignInResolverFactory({
|
|
53
|
+
create() {
|
|
54
|
+
return async (info, ctx) => {
|
|
55
|
+
const { result } = info;
|
|
56
|
+
const id = result.fullProfile.username;
|
|
57
|
+
if (!id) {
|
|
58
|
+
throw new Error(`OneLogin user profile does not contain a username`);
|
|
59
|
+
}
|
|
60
|
+
return ctx.signInWithCatalogUser({ entityRef: { name: id } });
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
})(exports.oneLoginSignInResolvers || (exports.oneLoginSignInResolvers = {}));
|
|
65
|
+
|
|
66
|
+
const authModuleOneLoginProvider = backendPluginApi.createBackendModule({
|
|
67
|
+
pluginId: "auth",
|
|
68
|
+
moduleId: "onelogin-provider",
|
|
69
|
+
register(reg) {
|
|
70
|
+
reg.registerInit({
|
|
71
|
+
deps: {
|
|
72
|
+
providers: pluginAuthNode.authProvidersExtensionPoint
|
|
73
|
+
},
|
|
74
|
+
async init({ providers }) {
|
|
75
|
+
providers.registerProvider({
|
|
76
|
+
providerId: "onelogin",
|
|
77
|
+
factory: pluginAuthNode.createOAuthProviderFactory({
|
|
78
|
+
authenticator: oneLoginAuthenticator,
|
|
79
|
+
signInResolverFactories: {
|
|
80
|
+
...exports.oneLoginSignInResolvers,
|
|
81
|
+
...pluginAuthNode.commonSignInResolvers
|
|
82
|
+
}
|
|
83
|
+
})
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
exports.default = authModuleOneLoginProvider;
|
|
91
|
+
exports.oneLoginAuthenticator = oneLoginAuthenticator;
|
|
92
|
+
//# sourceMappingURL=index.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../src/authenticator.ts","../src/resolvers.ts","../src/module.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 { Strategy as OneLoginStrategy } from 'passport-onelogin-oauth';\nimport {\n createOAuthAuthenticator,\n PassportOAuthAuthenticatorHelper,\n PassportOAuthDoneCallback,\n PassportProfile,\n} from '@backstage/plugin-auth-node';\n\n/** @public */\nexport const oneLoginAuthenticator = createOAuthAuthenticator({\n defaultProfileTransform:\n PassportOAuthAuthenticatorHelper.defaultProfileTransform,\n initialize({ callbackUrl, config }) {\n const clientId = config.getString('clientId');\n const clientSecret = config.getString('clientSecret');\n const issuer = config.getString('issuer');\n\n return PassportOAuthAuthenticatorHelper.from(\n new OneLoginStrategy(\n {\n clientID: clientId,\n clientSecret: clientSecret,\n callbackURL: callbackUrl,\n issuer,\n passReqToCallback: false,\n },\n (\n accessToken: string,\n refreshToken: string,\n params: any,\n fullProfile: PassportProfile,\n done: PassportOAuthDoneCallback,\n ) => {\n done(\n undefined,\n { fullProfile, params, accessToken },\n { refreshToken },\n );\n },\n ),\n );\n },\n\n async start(input, helper) {\n input.scope = 'openid';\n return helper.start(input, {\n accessType: 'offline',\n prompt: 'consent',\n });\n },\n\n async authenticate(input, helper) {\n return helper.authenticate(input);\n },\n\n async refresh(input, helper) {\n input.scope = 'openid';\n return helper.refresh(input);\n },\n});\n","/*\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 createSignInResolverFactory,\n OAuthAuthenticatorResult,\n PassportProfile,\n SignInInfo,\n} from '@backstage/plugin-auth-node';\n\n/**\n * Available sign-in resolvers for the OneLogin auth provider.\n *\n * @public\n */\nexport namespace oneLoginSignInResolvers {\n /**\n * Looks up the user by matching their OneLogin username to the entity name.\n */\n export const usernameMatchingUserEntityName = createSignInResolverFactory({\n create() {\n return async (\n info: SignInInfo<OAuthAuthenticatorResult<PassportProfile>>,\n ctx,\n ) => {\n const { result } = info;\n\n const id = result.fullProfile.username;\n if (!id) {\n throw new Error(`OneLogin user profile does not contain a username`);\n }\n\n return ctx.signInWithCatalogUser({ entityRef: { name: id } });\n };\n },\n });\n}\n","/*\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 */\nimport { createBackendModule } from '@backstage/backend-plugin-api';\nimport {\n authProvidersExtensionPoint,\n commonSignInResolvers,\n createOAuthProviderFactory,\n} from '@backstage/plugin-auth-node';\nimport { oneLoginAuthenticator } from './authenticator';\nimport { oneLoginSignInResolvers } from './resolvers';\n\n/** @public */\nexport const authModuleOneLoginProvider = createBackendModule({\n pluginId: 'auth',\n moduleId: 'onelogin-provider',\n register(reg) {\n reg.registerInit({\n deps: {\n providers: authProvidersExtensionPoint,\n },\n async init({ providers }) {\n providers.registerProvider({\n providerId: 'onelogin',\n factory: createOAuthProviderFactory({\n authenticator: oneLoginAuthenticator,\n signInResolverFactories: {\n ...oneLoginSignInResolvers,\n ...commonSignInResolvers,\n },\n }),\n });\n },\n });\n },\n});\n"],"names":["createOAuthAuthenticator","PassportOAuthAuthenticatorHelper","OneLoginStrategy","oneLoginSignInResolvers","createSignInResolverFactory","createBackendModule","authProvidersExtensionPoint","createOAuthProviderFactory","commonSignInResolvers"],"mappings":";;;;;;;;AAyBO,MAAM,wBAAwBA,uCAAyB,CAAA;AAAA,EAC5D,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;AAExC,IAAA,OAAOA,+CAAiC,CAAA,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O,WAAY,CAAA,QAAA,CAAA;AAC9B,QAAA,IAAI,CAAC,EAAI,EAAA;AACP,UAAM,MAAA,IAAI,MAAM,CAAmD,iDAAA,CAAA,CAAA,CAAA;AAAA,SACrE;AAEA,QAAO,OAAA,GAAA,CAAI,sBAAsB,EAAE,SAAA,EAAW,EAAE,IAAM,EAAA,EAAA,IAAM,CAAA,CAAA;AAAA,OAC9D,CAAA;AAAA,KACF;AAAA,GACD,CAAA,CAAA;AAAA,CApBc,EAAAD,+BAAA,KAAAA,+BAAA,GAAA,EAAA,CAAA,CAAA;;ACHV,MAAM,6BAA6BE,oCAAoB,CAAA;AAAA,EAC5D,QAAU,EAAA,MAAA;AAAA,EACV,QAAU,EAAA,mBAAA;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,UAAA;AAAA,UACZ,SAASC,yCAA2B,CAAA;AAAA,YAClC,aAAe,EAAA,qBAAA;AAAA,YACf,uBAAyB,EAAA;AAAA,cACvB,GAAGJ,+BAAA;AAAA,cACH,GAAGK,oCAAA;AAAA,aACL;AAAA,WACD,CAAA;AAAA,SACF,CAAA,CAAA;AAAA,OACH;AAAA,KACD,CAAA,CAAA;AAAA,GACH;AACF,CAAC;;;;;"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as _backstage_plugin_auth_node from '@backstage/plugin-auth-node';
|
|
2
|
+
import { PassportOAuthAuthenticatorHelper, PassportProfile, OAuthAuthenticatorResult } from '@backstage/plugin-auth-node';
|
|
3
|
+
import * as _backstage_backend_plugin_api from '@backstage/backend-plugin-api';
|
|
4
|
+
|
|
5
|
+
/** @public */
|
|
6
|
+
declare const oneLoginAuthenticator: _backstage_plugin_auth_node.OAuthAuthenticator<PassportOAuthAuthenticatorHelper, PassportProfile>;
|
|
7
|
+
|
|
8
|
+
/** @public */
|
|
9
|
+
declare const authModuleOneLoginProvider: () => _backstage_backend_plugin_api.BackendFeature;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Available sign-in resolvers for the OneLogin auth provider.
|
|
13
|
+
*
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
declare namespace oneLoginSignInResolvers {
|
|
17
|
+
/**
|
|
18
|
+
* Looks up the user by matching their OneLogin username to the entity name.
|
|
19
|
+
*/
|
|
20
|
+
const usernameMatchingUserEntityName: _backstage_plugin_auth_node.SignInResolverFactory<OAuthAuthenticatorResult<PassportProfile>, unknown>;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export { authModuleOneLoginProvider as default, oneLoginAuthenticator, oneLoginSignInResolvers };
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@backstage/plugin-auth-backend-module-onelogin-provider",
|
|
3
|
+
"version": "0.0.0-nightly-20240611021715",
|
|
4
|
+
"description": "The onelogin-provider backend module for the auth plugin.",
|
|
5
|
+
"backstage": {
|
|
6
|
+
"role": "backend-plugin-module"
|
|
7
|
+
},
|
|
8
|
+
"publishConfig": {
|
|
9
|
+
"access": "public",
|
|
10
|
+
"main": "dist/index.cjs.js",
|
|
11
|
+
"types": "dist/index.d.ts"
|
|
12
|
+
},
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "https://github.com/backstage/backstage",
|
|
16
|
+
"directory": "plugins/auth-backend-module-onelogin-provider"
|
|
17
|
+
},
|
|
18
|
+
"license": "Apache-2.0",
|
|
19
|
+
"main": "dist/index.cjs.js",
|
|
20
|
+
"types": "dist/index.d.ts",
|
|
21
|
+
"files": [
|
|
22
|
+
"dist",
|
|
23
|
+
"config.d.ts"
|
|
24
|
+
],
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "backstage-cli package build",
|
|
27
|
+
"clean": "backstage-cli package clean",
|
|
28
|
+
"lint": "backstage-cli package lint",
|
|
29
|
+
"prepack": "backstage-cli package prepack",
|
|
30
|
+
"postpack": "backstage-cli package postpack",
|
|
31
|
+
"start": "backstage-cli package start",
|
|
32
|
+
"test": "backstage-cli package test"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@backstage/backend-plugin-api": "^0.0.0-nightly-20240611021715",
|
|
36
|
+
"@backstage/plugin-auth-node": "^0.0.0-nightly-20240611021715",
|
|
37
|
+
"express": "^4.18.2",
|
|
38
|
+
"passport": "^0.7.0",
|
|
39
|
+
"passport-onelogin-oauth": "^0.0.1"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@backstage/backend-defaults": "^0.0.0-nightly-20240611021715",
|
|
43
|
+
"@backstage/backend-test-utils": "^0.0.0-nightly-20240611021715",
|
|
44
|
+
"@backstage/cli": "^0.0.0-nightly-20240611021715",
|
|
45
|
+
"@backstage/plugin-auth-backend": "^0.0.0-nightly-20240611021715",
|
|
46
|
+
"supertest": "^6.3.3"
|
|
47
|
+
},
|
|
48
|
+
"configSchema": "config.d.ts"
|
|
49
|
+
}
|