backend-defaults: rename viaSubject to issuedBy

Signed-off-by: Vincenzo Scamporlino <vincenzos@spotify.com>
This commit is contained in:
Vincenzo Scamporlino
2025-04-09 15:17:07 +02:00
parent 86d5f4a07c
commit 42b29f826e
3 changed files with 15 additions and 3 deletions
@@ -87,6 +87,7 @@ export class DefaultAuthService implements AuthService {
userResult.userEntityRef,
token,
this.#getJwtExpiration(token),
this.pluginId,
);
}
@@ -51,7 +51,7 @@ export function createCredentialsWithUserPrincipal(
sub: string,
token: string,
expiresAt?: Date,
viaSubject?: string,
issuedBySubject?: string,
): InternalBackstageCredentials<BackstageUserPrincipal> {
return Object.defineProperty(
{
@@ -61,7 +61,9 @@ export function createCredentialsWithUserPrincipal(
principal: {
type: 'user',
userEntityRef: sub,
...(viaSubject && { via: { type: 'service', subject: viaSubject } }),
...(issuedBySubject && {
issuedBy: { type: 'service', subject: issuedBySubject },
}),
},
},
'token',
@@ -36,7 +36,16 @@ export type BackstageUserPrincipal = {
*/
userEntityRef: string;
via?: BackstageServicePrincipal;
/**
* The service principal that issued the token on behalf of the user.
*
* @remarks
*
* This field is present in scenarios where a backend service acts on behalf
* of a user. It provides context about the intermediary service that
* facilitated the authentication.
*/
issuedBy?: BackstageServicePrincipal;
};
/**