backend-{plugin,app}-api: add UserInfoService + initial implementation

Co-authored-by: Fredrik Adelöw <freben@gmail.com>
Co-authored-by: Carl-Erik Bergström <cbergstrom@spotify.com>
Co-authored-by: blam <ben@blam.sh>
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2024-02-09 13:03:06 +01:00
parent 9e45e2af6d
commit 746701e094
8 changed files with 142 additions and 0 deletions
+17
View File
@@ -121,6 +121,14 @@ export type BackstageUserCredentials = {
userEntityRef: string;
};
// @public (undocumented)
export interface BackstageUserInfo {
// (undocumented)
ownershipEntityRefs: string[];
// (undocumented)
userEntityRef: string;
}
// @public
export interface CacheService {
delete(key: string): Promise<void>;
@@ -146,6 +154,7 @@ export type CacheServiceSetOptions = {
// @public
export namespace coreServices {
const auth: ServiceRef<AuthService, 'plugin'>;
const userInfo: ServiceRef<UserInfoService, 'plugin'>;
const cache: ServiceRef<CacheService, 'plugin'>;
const rootConfig: ServiceRef<RootConfigService, 'root'>;
const database: ServiceRef<DatabaseService, 'plugin'>;
@@ -524,4 +533,12 @@ export interface UrlReaderService {
readUrl(url: string, options?: ReadUrlOptions): Promise<ReadUrlResponse>;
search(url: string, options?: SearchOptions): Promise<SearchResponse>;
}
// @public (undocumented)
export interface UserInfoService {
// (undocumented)
getUserInfo(
credentials: BackstageUserCredentials,
): Promise<BackstageUserInfo>;
}
```
@@ -0,0 +1,30 @@
/*
* Copyright 2024 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 { BackstageUserCredentials } from './AuthService';
/** @public */
export interface BackstageUserInfo {
userEntityRef: string;
ownershipEntityRefs: string[];
}
/** @public */
export interface UserInfoService {
getUserInfo(
credentials: BackstageUserCredentials,
): Promise<BackstageUserInfo>;
}
@@ -31,6 +31,17 @@ export namespace coreServices {
id: 'core.auth',
});
/**
* The service reference for the plugin scoped {@link UserInfoService}.
*
* @public
*/
export const userInfo = createServiceRef<
import('./UserInfoService').UserInfoService
>({
id: 'core.userInfo',
});
/**
* The service reference for the plugin scoped {@link CacheService}.
*
@@ -62,4 +62,5 @@ export type {
SearchResponseFile,
UrlReaderService,
} from './UrlReaderService';
export type { BackstageUserInfo, UserInfoService } from './UserInfoService';
export type { IdentityService } from './IdentityService';