backend-plugin-api: switch principal mapping to use none instead of unauthenticated

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2024-02-16 12:18:35 +01:00
parent 4c72edd4c0
commit ddb7060e08
3 changed files with 4 additions and 4 deletions
+1 -1
View File
@@ -115,7 +115,7 @@ export type BackstageNonePrincipal = {
export type BackstagePrincipalTypes = {
user: BackstageUserPrincipal;
service: BackstageServicePrincipal;
unauthenticated: BackstageNonePrincipal;
none: BackstageNonePrincipal;
unknown: unknown;
};
@@ -55,7 +55,7 @@ export type BackstageCredentials<TPrincipal = unknown> = {
export type BackstagePrincipalTypes = {
user: BackstageUserPrincipal;
service: BackstageServicePrincipal;
unauthenticated: BackstageNonePrincipal;
none: BackstageNonePrincipal;
unknown: unknown;
};
@@ -60,13 +60,13 @@ export class MockHttpAuthService implements HttpAuthService {
return credentials as any;
}
if (this.#auth.isPrincipal(credentials, 'unauthenticated')) {
if (this.#auth.isPrincipal(credentials, 'none')) {
if (allowedPrincipalTypes.includes('none' as TAllowed)) {
return credentials as any;
}
throw new NotAllowedError(
`This endpoint does not allow 'unauthenticated' credentials`,
`This endpoint does not allow 'none' credentials`,
);
} else if (this.#auth.isPrincipal(credentials, 'user')) {
if (allowedPrincipalTypes.includes('user' as TAllowed)) {