auth refactor type fixes
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -23,6 +23,7 @@ import {
|
||||
import { gcpIapAuthenticator } from './authenticator';
|
||||
import { gcpIapSignInResolvers } from './resolvers';
|
||||
|
||||
/** @public */
|
||||
export const authModuleGcpIapProvider = createBackendModule({
|
||||
pluginId: 'auth',
|
||||
moduleId: 'gcpIapProvider',
|
||||
|
||||
@@ -23,6 +23,7 @@ import {
|
||||
import { googleAuthenticator } from './authenticator';
|
||||
import { googleSignInResolvers } from './resolvers';
|
||||
|
||||
/** @public */
|
||||
export const authModuleGoogleProvider = createBackendModule({
|
||||
pluginId: 'auth',
|
||||
moduleId: 'googleProvider',
|
||||
|
||||
@@ -31,9 +31,6 @@ export * from './lib/flow';
|
||||
// OAuth wrapper over a passport or a custom `strategy`.
|
||||
export * from './lib/oauth';
|
||||
|
||||
// Helpers to convert new API in @backstage/plugin-auth-node to old API
|
||||
export * from './lib/legacy';
|
||||
|
||||
export * from './lib/catalog';
|
||||
|
||||
export { getDefaultOwnershipEntityRefs } from './lib/resolvers';
|
||||
|
||||
@@ -22,7 +22,7 @@ import { AuthHandler } from '../../providers';
|
||||
import { OAuthResult } from '../oauth';
|
||||
import { PassportProfile } from '../passport/types';
|
||||
|
||||
/** @public */
|
||||
/** @internal */
|
||||
export function adaptLegacyOAuthHandler(
|
||||
authHandler?: AuthHandler<OAuthResult>,
|
||||
): ProfileTransform<OAuthAuthenticatorResult<PassportProfile>> | undefined {
|
||||
|
||||
@@ -21,7 +21,7 @@ import {
|
||||
} from '@backstage/plugin-auth-node';
|
||||
import { OAuthResult } from '../oauth';
|
||||
|
||||
/** @public */
|
||||
/** @internal */
|
||||
export function adaptLegacyOAuthSignInResolver(
|
||||
signInResolver?: SignInResolver<OAuthResult>,
|
||||
): SignInResolver<OAuthAuthenticatorResult<PassportProfile>> | undefined {
|
||||
|
||||
@@ -21,6 +21,7 @@ import {
|
||||
} from '@backstage/plugin-auth-node';
|
||||
import { OAuthResult } from '../oauth';
|
||||
|
||||
/** @internal */
|
||||
export function adaptOAuthSignInResolverToLegacy<
|
||||
TKeys extends string,
|
||||
>(resolvers: {
|
||||
|
||||
@@ -52,7 +52,7 @@ export const TEN_MINUTES_MS = 600 * 1000;
|
||||
|
||||
/**
|
||||
* @public
|
||||
* @deprecated
|
||||
* @deprecated Use `createOAuthRouteHandlers` from `@backstage/plugin-auth-node` instead
|
||||
*/
|
||||
export type OAuthAdapterOptions = {
|
||||
providerId: string;
|
||||
|
||||
@@ -20,4 +20,4 @@ import { OAuthEnvironmentHandler as _OAuthEnvironmentHandler } from '@backstage/
|
||||
* @public
|
||||
* @deprecated import from `@backstage/plugin-auth-node` instead
|
||||
*/
|
||||
export type OAuthEnvironmentHandler = _OAuthEnvironmentHandler;
|
||||
export const OAuthEnvironmentHandler = _OAuthEnvironmentHandler;
|
||||
|
||||
@@ -26,7 +26,7 @@ import { OAuthStartResponse, ProfileInfo } from '../../providers/types';
|
||||
* Common options for passport.js-based OAuth providers
|
||||
*
|
||||
* @public
|
||||
* @deprecated
|
||||
* @deprecated No longer in use
|
||||
*/
|
||||
export type OAuthProviderOptions = {
|
||||
/**
|
||||
|
||||
@@ -32,6 +32,6 @@ export type GcpIapTokenInfo = _GcpIapTokenInfo;
|
||||
* callbacks.
|
||||
*
|
||||
* @public
|
||||
* @deprecated
|
||||
* @deprecated import from `@backstage/plugin-auth-backend-module-gcp-iap-provider` instead
|
||||
*/
|
||||
export type GcpIapResult = _GcpIapResult;
|
||||
|
||||
@@ -45,6 +45,9 @@ describe('MicrosoftAuthProvider', () => {
|
||||
},
|
||||
})({
|
||||
providerId: 'microsoft',
|
||||
baseUrl: 'http://backstage.test/api/auth',
|
||||
appUrl: 'http://backstage.test',
|
||||
isOriginAllowed: _ => true,
|
||||
globalConfig: {
|
||||
baseUrl: 'http://backstage.test/api/auth',
|
||||
appUrl: 'http://backstage.test',
|
||||
|
||||
@@ -21,4 +21,4 @@ export {
|
||||
type IdentityClientOptions,
|
||||
} from './DefaultIdentityClient';
|
||||
export { IdentityClient } from './IdentityClient';
|
||||
export type { IdentityApi } from './IdentityApi';
|
||||
export type { IdentityApi, IdentityApiGetIdentityRequest } from './IdentityApi';
|
||||
|
||||
@@ -40,6 +40,5 @@ export {
|
||||
type OAuthAuthenticatorRefreshInput,
|
||||
type OAuthAuthenticatorResult,
|
||||
type OAuthAuthenticatorStartInput,
|
||||
type OAuthProfileTransform,
|
||||
type OAuthSession,
|
||||
} from './types';
|
||||
|
||||
@@ -18,6 +18,7 @@ import { Config } from '@backstage/config';
|
||||
import { Request } from 'express';
|
||||
import { ProfileTransform } from '../types';
|
||||
|
||||
/** @public */
|
||||
export interface OAuthSession {
|
||||
accessToken: string;
|
||||
tokenType: string;
|
||||
@@ -27,33 +28,39 @@ export interface OAuthSession {
|
||||
refreshToken?: string;
|
||||
}
|
||||
|
||||
/** @public */
|
||||
export interface OAuthAuthenticatorStartInput {
|
||||
scope: string;
|
||||
state: string;
|
||||
req: Request;
|
||||
}
|
||||
|
||||
/** @public */
|
||||
export interface OAuthAuthenticatorAuthenticateInput {
|
||||
req: Request;
|
||||
}
|
||||
|
||||
/** @public */
|
||||
export interface OAuthAuthenticatorRefreshInput {
|
||||
scope: string;
|
||||
refreshToken: string;
|
||||
req: Request;
|
||||
}
|
||||
|
||||
/** @public */
|
||||
export interface OAuthAuthenticatorLogoutInput {
|
||||
accessToken?: string;
|
||||
refreshToken?: string;
|
||||
req: Request;
|
||||
}
|
||||
|
||||
/** @public */
|
||||
export interface OAuthAuthenticatorResult<TProfile> {
|
||||
fullProfile: TProfile;
|
||||
session: OAuthSession;
|
||||
}
|
||||
|
||||
/** @public */
|
||||
export interface OAuthAuthenticator<TContext, TProfile> {
|
||||
defaultProfileTransform: ProfileTransform<OAuthAuthenticatorResult<TProfile>>;
|
||||
shouldPersistScopes?: boolean;
|
||||
@@ -73,6 +80,7 @@ export interface OAuthAuthenticator<TContext, TProfile> {
|
||||
logout?(input: OAuthAuthenticatorLogoutInput, ctx: TContext): Promise<void>;
|
||||
}
|
||||
|
||||
/** @public */
|
||||
export function createOAuthAuthenticator<TContext, TProfile>(
|
||||
authenticator: OAuthAuthenticator<TContext, TProfile>,
|
||||
): OAuthAuthenticator<TContext, TProfile> {
|
||||
|
||||
@@ -26,6 +26,7 @@ import {
|
||||
import { createProxyAuthRouteHandlers } from './createProxyRouteHandlers';
|
||||
import { ProxyAuthenticator } from './types';
|
||||
|
||||
/** @public */
|
||||
export function createProxyAuthProviderFactory<TResult>(options: {
|
||||
authenticator: ProxyAuthenticator<unknown, TResult>;
|
||||
profileTransform?: ProfileTransform<TResult>;
|
||||
|
||||
@@ -18,6 +18,7 @@ import { Config } from '@backstage/config';
|
||||
import { Request } from 'express';
|
||||
import { ProfileTransform } from '../types';
|
||||
|
||||
/** @public */
|
||||
export interface ProxyAuthenticator<TContext, TResult> {
|
||||
defaultProfileTransform: ProfileTransform<TResult>;
|
||||
initialize(ctx: { config: Config }): Promise<TContext>;
|
||||
@@ -27,6 +28,7 @@ export interface ProxyAuthenticator<TContext, TResult> {
|
||||
): Promise<{ result: TResult }>;
|
||||
}
|
||||
|
||||
/** @public */
|
||||
export function createProxyAuthenticator<TContext, TResult>(
|
||||
authenticator: ProxyAuthenticator<TContext, TResult>,
|
||||
): ProxyAuthenticator<TContext, TResult> {
|
||||
|
||||
@@ -19,6 +19,7 @@ import { SignInResolver } from '../types';
|
||||
import zodToJsonSchema from 'zod-to-json-schema';
|
||||
import { JsonObject } from '@backstage/types';
|
||||
|
||||
/** @public */
|
||||
export interface SignInResolverFactory<TAuthResult, TOptions> {
|
||||
(
|
||||
...options: undefined extends TOptions
|
||||
@@ -28,6 +29,7 @@ export interface SignInResolverFactory<TAuthResult, TOptions> {
|
||||
optionsJsonSchema?: JsonObject;
|
||||
}
|
||||
|
||||
/** @public */
|
||||
export interface SignInResolverFactoryOptions<
|
||||
TAuthResult,
|
||||
TOptionsOutput,
|
||||
@@ -37,6 +39,7 @@ export interface SignInResolverFactoryOptions<
|
||||
create(options: TOptionsOutput): SignInResolver<TAuthResult>;
|
||||
}
|
||||
|
||||
/** @public */
|
||||
export function createSignInResolverFactory<
|
||||
TAuthResult,
|
||||
TOptionsOutput,
|
||||
|
||||
Reference in New Issue
Block a user