@backstage/backend-defaults
Version:
Backend defaults used by Backstage backend apps
51 lines (48 loc) • 1.78 kB
TypeScript
import * as _backstage_backend_plugin_api from '@backstage/backend-plugin-api';
import { HttpAuthService, AuthService, DiscoveryService, BackstagePrincipalTypes, BackstageCredentials } from '@backstage/backend-plugin-api';
import { Request, Response } from 'express';
/**
* @public
* Options for creating a DefaultHttpAuthService.
*/
interface DefaultHttpAuthServiceOptions {
auth: AuthService;
discovery: DiscoveryService;
pluginId: string;
/**
* Optionally override logic for extracting the token from the request.
*/
getTokenFromRequest?: (req: Request) => {
token?: string;
};
}
/**
* @public
* DefaultHttpAuthService is the default implementation of the HttpAuthService
*/
declare class DefaultHttpAuthService implements HttpAuthService {
#private;
private constructor();
static create(options: DefaultHttpAuthServiceOptions): DefaultHttpAuthService;
credentials<TAllowed extends keyof BackstagePrincipalTypes = 'unknown'>(req: Request, options?: {
allow?: Array<TAllowed>;
allowLimitedAccess?: boolean;
}): Promise<BackstageCredentials<BackstagePrincipalTypes[TAllowed]>>;
issueUserCookie(res: Response, options?: {
credentials?: BackstageCredentials;
}): Promise<{
expiresAt: Date;
}>;
}
/**
* Authentication of HTTP requests.
*
* See {@link @backstage/code-plugin-api#HttpAuthService}
* and {@link https://backstage.io/docs/backend-system/core-services/http-auth | the service docs}
* for more information.
*
* @public
*/
declare const httpAuthServiceFactory: _backstage_backend_plugin_api.ServiceFactory<HttpAuthService, "plugin", "singleton">;
export { DefaultHttpAuthService, httpAuthServiceFactory };
export type { DefaultHttpAuthServiceOptions };