backend-plugin-api: auth refactor to issueServiceToken with required credentials + getOwnCredentials

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2024-02-10 12:04:11 +01:00
parent 9ae4b9b6c2
commit c599fe1f7b
6 changed files with 39 additions and 34 deletions
@@ -71,9 +71,10 @@ export interface AuthService {
type: TType,
): credentials is BackstageCredentials<BackstagePrincipalTypes[TType]>;
getOwnCredentials(): Promise<BackstageCredentials<BackstageServicePrincipal>>;
// TODO: should the caller provide the target plugin ID?
// TODO: how can we make it very difficult to forget to forward credentials
issueToken(options: {
forward?: BackstageCredentials;
issueServiceToken(options: {
forward: BackstageCredentials;
}): Promise<{ token: string }>;
}
@@ -43,8 +43,8 @@ export interface HttpAuthService {
BackstageCredentials<BackstageHttpAccessToPrincipalTypesMapping[TAllowed]>
>;
requestHeaders(options?: {
forward?: BackstageCredentials;
requestHeaders(options: {
forward: BackstageCredentials;
}): Promise<Record<string, string>>;
issueUserCookie(res: Response): Promise<void>;