Renamed the RedirectInfo type to OAuthStartResponse
Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-auth-backend': minor
|
||||
---
|
||||
|
||||
Renamed the `RedirectInfo` type to `OAuthStartResponse`
|
||||
@@ -317,7 +317,7 @@ export interface OAuthHandlers {
|
||||
response: OAuthResponse;
|
||||
refreshToken?: string;
|
||||
}>;
|
||||
start(req: OAuthStartRequest): Promise<RedirectInfo>;
|
||||
start(req: OAuthStartRequest): Promise<OAuthStartResponse>;
|
||||
}
|
||||
|
||||
// @public (undocumented)
|
||||
@@ -366,6 +366,12 @@ export type OAuthStartRequest = express.Request<{}> & {
|
||||
state: OAuthState;
|
||||
};
|
||||
|
||||
// @public (undocumented)
|
||||
export type OAuthStartResponse = {
|
||||
url: string;
|
||||
status?: number;
|
||||
};
|
||||
|
||||
// @public (undocumented)
|
||||
export type OAuthState = {
|
||||
nonce: string;
|
||||
@@ -654,12 +660,6 @@ export const providers: Readonly<{
|
||||
// @public (undocumented)
|
||||
export const readState: (stateString: string) => OAuthState;
|
||||
|
||||
// @public (undocumented)
|
||||
export type RedirectInfo = {
|
||||
url: string;
|
||||
status?: number;
|
||||
};
|
||||
|
||||
// @public (undocumented)
|
||||
export interface RouterOptions {
|
||||
// (undocumented)
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
import express from 'express';
|
||||
import { Profile as PassportProfile } from 'passport';
|
||||
import { BackstageSignInResult } from '@backstage/plugin-auth-node';
|
||||
import { RedirectInfo, ProfileInfo } from '../../providers/types';
|
||||
import { OAuthStartResponse, ProfileInfo } from '../../providers/types';
|
||||
|
||||
/**
|
||||
* Common options for passport.js-based OAuth providers
|
||||
@@ -115,7 +115,7 @@ export interface OAuthHandlers {
|
||||
/**
|
||||
* Initiate a sign in request with an auth provider.
|
||||
*/
|
||||
start(req: OAuthStartRequest): Promise<RedirectInfo>;
|
||||
start(req: OAuthStartRequest): Promise<OAuthStartResponse>;
|
||||
|
||||
/**
|
||||
* Handle the redirect from the auth provider when the user has signed in.
|
||||
|
||||
@@ -33,7 +33,7 @@ describe('PassportStrategyHelper', () => {
|
||||
}
|
||||
|
||||
describe('executeRedirectStrategy', () => {
|
||||
it('should call authenticate and resolve with RedirectInfo', async () => {
|
||||
it('should call authenticate and resolve with OAuthStartResponse', async () => {
|
||||
const mockStrategy = new MyCustomRedirectStrategy();
|
||||
const spyAuthenticate = jest.spyOn(mockStrategy, 'authenticate');
|
||||
const redirectStrategyPromise = executeRedirectStrategy(
|
||||
|
||||
@@ -20,7 +20,7 @@ import jwtDecoder from 'jwt-decode';
|
||||
import { InternalOAuthError } from 'passport-oauth2';
|
||||
|
||||
import { PassportProfile } from './types';
|
||||
import { ProfileInfo, RedirectInfo } from '../../providers/types';
|
||||
import { ProfileInfo, OAuthStartResponse } from '../../providers/types';
|
||||
|
||||
export type PassportDoneCallback<Res, Private = never> = (
|
||||
err?: Error,
|
||||
@@ -77,7 +77,7 @@ export const executeRedirectStrategy = async (
|
||||
req: express.Request,
|
||||
providerStrategy: passport.Strategy,
|
||||
options: Record<string, string>,
|
||||
): Promise<RedirectInfo> => {
|
||||
): Promise<OAuthStartResponse> => {
|
||||
return new Promise(resolve => {
|
||||
const strategy = Object.create(providerStrategy);
|
||||
strategy.redirect = (url: string, status?: number) => {
|
||||
|
||||
@@ -38,7 +38,7 @@ import {
|
||||
import {
|
||||
AuthHandler,
|
||||
AuthResolverContext,
|
||||
RedirectInfo,
|
||||
OAuthStartResponse,
|
||||
SignInResolver,
|
||||
} from '../types';
|
||||
import express from 'express';
|
||||
@@ -94,7 +94,7 @@ export class AtlassianAuthProvider implements OAuthHandlers {
|
||||
);
|
||||
}
|
||||
|
||||
async start(req: OAuthStartRequest): Promise<RedirectInfo> {
|
||||
async start(req: OAuthStartRequest): Promise<OAuthStartResponse> {
|
||||
return await executeRedirectStrategy(req, this._strategy, {
|
||||
state: encodeState(req.state),
|
||||
});
|
||||
|
||||
@@ -37,7 +37,7 @@ import {
|
||||
PassportDoneCallback,
|
||||
} from '../../lib/passport';
|
||||
import {
|
||||
RedirectInfo,
|
||||
OAuthStartResponse,
|
||||
AuthHandler,
|
||||
SignInResolver,
|
||||
AuthResolverContext,
|
||||
@@ -98,7 +98,7 @@ export class Auth0AuthProvider implements OAuthHandlers {
|
||||
);
|
||||
}
|
||||
|
||||
async start(req: OAuthStartRequest): Promise<RedirectInfo> {
|
||||
async start(req: OAuthStartRequest): Promise<OAuthStartResponse> {
|
||||
return await executeRedirectStrategy(req, this._strategy, {
|
||||
accessType: 'offline',
|
||||
prompt: 'consent',
|
||||
|
||||
@@ -39,7 +39,7 @@ import {
|
||||
import { createAuthProviderIntegration } from '../createAuthProviderIntegration';
|
||||
import {
|
||||
AuthHandler,
|
||||
RedirectInfo,
|
||||
OAuthStartResponse,
|
||||
SignInResolver,
|
||||
AuthResolverContext,
|
||||
} from '../types';
|
||||
@@ -121,7 +121,7 @@ export class BitbucketAuthProvider implements OAuthHandlers {
|
||||
);
|
||||
}
|
||||
|
||||
async start(req: OAuthStartRequest): Promise<RedirectInfo> {
|
||||
async start(req: OAuthStartRequest): Promise<OAuthStartResponse> {
|
||||
return await executeRedirectStrategy(req, this._strategy, {
|
||||
accessType: 'offline',
|
||||
prompt: 'consent',
|
||||
|
||||
@@ -26,7 +26,7 @@ import {
|
||||
PassportDoneCallback,
|
||||
} from '../../lib/passport';
|
||||
import {
|
||||
RedirectInfo,
|
||||
OAuthStartResponse,
|
||||
AuthHandler,
|
||||
SignInResolver,
|
||||
StateEncoder,
|
||||
@@ -107,7 +107,7 @@ export class GithubAuthProvider implements OAuthHandlers {
|
||||
);
|
||||
}
|
||||
|
||||
async start(req: OAuthStartRequest): Promise<RedirectInfo> {
|
||||
async start(req: OAuthStartRequest): Promise<OAuthStartResponse> {
|
||||
return await executeRedirectStrategy(req, this._strategy, {
|
||||
scope: req.scope,
|
||||
state: (await this.stateEncoder(req)).encodedState,
|
||||
|
||||
@@ -25,7 +25,7 @@ import {
|
||||
PassportDoneCallback,
|
||||
} from '../../lib/passport';
|
||||
import {
|
||||
RedirectInfo,
|
||||
OAuthStartResponse,
|
||||
SignInResolver,
|
||||
AuthHandler,
|
||||
AuthResolverContext,
|
||||
@@ -110,7 +110,7 @@ export class GitlabAuthProvider implements OAuthHandlers {
|
||||
);
|
||||
}
|
||||
|
||||
async start(req: OAuthStartRequest): Promise<RedirectInfo> {
|
||||
async start(req: OAuthStartRequest): Promise<OAuthStartResponse> {
|
||||
return await executeRedirectStrategy(req, this._strategy, {
|
||||
scope: req.scope,
|
||||
state: encodeState(req.state),
|
||||
|
||||
@@ -39,7 +39,7 @@ import {
|
||||
import {
|
||||
AuthHandler,
|
||||
AuthResolverContext,
|
||||
RedirectInfo,
|
||||
OAuthStartResponse,
|
||||
SignInResolver,
|
||||
} from '../types';
|
||||
import { createAuthProviderIntegration } from '../createAuthProviderIntegration';
|
||||
@@ -98,7 +98,7 @@ export class GoogleAuthProvider implements OAuthHandlers {
|
||||
);
|
||||
}
|
||||
|
||||
async start(req: OAuthStartRequest): Promise<RedirectInfo> {
|
||||
async start(req: OAuthStartRequest): Promise<OAuthStartResponse> {
|
||||
return await executeRedirectStrategy(req, this.strategy, {
|
||||
accessType: 'offline',
|
||||
prompt: 'consent',
|
||||
|
||||
@@ -49,7 +49,7 @@ export type {
|
||||
StateEncoder,
|
||||
AuthResponse,
|
||||
ProfileInfo,
|
||||
RedirectInfo,
|
||||
OAuthStartResponse,
|
||||
} from './types';
|
||||
|
||||
export { prepareBackstageIdentityResponse } from './prepareBackstageIdentityResponse';
|
||||
|
||||
@@ -38,7 +38,7 @@ import {
|
||||
} from '../../lib/passport';
|
||||
import {
|
||||
AuthHandler,
|
||||
RedirectInfo,
|
||||
OAuthStartResponse,
|
||||
SignInResolver,
|
||||
AuthResolverContext,
|
||||
} from '../types';
|
||||
@@ -97,7 +97,7 @@ export class MicrosoftAuthProvider implements OAuthHandlers {
|
||||
);
|
||||
}
|
||||
|
||||
async start(req: OAuthStartRequest): Promise<RedirectInfo> {
|
||||
async start(req: OAuthStartRequest): Promise<OAuthStartResponse> {
|
||||
return await executeRedirectStrategy(req, this._strategy, {
|
||||
scope: req.scope,
|
||||
state: encodeState(req.state),
|
||||
|
||||
@@ -39,7 +39,7 @@ import {
|
||||
import {
|
||||
AuthHandler,
|
||||
AuthResolverContext,
|
||||
RedirectInfo,
|
||||
OAuthStartResponse,
|
||||
SignInResolver,
|
||||
} from '../types';
|
||||
import { createAuthProviderIntegration } from '../createAuthProviderIntegration';
|
||||
@@ -114,7 +114,7 @@ export class OAuth2AuthProvider implements OAuthHandlers {
|
||||
);
|
||||
}
|
||||
|
||||
async start(req: OAuthStartRequest): Promise<RedirectInfo> {
|
||||
async start(req: OAuthStartRequest): Promise<OAuthStartResponse> {
|
||||
return await executeRedirectStrategy(req, this._strategy, {
|
||||
accessType: 'offline',
|
||||
prompt: 'consent',
|
||||
|
||||
@@ -40,7 +40,7 @@ import {
|
||||
import {
|
||||
AuthHandler,
|
||||
AuthResolverContext,
|
||||
RedirectInfo,
|
||||
OAuthStartResponse,
|
||||
SignInResolver,
|
||||
} from '../types';
|
||||
import { createAuthProviderIntegration } from '../createAuthProviderIntegration';
|
||||
@@ -91,7 +91,7 @@ export class OidcAuthProvider implements OAuthHandlers {
|
||||
this.resolverContext = options.resolverContext;
|
||||
}
|
||||
|
||||
async start(req: OAuthStartRequest): Promise<RedirectInfo> {
|
||||
async start(req: OAuthStartRequest): Promise<OAuthStartResponse> {
|
||||
const { strategy } = await this.implementation;
|
||||
const options: Record<string, string> = {
|
||||
scope: req.scope || this.scope || 'openid profile email',
|
||||
|
||||
@@ -38,7 +38,7 @@ import {
|
||||
} from '../../lib/passport';
|
||||
import {
|
||||
AuthHandler,
|
||||
RedirectInfo,
|
||||
OAuthStartResponse,
|
||||
SignInResolver,
|
||||
AuthResolverContext,
|
||||
} from '../types';
|
||||
@@ -125,7 +125,7 @@ export class OktaAuthProvider implements OAuthHandlers {
|
||||
);
|
||||
}
|
||||
|
||||
async start(req: OAuthStartRequest): Promise<RedirectInfo> {
|
||||
async start(req: OAuthStartRequest): Promise<OAuthStartResponse> {
|
||||
return await executeRedirectStrategy(req, this.strategy, {
|
||||
accessType: 'offline',
|
||||
prompt: 'consent',
|
||||
|
||||
@@ -37,7 +37,7 @@ import {
|
||||
PassportDoneCallback,
|
||||
} from '../../lib/passport';
|
||||
import {
|
||||
RedirectInfo,
|
||||
OAuthStartResponse,
|
||||
AuthHandler,
|
||||
SignInResolver,
|
||||
AuthResolverContext,
|
||||
@@ -95,7 +95,7 @@ export class OneLoginProvider implements OAuthHandlers {
|
||||
},
|
||||
);
|
||||
}
|
||||
async start(req: OAuthStartRequest): Promise<RedirectInfo> {
|
||||
async start(req: OAuthStartRequest): Promise<OAuthStartResponse> {
|
||||
return await executeRedirectStrategy(req, this._strategy, {
|
||||
accessType: 'offline',
|
||||
prompt: 'consent',
|
||||
|
||||
@@ -127,7 +127,7 @@ export type AuthProviderConfig = {
|
||||
};
|
||||
|
||||
/** @public */
|
||||
export type RedirectInfo = {
|
||||
export type OAuthStartResponse = {
|
||||
/**
|
||||
* URL to redirect to
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user