@backstage/plugin-auth-backend-module-bitbucket-server-provider 0.0.0-nightly-20240910023018
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 +165 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +26 -0
- package/package.json +52 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# @backstage/plugin-auth-backend-module-bitbucket-server-provider
|
|
2
|
+
|
|
3
|
+
## 0.0.0-nightly-20240910023018
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 527d973: New module for `@backstage/plugin-auth-backend` that adds a `Bitbucket Server` auth provider.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
- @backstage/backend-plugin-api@0.0.0-nightly-20240910023018
|
|
13
|
+
- @backstage/plugin-auth-node@0.0.0-nightly-20240910023018
|
package/README.md
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# Auth Module: Bitbucket Server Provider
|
|
2
|
+
|
|
3
|
+
This module provides an Bitbucket Server auth provider implementation for `@backstage/plugin-auth-backend`.
|
|
4
|
+
|
|
5
|
+
## Links
|
|
6
|
+
|
|
7
|
+
- [Repository](https://gitlab.com/backstage/backstage/tree/master/plugins/auth-backend-module-bitbucket-server-provider)
|
|
8
|
+
- [Backstage Project Homepage](https://backstage.io)
|
package/config.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2024 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
|
+
bitbucketServer?: {
|
|
22
|
+
[authEnv: string]: {
|
|
23
|
+
clientId: string;
|
|
24
|
+
/**
|
|
25
|
+
* @visibility secret
|
|
26
|
+
*/
|
|
27
|
+
clientSecret: string;
|
|
28
|
+
host: string;
|
|
29
|
+
callbackUrl?: string;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var passportOauth2 = require('passport-oauth2');
|
|
6
|
+
var pluginAuthNode = require('@backstage/plugin-auth-node');
|
|
7
|
+
var fetch = require('node-fetch');
|
|
8
|
+
var backendPluginApi = require('@backstage/backend-plugin-api');
|
|
9
|
+
|
|
10
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
11
|
+
|
|
12
|
+
var fetch__default = /*#__PURE__*/_interopDefaultCompat(fetch);
|
|
13
|
+
|
|
14
|
+
async function fetchProfile(options) {
|
|
15
|
+
const { host, accessToken } = options;
|
|
16
|
+
let whoAmIResponse;
|
|
17
|
+
try {
|
|
18
|
+
whoAmIResponse = await fetch__default.default(
|
|
19
|
+
`https://${host}/plugins/servlet/applinks/whoami`,
|
|
20
|
+
{
|
|
21
|
+
headers: {
|
|
22
|
+
Authorization: `Bearer ${accessToken}`
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
} catch (e) {
|
|
27
|
+
throw new Error(`Failed to retrieve the username of the logged in user`);
|
|
28
|
+
}
|
|
29
|
+
const username = whoAmIResponse.headers.get("X-Ausername");
|
|
30
|
+
if (!username) {
|
|
31
|
+
throw new Error(`Failed to retrieve the username of the logged in user`);
|
|
32
|
+
}
|
|
33
|
+
let userResponse;
|
|
34
|
+
try {
|
|
35
|
+
userResponse = await fetch__default.default(
|
|
36
|
+
`https://${host}/rest/api/latest/users/${username}?avatarSize=256`,
|
|
37
|
+
{
|
|
38
|
+
headers: {
|
|
39
|
+
Authorization: `Bearer ${accessToken}`
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
);
|
|
43
|
+
} catch (e) {
|
|
44
|
+
throw new Error(`Failed to retrieve the user '${username}'`);
|
|
45
|
+
}
|
|
46
|
+
if (!userResponse.ok) {
|
|
47
|
+
throw new Error(`Failed to retrieve the user '${username}'`);
|
|
48
|
+
}
|
|
49
|
+
const user = await userResponse.json();
|
|
50
|
+
const passportProfile = {
|
|
51
|
+
provider: "bitbucketServer",
|
|
52
|
+
id: user.id.toString(),
|
|
53
|
+
displayName: user.displayName,
|
|
54
|
+
username: user.name,
|
|
55
|
+
emails: [
|
|
56
|
+
{
|
|
57
|
+
value: user.emailAddress
|
|
58
|
+
}
|
|
59
|
+
]
|
|
60
|
+
};
|
|
61
|
+
if (user.avatarUrl) {
|
|
62
|
+
passportProfile.photos = [{ value: `https://${host}${user.avatarUrl}` }];
|
|
63
|
+
}
|
|
64
|
+
return passportProfile;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const bitbucketServerAuthenticator = pluginAuthNode.createOAuthAuthenticator({
|
|
68
|
+
defaultProfileTransform: pluginAuthNode.PassportOAuthAuthenticatorHelper.defaultProfileTransform,
|
|
69
|
+
initialize({ callbackUrl, config }) {
|
|
70
|
+
const clientID = config.getString("clientId");
|
|
71
|
+
const clientSecret = config.getString("clientSecret");
|
|
72
|
+
const host = config.getString("host");
|
|
73
|
+
const callbackURL = config.getOptionalString("callbackUrl") ?? callbackUrl;
|
|
74
|
+
const helper = pluginAuthNode.PassportOAuthAuthenticatorHelper.from(
|
|
75
|
+
new passportOauth2.Strategy(
|
|
76
|
+
{
|
|
77
|
+
clientID,
|
|
78
|
+
clientSecret,
|
|
79
|
+
callbackURL,
|
|
80
|
+
authorizationURL: `https://${host}/rest/oauth2/latest/authorize`,
|
|
81
|
+
tokenURL: `https://${host}/rest/oauth2/latest/token`
|
|
82
|
+
},
|
|
83
|
+
(accessToken, refreshToken, params, fullProfile, done) => {
|
|
84
|
+
done(
|
|
85
|
+
void 0,
|
|
86
|
+
{ fullProfile, params, accessToken },
|
|
87
|
+
{ refreshToken }
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
)
|
|
91
|
+
);
|
|
92
|
+
return { helper, host };
|
|
93
|
+
},
|
|
94
|
+
async start(input, { helper }) {
|
|
95
|
+
return helper.start(input, {
|
|
96
|
+
accessType: "offline",
|
|
97
|
+
prompt: "consent"
|
|
98
|
+
});
|
|
99
|
+
},
|
|
100
|
+
async authenticate(input, { helper, host }) {
|
|
101
|
+
const result = await helper.authenticate(input);
|
|
102
|
+
const fullProfile = await fetchProfile({
|
|
103
|
+
host,
|
|
104
|
+
accessToken: result.session.accessToken
|
|
105
|
+
});
|
|
106
|
+
return { ...result, fullProfile };
|
|
107
|
+
},
|
|
108
|
+
async refresh(input, { helper, host }) {
|
|
109
|
+
const result = await helper.refresh(input);
|
|
110
|
+
const fullProfile = await fetchProfile({
|
|
111
|
+
host,
|
|
112
|
+
accessToken: result.session.accessToken
|
|
113
|
+
});
|
|
114
|
+
return { ...result, fullProfile };
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
exports.bitbucketServerSignInResolvers = void 0;
|
|
119
|
+
((bitbucketServerSignInResolvers2) => {
|
|
120
|
+
bitbucketServerSignInResolvers2.emailMatchingUserEntityProfileEmail = pluginAuthNode.createSignInResolverFactory({
|
|
121
|
+
create() {
|
|
122
|
+
return async (info, ctx) => {
|
|
123
|
+
const { profile } = info;
|
|
124
|
+
if (!profile.email) {
|
|
125
|
+
throw new Error(
|
|
126
|
+
"Login failed, user profile does not contain an email"
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
return ctx.signInWithCatalogUser({
|
|
130
|
+
filter: {
|
|
131
|
+
"spec.profile.email": profile.email
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
})(exports.bitbucketServerSignInResolvers || (exports.bitbucketServerSignInResolvers = {}));
|
|
138
|
+
|
|
139
|
+
const authModuleBitbucketServerProvider = backendPluginApi.createBackendModule({
|
|
140
|
+
pluginId: "auth",
|
|
141
|
+
moduleId: "bitbucket-server-provider",
|
|
142
|
+
register(reg) {
|
|
143
|
+
reg.registerInit({
|
|
144
|
+
deps: {
|
|
145
|
+
providers: pluginAuthNode.authProvidersExtensionPoint
|
|
146
|
+
},
|
|
147
|
+
async init({ providers }) {
|
|
148
|
+
providers.registerProvider({
|
|
149
|
+
providerId: "bitbucketServer",
|
|
150
|
+
factory: pluginAuthNode.createOAuthProviderFactory({
|
|
151
|
+
authenticator: bitbucketServerAuthenticator,
|
|
152
|
+
signInResolverFactories: {
|
|
153
|
+
...exports.bitbucketServerSignInResolvers,
|
|
154
|
+
...pluginAuthNode.commonSignInResolvers
|
|
155
|
+
}
|
|
156
|
+
})
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
exports.bitbucketServerAuthenticator = bitbucketServerAuthenticator;
|
|
164
|
+
exports.default = authModuleBitbucketServerProvider;
|
|
165
|
+
//# sourceMappingURL=index.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../src/helpers.ts","../src/authenticator.ts","../src/resolvers.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 fetch from 'node-fetch';\nimport { PassportProfile } from '@backstage/plugin-auth-node';\n\nexport async function fetchProfile(options: {\n host: string;\n accessToken: string;\n}): Promise<PassportProfile> {\n const { host, accessToken } = options;\n // Get current user name\n let whoAmIResponse;\n try {\n whoAmIResponse = await fetch(\n `https://${host}/plugins/servlet/applinks/whoami`,\n {\n headers: {\n Authorization: `Bearer ${accessToken}`,\n },\n },\n );\n } catch (e) {\n throw new Error(`Failed to retrieve the username of the logged in user`);\n }\n\n // A response.ok check here would be worthless as the Bitbucket API always returns 200 OK for this call\n const username = whoAmIResponse.headers.get('X-Ausername');\n if (!username) {\n throw new Error(`Failed to retrieve the username of the logged in user`);\n }\n\n let userResponse;\n try {\n userResponse = await fetch(\n `https://${host}/rest/api/latest/users/${username}?avatarSize=256`,\n {\n headers: {\n Authorization: `Bearer ${accessToken}`,\n },\n },\n );\n } catch (e) {\n throw new Error(`Failed to retrieve the user '${username}'`);\n }\n\n if (!userResponse.ok) {\n throw new Error(`Failed to retrieve the user '${username}'`);\n }\n\n const user = await userResponse.json();\n\n const passportProfile = {\n provider: 'bitbucketServer',\n id: user.id.toString(),\n displayName: user.displayName,\n username: user.name,\n emails: [\n {\n value: user.emailAddress,\n },\n ],\n } as PassportProfile;\n\n if (user.avatarUrl) {\n passportProfile.photos = [{ value: `https://${host}${user.avatarUrl}` }];\n }\n\n return passportProfile;\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 { Strategy as OAuth2Strategy, VerifyCallback } from 'passport-oauth2';\nimport {\n createOAuthAuthenticator,\n PassportOAuthAuthenticatorHelper,\n PassportProfile,\n} from '@backstage/plugin-auth-node';\nimport { fetchProfile } from './helpers';\n\n/** @public */\nexport const bitbucketServerAuthenticator = createOAuthAuthenticator({\n defaultProfileTransform:\n PassportOAuthAuthenticatorHelper.defaultProfileTransform,\n initialize({ callbackUrl, config }) {\n const clientID = config.getString('clientId');\n const clientSecret = config.getString('clientSecret');\n const host = config.getString('host');\n const callbackURL = config.getOptionalString('callbackUrl') ?? callbackUrl;\n\n const helper = PassportOAuthAuthenticatorHelper.from(\n new OAuth2Strategy(\n {\n clientID,\n clientSecret,\n callbackURL,\n authorizationURL: `https://${host}/rest/oauth2/latest/authorize`,\n tokenURL: `https://${host}/rest/oauth2/latest/token`,\n },\n (\n accessToken: string,\n refreshToken: string,\n params: any,\n fullProfile: PassportProfile,\n done: VerifyCallback,\n ) => {\n done(\n undefined,\n { fullProfile, params, accessToken },\n { refreshToken },\n );\n },\n ),\n );\n\n return { helper, host };\n },\n\n async start(input, { helper }) {\n return helper.start(input, {\n accessType: 'offline',\n prompt: 'consent',\n });\n },\n\n async authenticate(input, { helper, host }) {\n const result = await helper.authenticate(input);\n\n // The OAuth2 strategy does not return a user profile, so we fetch it manually\n const fullProfile = await fetchProfile({\n host,\n accessToken: result.session.accessToken,\n });\n\n return { ...result, fullProfile };\n },\n\n async refresh(input, { helper, host }) {\n const result = await helper.refresh(input);\n\n // The OAuth2 strategy does not return a user profile, so we fetch it manually\n const fullProfile = await fetchProfile({\n host,\n accessToken: result.session.accessToken,\n });\n\n return { ...result, fullProfile };\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 */\nimport {\n createSignInResolverFactory,\n OAuthAuthenticatorResult,\n PassportProfile,\n SignInInfo,\n} from '@backstage/plugin-auth-node';\n\n/**\n * Available sign-in resolvers for the Bitbucket Server auth provider.\n *\n * @public\n */\nexport namespace bitbucketServerSignInResolvers {\n /**\n * Looks up the user by matching their email to the entity email.\n */\n export const emailMatchingUserEntityProfileEmail =\n 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(\n 'Login failed, user profile does not contain an email',\n );\n }\n\n return ctx.signInWithCatalogUser({\n filter: {\n 'spec.profile.email': profile.email,\n },\n });\n };\n },\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 */\nimport { createBackendModule } from '@backstage/backend-plugin-api';\nimport {\n authProvidersExtensionPoint,\n commonSignInResolvers,\n createOAuthProviderFactory,\n} from '@backstage/plugin-auth-node';\nimport { bitbucketServerAuthenticator } from './authenticator';\nimport { bitbucketServerSignInResolvers } from './resolvers';\n\n/** @public */\nexport const authModuleBitbucketServerProvider = createBackendModule({\n pluginId: 'auth',\n moduleId: 'bitbucket-server-provider',\n register(reg) {\n reg.registerInit({\n deps: {\n providers: authProvidersExtensionPoint,\n },\n async init({ providers }) {\n providers.registerProvider({\n providerId: 'bitbucketServer',\n factory: createOAuthProviderFactory({\n authenticator: bitbucketServerAuthenticator,\n signInResolverFactories: {\n ...bitbucketServerSignInResolvers,\n ...commonSignInResolvers,\n },\n }),\n });\n },\n });\n },\n});\n"],"names":["fetch","createOAuthAuthenticator","PassportOAuthAuthenticatorHelper","OAuth2Strategy","bitbucketServerSignInResolvers","createSignInResolverFactory","createBackendModule","authProvidersExtensionPoint","createOAuthProviderFactory","commonSignInResolvers"],"mappings":";;;;;;;;;;;;;AAmBA,eAAsB,aAAa,OAGN,EAAA;AAC3B,EAAM,MAAA,EAAE,IAAM,EAAA,WAAA,EAAgB,GAAA,OAAA,CAAA;AAE9B,EAAI,IAAA,cAAA,CAAA;AACJ,EAAI,IAAA;AACF,IAAA,cAAA,GAAiB,MAAMA,sBAAA;AAAA,MACrB,WAAW,IAAI,CAAA,gCAAA,CAAA;AAAA,MACf;AAAA,QACE,OAAS,EAAA;AAAA,UACP,aAAA,EAAe,UAAU,WAAW,CAAA,CAAA;AAAA,SACtC;AAAA,OACF;AAAA,KACF,CAAA;AAAA,WACO,CAAG,EAAA;AACV,IAAM,MAAA,IAAI,MAAM,CAAuD,qDAAA,CAAA,CAAA,CAAA;AAAA,GACzE;AAGA,EAAA,MAAM,QAAW,GAAA,cAAA,CAAe,OAAQ,CAAA,GAAA,CAAI,aAAa,CAAA,CAAA;AACzD,EAAA,IAAI,CAAC,QAAU,EAAA;AACb,IAAM,MAAA,IAAI,MAAM,CAAuD,qDAAA,CAAA,CAAA,CAAA;AAAA,GACzE;AAEA,EAAI,IAAA,YAAA,CAAA;AACJ,EAAI,IAAA;AACF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AA,EACnE,QAAU,EAAA,MAAA;AAAA,EACV,QAAU,EAAA,2BAAA;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,iBAAA;AAAA,UACZ,SAASC,yCAA2B,CAAA;AAAA,YAClC,aAAe,EAAA,4BAAA;AAAA,YACf,uBAAyB,EAAA;AAAA,cACvB,GAAGJ,sCAAA;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,26 @@
|
|
|
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 bitbucketServerAuthenticator: _backstage_plugin_auth_node.OAuthAuthenticator<{
|
|
7
|
+
helper: PassportOAuthAuthenticatorHelper;
|
|
8
|
+
host: string;
|
|
9
|
+
}, PassportProfile>;
|
|
10
|
+
|
|
11
|
+
/** @public */
|
|
12
|
+
declare const authModuleBitbucketServerProvider: _backstage_backend_plugin_api.BackendFeature;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Available sign-in resolvers for the Bitbucket Server auth provider.
|
|
16
|
+
*
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
declare namespace bitbucketServerSignInResolvers {
|
|
20
|
+
/**
|
|
21
|
+
* Looks up the user by matching their email to the entity email.
|
|
22
|
+
*/
|
|
23
|
+
const emailMatchingUserEntityProfileEmail: _backstage_plugin_auth_node.SignInResolverFactory<OAuthAuthenticatorResult<PassportProfile>, unknown>;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { bitbucketServerAuthenticator, bitbucketServerSignInResolvers, authModuleBitbucketServerProvider as default };
|
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@backstage/plugin-auth-backend-module-bitbucket-server-provider",
|
|
3
|
+
"version": "0.0.0-nightly-20240910023018",
|
|
4
|
+
"description": "The bitbucket-server-provider backend module for the auth plugin.",
|
|
5
|
+
"backstage": {
|
|
6
|
+
"role": "backend-plugin-module",
|
|
7
|
+
"pluginId": "auth",
|
|
8
|
+
"pluginPackage": "@backstage/plugin-auth-backend"
|
|
9
|
+
},
|
|
10
|
+
"publishConfig": {
|
|
11
|
+
"access": "public",
|
|
12
|
+
"main": "dist/index.cjs.js",
|
|
13
|
+
"types": "dist/index.d.ts"
|
|
14
|
+
},
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "https://github.com/backstage/backstage",
|
|
18
|
+
"directory": "plugins/auth-backend-module-bitbucket-server-provider"
|
|
19
|
+
},
|
|
20
|
+
"license": "Apache-2.0",
|
|
21
|
+
"main": "dist/index.cjs.js",
|
|
22
|
+
"types": "dist/index.d.ts",
|
|
23
|
+
"files": [
|
|
24
|
+
"dist",
|
|
25
|
+
"config.d.ts"
|
|
26
|
+
],
|
|
27
|
+
"scripts": {
|
|
28
|
+
"build": "backstage-cli package build",
|
|
29
|
+
"clean": "backstage-cli package clean",
|
|
30
|
+
"lint": "backstage-cli package lint",
|
|
31
|
+
"prepack": "backstage-cli package prepack",
|
|
32
|
+
"postpack": "backstage-cli package postpack",
|
|
33
|
+
"start": "backstage-cli package start",
|
|
34
|
+
"test": "backstage-cli package test"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@backstage/backend-plugin-api": "^0.0.0-nightly-20240910023018",
|
|
38
|
+
"@backstage/plugin-auth-node": "^0.0.0-nightly-20240910023018",
|
|
39
|
+
"node-fetch": "^2.7.0",
|
|
40
|
+
"passport": "^0.7.0",
|
|
41
|
+
"passport-oauth2": "^1.6.1"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@backstage/backend-defaults": "^0.0.0-nightly-20240910023018",
|
|
45
|
+
"@backstage/backend-test-utils": "^0.0.0-nightly-20240910023018",
|
|
46
|
+
"@backstage/cli": "^0.0.0-nightly-20240910023018",
|
|
47
|
+
"@backstage/plugin-auth-backend": "^0.0.0-nightly-20240910023018",
|
|
48
|
+
"@types/passport-oauth2": "^1.4.15",
|
|
49
|
+
"supertest": "^6.3.3"
|
|
50
|
+
},
|
|
51
|
+
"configSchema": "config.d.ts"
|
|
52
|
+
}
|