Merge pull request #22765 from drodil/auth_resolver_override

feat: allow overriding default ownership resolving
This commit is contained in:
Patrik Oldsberg
2024-04-23 16:44:50 +02:00
committed by GitHub
11 changed files with 111 additions and 8 deletions
+17
View File
@@ -21,6 +21,23 @@ import { Strategy } from 'passport';
import { ZodSchema } from 'zod';
import { ZodTypeDef } from 'zod';
// @public (undocumented)
export interface AuthOwnershipResolutionExtensionPoint {
// (undocumented)
setAuthOwnershipResolver(ownershipResolver: AuthOwnershipResolver): void;
}
// @public (undocumented)
export const authOwnershipResolutionExtensionPoint: ExtensionPoint<AuthOwnershipResolutionExtensionPoint>;
// @public
export interface AuthOwnershipResolver {
// (undocumented)
resolveOwnershipEntityRefs(entity: Entity): Promise<{
ownershipEntityRefs: string[];
}>;
}
// @public @deprecated (undocumented)
export type AuthProviderConfig = {
baseUrl: string;
@@ -0,0 +1,28 @@
/*
* Copyright 2023 The Backstage Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { AuthOwnershipResolver } from '../types';
import { createExtensionPoint } from '@backstage/backend-plugin-api';
/** @public */
export interface AuthOwnershipResolutionExtensionPoint {
setAuthOwnershipResolver(ownershipResolver: AuthOwnershipResolver): void;
}
/** @public */
export const authOwnershipResolutionExtensionPoint =
createExtensionPoint<AuthOwnershipResolutionExtensionPoint>({
id: 'auth.ownershipResolution',
});
@@ -19,3 +19,8 @@ export {
type AuthProviderRegistrationOptions,
type AuthProvidersExtensionPoint,
} from './AuthProvidersExtensionPoint';
export {
authOwnershipResolutionExtensionPoint,
type AuthOwnershipResolutionExtensionPoint,
} from './AuthOwnershipResolutionExtensionPoint';
+1
View File
@@ -43,5 +43,6 @@ export type {
SignInInfo,
SignInResolver,
TokenParams,
AuthOwnershipResolver,
} from './types';
export { tokenTypes } from './types';
+11
View File
@@ -163,6 +163,17 @@ export type AuthResolverContext = {
): Promise<BackstageSignInResult>;
};
/**
* Resolver interface for resolving the ownership entity references for entity
*
* @public
*/
export interface AuthOwnershipResolver {
resolveOwnershipEntityRefs(
entity: Entity,
): Promise<{ ownershipEntityRefs: string[] }>;
}
/**
* Any Auth provider needs to implement this interface which handles the routes in the
* auth backend. Any auth API requests from the frontend reaches these methods.