auth-backend: move a few types to auth-node

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2023-07-22 09:46:47 +02:00
parent 747712f930
commit 318816cef9
6 changed files with 137 additions and 98 deletions
+3 -19
View File
@@ -14,7 +14,7 @@
* limitations under the License.
*/
import { JsonValue } from '@backstage/types';
import { TokenParams as _TokenParams } from '@backstage/plugin-auth-node';
/** Represents any form of serializable JWK */
export interface AnyJWK extends Record<string, string> {
@@ -25,26 +25,10 @@ export interface AnyJWK extends Record<string, string> {
}
/**
* Parameters used to issue new ID Tokens
*
* @public
* @deprecated import from `@backstage/plugin-auth-node` instead
*/
export type TokenParams = {
/**
* The claims that will be embedded within the token. At a minimum, this should include
* the subject claim, `sub`. It is common to also list entity ownership relations in the
* `ent` list. Additional claims may also be added at the developer's discretion except
* for the following list, which will be overwritten by the TokenIssuer: `iss`, `aud`,
* `iat`, and `exp`. The Backstage team also maintains the right add new claims in the future
* without listing the change as a "breaking change".
*/
claims: {
/** The token subject, i.e. User ID */
sub: string;
/** A list of entity references that the user claims ownership through */
ent?: string[];
} & Record<string, JsonValue>;
};
export type TokenParams = _TokenParams;
/**
* A TokenIssuer is able to issue verifiable ID Tokens on demand.
+11 -79
View File
@@ -14,8 +14,6 @@
* limitations under the License.
*/
import { GetEntitiesRequest } from '@backstage/catalog-client';
import { Entity } from '@backstage/catalog-model';
import { Config } from '@backstage/config';
import {
BackstageIdentityResponse,
@@ -23,71 +21,24 @@ import {
} from '@backstage/plugin-auth-node';
import express from 'express';
import { LoggerService } from '@backstage/backend-plugin-api';
import { TokenParams } from '../identity/types';
import {
AuthResolverCatalogUserQuery as _AuthResolverCatalogUserQuery,
AuthResolverContext as _AuthResolverContext,
ProfileInfo as _ProfileInfo,
} from '@backstage/plugin-auth-node';
import { OAuthStartRequest } from '../lib/oauth/types';
/**
* A query for a single user in the catalog.
*
* If `entityRef` is used, the default kind is `'User'`.
*
* If `annotations` are used, all annotations must be present and
* match the provided value exactly. Only entities of kind `'User'` will be considered.
*
* If `filter` are used they are passed on as they are to the `CatalogApi`.
*
* Regardless of the query method, the query must match exactly one entity
* in the catalog, or an error will be thrown.
*
* @public
* @deprecated import from `@backstage/plugin-auth-node` instead
*/
export type AuthResolverCatalogUserQuery =
| {
entityRef:
| string
| {
kind?: string;
namespace?: string;
name: string;
};
}
| {
annotations: Record<string, string>;
}
| {
filter: Exclude<GetEntitiesRequest['filter'], undefined>;
};
export type AuthResolverCatalogUserQuery = _AuthResolverCatalogUserQuery;
/**
* The context that is used for auth processing.
*
* @public
* @deprecated import from `@backstage/plugin-auth-node` instead
*/
export type AuthResolverContext = {
/**
* Issues a Backstage token using the provided parameters.
*/
issueToken(params: TokenParams): Promise<{ token: string }>;
/**
* Finds a single user in the catalog using the provided query.
*
* See {@link AuthResolverCatalogUserQuery} for details.
*/
findCatalogUser(
query: AuthResolverCatalogUserQuery,
): Promise<{ entity: Entity }>;
/**
* Finds a single user in the catalog using the provided query, and then
* issues an identity for that user using default ownership resolution.
*
* See {@link AuthResolverCatalogUserQuery} for details.
*/
signInWithCatalogUser(
query: AuthResolverCatalogUserQuery,
): Promise<BackstageSignInResult>;
};
export type AuthResolverContext = _AuthResolverContext;
/**
* The callback used to resolve the cookie configuration for auth providers that use cookies.
@@ -219,29 +170,10 @@ export type AuthResponse<ProviderInfo> = {
};
/**
* Used to display login information to user, i.e. sidebar popup.
*
* It is also temporarily used as the profile of the signed-in user's Backstage
* identity, but we want to replace that with data from identity and/org catalog
* service
*
* @public
* @deprecated import from `@backstage/plugin-auth-node` instead
*/
export type ProfileInfo = {
/**
* Email ID of the signed in user.
*/
email?: string;
/**
* Display name that can be presented to the signed in user.
*/
displayName?: string;
/**
* URL to an image that can be used as the display image or avatar of the
* signed in user.
*/
picture?: string;
};
export type ProfileInfo = _ProfileInfo;
/**
* Type of sign in information context. Includes the profile information and