auth-node: deprecate AuthProviderConfig and move to top-level props instead

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2023-07-29 11:56:38 +02:00
parent 969f9f2553
commit 12b4d8a3f8
2 changed files with 31 additions and 7 deletions
@@ -35,11 +35,11 @@ export function createOAuthProviderFactory<TProfile>(options: {
return OAuthEnvironmentHandler.mapConfig(ctx.config, envConfig => {
return createOAuthRouteHandlers<TProfile>({
authenticator: options.authenticator,
appUrl: ctx.globalConfig.appUrl,
baseUrl: ctx.globalConfig.baseUrl,
appUrl: ctx.appUrl,
baseUrl: ctx.baseUrl,
config: envConfig,
isOriginAllowed: ctx.globalConfig.isOriginAllowed,
cookieConfigurer: ctx.globalConfig.cookieConfigurer,
isOriginAllowed: ctx.isOriginAllowed,
cookieConfigurer: ctx.cookieConfigurer,
providerId: ctx.providerId,
resolverContext: ctx.resolverContext,
stateTransform: options.stateTransform,
+27 -3
View File
@@ -215,7 +215,10 @@ export interface AuthProviderRouteHandlers {
logout?(req: Request, res: Response): Promise<void>;
}
/** @public */
/**
* @public
* @deprecated Use top-level properties passed to `AuthProviderFactory` instead
*/
export type AuthProviderConfig = {
/**
* The protocol://domain[:port] where the app is hosted. This is used to construct the
@@ -242,15 +245,36 @@ export type AuthProviderConfig = {
/** @public */
export type AuthProviderFactory = (options: {
providerId: string;
/** @deprecated Use top-level properties instead */
globalConfig: AuthProviderConfig;
config: Config;
logger: LoggerService;
resolverContext: AuthResolverContext;
/**
* The protocol://domain[:port] where the app is hosted. This is used to construct the
* callbackURL to redirect to once the user signs in to the auth provider.
*/
baseUrl: string;
/**
* The base URL of the app as provided by app.baseUrl
*/
appUrl: string;
/**
* A function that is called to check whether an origin is allowed to receive the authentication result.
*/
isOriginAllowed: (origin: string) => boolean;
/**
* The function used to resolve cookie configuration based on the auth provider options.
*/
cookieConfigurer?: CookieConfigurer;
}) => AuthProviderRouteHandlers;
/** @public */
export type ClientAuthResponse<ProviderInfo> = {
providerInfo: ProviderInfo;
export type ClientAuthResponse<TProviderInfo> = {
providerInfo: TProviderInfo;
profile: ProfileInfo;
backstageIdentity?: BackstageIdentityResponse;
};