removes default signin resolver, updates tests
Signed-off-by: Daniel Deloff <44780793+rv-ddeloff@users.noreply.github.com>
This commit is contained in:
@@ -14,10 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {
|
||||
AtlassianAuthProvider,
|
||||
atlassianDefaultSignInResolver,
|
||||
} from './provider';
|
||||
import { AtlassianAuthProvider } from './provider';
|
||||
import * as helpers from '../../lib/passport/PassportStrategyHelper';
|
||||
import { getVoidLogger } from '@backstage/backend-common';
|
||||
import { TokenIssuer } from '../../identity';
|
||||
@@ -55,7 +52,6 @@ describe('createAtlassianProvider', () => {
|
||||
clientSecret: 'mock',
|
||||
callbackUrl: 'mock',
|
||||
scopes: 'scope',
|
||||
signInResolver: atlassianDefaultSignInResolver,
|
||||
});
|
||||
|
||||
it('should auth', async () => {
|
||||
@@ -84,9 +80,6 @@ describe('createAtlassianProvider', () => {
|
||||
});
|
||||
const { response } = await provider.handler({} as any);
|
||||
expect(response).toEqual({
|
||||
backstageIdentity: {
|
||||
id: 'conrad',
|
||||
},
|
||||
providerInfo: {
|
||||
accessToken: 'accessToken',
|
||||
expiresInSeconds: 123,
|
||||
@@ -137,9 +130,6 @@ describe('createAtlassianProvider', () => {
|
||||
const response = await provider.refresh({} as any);
|
||||
|
||||
expect(response).toEqual({
|
||||
backstageIdentity: {
|
||||
id: 'mockuser',
|
||||
},
|
||||
profile: {
|
||||
displayName: 'Mocked User',
|
||||
email: 'mockuser@gmail.com',
|
||||
|
||||
@@ -55,23 +55,6 @@ export type AtlassianAuthProviderOptions = OAuthProviderOptions & {
|
||||
logger: Logger;
|
||||
};
|
||||
|
||||
export const atlassianDefaultSignInResolver: SignInResolver<OAuthResult> =
|
||||
async (info, ctx) => {
|
||||
const { profile, result } = info;
|
||||
|
||||
let id = result.fullProfile.id;
|
||||
|
||||
if (profile.email) {
|
||||
id = profile.email.split('@')[0];
|
||||
}
|
||||
|
||||
const token = await ctx.tokenIssuer.issueToken({
|
||||
claims: { sub: id, ent: [`user:default/${id}`] },
|
||||
});
|
||||
|
||||
return { id, token };
|
||||
};
|
||||
|
||||
export const atlassianDefaultAuthHandler: AuthHandler<OAuthResult> = async ({
|
||||
fullProfile,
|
||||
params,
|
||||
|
||||
Reference in New Issue
Block a user