backend-defaults: add via to credentials

Co-authored-by: Fredrik Adelöw <freben@gmail.com>
Co-authored-by: Patrik Oldsberg <poldsberg@gmail.com>
Signed-off-by: Vincenzo Scamporlino <vincenzos@spotify.com>
This commit is contained in:
Vincenzo Scamporlino
2025-04-09 11:52:48 +02:00
parent 96865ec71e
commit 86d5f4a07c
3 changed files with 5 additions and 0 deletions
@@ -68,6 +68,7 @@ export class DefaultAuthService implements AuthService {
userResult.userEntityRef,
pluginResult.limitedUserToken,
this.#getJwtExpiration(pluginResult.limitedUserToken),
pluginResult.subject,
);
}
return createCredentialsWithServicePrincipal(pluginResult.subject);
@@ -51,6 +51,7 @@ export function createCredentialsWithUserPrincipal(
sub: string,
token: string,
expiresAt?: Date,
viaSubject?: string,
): InternalBackstageCredentials<BackstageUserPrincipal> {
return Object.defineProperty(
{
@@ -60,6 +61,7 @@ export function createCredentialsWithUserPrincipal(
principal: {
type: 'user',
userEntityRef: sub,
...(viaSubject && { via: { type: 'service', subject: viaSubject } }),
},
},
'token',
@@ -35,6 +35,8 @@ export type BackstageUserPrincipal = {
* The entity ref of the user entity that this principal represents.
*/
userEntityRef: string;
via?: BackstageServicePrincipal;
};
/**