backend-plugin-api: updated cookie auth implementation

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2024-02-26 01:28:27 +01:00
parent e210800545
commit d455112cbf
16 changed files with 474 additions and 158 deletions
@@ -46,6 +46,8 @@ export type BackstageServicePrincipal = {
export type BackstageCredentials<TPrincipal = unknown> = {
$$type: '@backstage/BackstageCredentials';
expiresAt?: Date;
principal: TPrincipal;
};
@@ -15,7 +15,11 @@
*/
import { Request, Response } from 'express';
import { BackstageCredentials, BackstagePrincipalTypes } from './AuthService';
import {
BackstageCredentials,
BackstagePrincipalTypes,
BackstageUserPrincipal,
} from './AuthService';
/** @public */
export interface HttpAuthService {
@@ -23,9 +27,14 @@ export interface HttpAuthService {
req: Request<any, any, any, any, any>,
options?: {
allow?: Array<TAllowed>;
allowedAuthMethods?: Array<'token' | 'cookie'>;
allowLimitedAccess?: boolean;
},
): Promise<BackstageCredentials<BackstagePrincipalTypes[TAllowed]>>;
issueUserCookie(res: Response): Promise<void>;
issueUserCookie(
res: Response,
options?: {
credentials?: BackstageCredentials<BackstageUserPrincipal>;
},
): Promise<{ expiresAt: Date }>;
}