From cc9a7a558b68498737438a07ce31b2982bcd59b2 Mon Sep 17 00:00:00 2001 From: Johan Haals Date: Fri, 16 Aug 2024 15:41:34 +0200 Subject: [PATCH 1/3] auth-backend: deprecate createRouter Signed-off-by: Johan Haals --- .changeset/thirty-dogs-wave.md | 5 +++++ plugins/auth-backend/api-report.md | 14 ++++++------ plugins/auth-backend/src/service/router.ts | 26 +++++++++++++--------- 3 files changed, 27 insertions(+), 18 deletions(-) create mode 100644 .changeset/thirty-dogs-wave.md diff --git a/.changeset/thirty-dogs-wave.md b/.changeset/thirty-dogs-wave.md new file mode 100644 index 0000000000..b8c4728a32 --- /dev/null +++ b/.changeset/thirty-dogs-wave.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-auth-backend': patch +--- + +Deprecated `createRouter` and its router options in favour of the new backend system. diff --git a/plugins/auth-backend/api-report.md b/plugins/auth-backend/api-report.md index 56c2da3a08..29086cf86b 100644 --- a/plugins/auth-backend/api-report.md +++ b/plugins/auth-backend/api-report.md @@ -20,6 +20,7 @@ import { ClientAuthResponse } from '@backstage/plugin-auth-node'; import { cloudflareAccessSignInResolvers } from '@backstage/plugin-auth-backend-module-cloudflare-access-provider'; import { Config } from '@backstage/config'; import { CookieConfigurer as CookieConfigurer_2 } from '@backstage/plugin-auth-node'; +import { DatabaseService } from '@backstage/backend-plugin-api'; import { decodeOAuthState } from '@backstage/plugin-auth-node'; import { DiscoveryService } from '@backstage/backend-plugin-api'; import { encodeOAuthState } from '@backstage/plugin-auth-node'; @@ -33,14 +34,13 @@ import { OAuth2ProxyResult as OAuth2ProxyResult_2 } from '@backstage/plugin-auth import { OAuthEnvironmentHandler as OAuthEnvironmentHandler_2 } from '@backstage/plugin-auth-node'; import { OAuthState as OAuthState_2 } from '@backstage/plugin-auth-node'; import { OidcAuthResult as OidcAuthResult_2 } from '@backstage/plugin-auth-backend-module-oidc-provider'; -import { PluginDatabaseManager } from '@backstage/backend-common'; -import { PluginEndpointDiscovery } from '@backstage/backend-common'; import { prepareBackstageIdentityResponse as prepareBackstageIdentityResponse_2 } from '@backstage/plugin-auth-node'; import { Profile } from 'passport'; import { ProfileInfo as ProfileInfo_2 } from '@backstage/plugin-auth-node'; import { SignInInfo as SignInInfo_2 } from '@backstage/plugin-auth-node'; import { SignInResolver as SignInResolver_2 } from '@backstage/plugin-auth-node'; import { TokenManager } from '@backstage/backend-common'; +import { TokenManagerService } from '@backstage/backend-plugin-api'; import { TokenParams as TokenParams_2 } from '@backstage/plugin-auth-node'; import { UserEntity } from '@backstage/catalog-model'; import { WebMessageResponse as WebMessageResponse_2 } from '@backstage/plugin-auth-node'; @@ -193,7 +193,7 @@ export function createAuthProviderIntegration< // @public (undocumented) export function createOriginFilter(config: Config): (origin: string) => boolean; -// @public (undocumented) +// @public @deprecated (undocumented) export function createRouter(options: RouterOptions): Promise; // @public @@ -647,7 +647,7 @@ export const providers: Readonly<{ // @public @deprecated (undocumented) export const readState: typeof decodeOAuthState; -// @public (undocumented) +// @public @deprecated (undocumented) export interface RouterOptions { // (undocumented) auth?: AuthService; @@ -656,11 +656,11 @@ export interface RouterOptions { // (undocumented) config: Config; // (undocumented) - database: PluginDatabaseManager; + database: DatabaseService; // (undocumented) disableDefaultProviderFactories?: boolean; // (undocumented) - discovery: PluginEndpointDiscovery; + discovery: DiscoveryService; // (undocumented) httpAuth?: HttpAuthService; // (undocumented) @@ -672,7 +672,7 @@ export interface RouterOptions { // (undocumented) tokenFactoryAlgorithm?: string; // (undocumented) - tokenManager: TokenManager; + tokenManager: TokenManagerService; } // @public (undocumented) diff --git a/plugins/auth-backend/src/service/router.ts b/plugins/auth-backend/src/service/router.ts index 4bb42c3abd..033f9f8d21 100644 --- a/plugins/auth-backend/src/service/router.ts +++ b/plugins/auth-backend/src/service/router.ts @@ -19,17 +19,15 @@ import Router from 'express-promise-router'; import cookieParser from 'cookie-parser'; import { AuthService, + DatabaseService, + DiscoveryService, HttpAuthService, LoggerService, + TokenManagerService, } from '@backstage/backend-plugin-api'; import { defaultAuthProviderFactories } from '../providers'; import { AuthOwnershipResolver } from '@backstage/plugin-auth-node'; -import { - createLegacyAuthAdapters, - PluginDatabaseManager, - PluginEndpointDiscovery, - TokenManager, -} from '@backstage/backend-common'; +import { createLegacyAuthAdapters } from '@backstage/backend-common'; import { NotFoundError } from '@backstage/errors'; import { CatalogApi } from '@backstage/catalog-client'; import { @@ -49,13 +47,16 @@ import { StaticKeyStore } from '../identity/StaticKeyStore'; import { Config } from '@backstage/config'; import { bindProviderRouters, ProviderFactories } from '../providers/router'; -/** @public */ +/** + * @public + * @deprecated Please migrate to the new backend system as this will be removed in the future. + */ export interface RouterOptions { logger: LoggerService; - database: PluginDatabaseManager; + database: DatabaseService; config: Config; - discovery: PluginEndpointDiscovery; - tokenManager: TokenManager; + discovery: DiscoveryService; + tokenManager: TokenManagerService; auth?: AuthService; httpAuth?: HttpAuthService; tokenFactoryAlgorithm?: string; @@ -65,7 +66,10 @@ export interface RouterOptions { ownershipResolver?: AuthOwnershipResolver; } -/** @public */ +/** + * @public + * @deprecated Please migrate to the new backend system as this will be removed in the future. + */ export async function createRouter( options: RouterOptions, ): Promise { From 80a3df73fcced39c7625d8b0ddb003b322028022 Mon Sep 17 00:00:00 2001 From: Johan Haals Date: Fri, 16 Aug 2024 15:48:59 +0200 Subject: [PATCH 2/3] Remove config Dependency Signed-off-by: Johan Haals --- plugins/auth-backend/api-report.md | 3 ++- plugins/auth-backend/package.json | 1 - plugins/auth-backend/src/service/router.ts | 4 ++-- yarn.lock | 1 - 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/plugins/auth-backend/api-report.md b/plugins/auth-backend/api-report.md index 29086cf86b..f801c92597 100644 --- a/plugins/auth-backend/api-report.md +++ b/plugins/auth-backend/api-report.md @@ -37,6 +37,7 @@ import { OidcAuthResult as OidcAuthResult_2 } from '@backstage/plugin-auth-backe import { prepareBackstageIdentityResponse as prepareBackstageIdentityResponse_2 } from '@backstage/plugin-auth-node'; import { Profile } from 'passport'; import { ProfileInfo as ProfileInfo_2 } from '@backstage/plugin-auth-node'; +import { RootConfigService } from '@backstage/backend-plugin-api'; import { SignInInfo as SignInInfo_2 } from '@backstage/plugin-auth-node'; import { SignInResolver as SignInResolver_2 } from '@backstage/plugin-auth-node'; import { TokenManager } from '@backstage/backend-common'; @@ -654,7 +655,7 @@ export interface RouterOptions { // (undocumented) catalogApi?: CatalogApi; // (undocumented) - config: Config; + config: RootConfigService; // (undocumented) database: DatabaseService; // (undocumented) diff --git a/plugins/auth-backend/package.json b/plugins/auth-backend/package.json index 9c7b205352..7402e0d242 100644 --- a/plugins/auth-backend/package.json +++ b/plugins/auth-backend/package.json @@ -47,7 +47,6 @@ "@backstage/backend-plugin-api": "workspace:^", "@backstage/catalog-client": "workspace:^", "@backstage/catalog-model": "workspace:^", - "@backstage/config": "workspace:^", "@backstage/errors": "workspace:^", "@backstage/plugin-auth-backend-module-atlassian-provider": "workspace:^", "@backstage/plugin-auth-backend-module-aws-alb-provider": "workspace:^", diff --git a/plugins/auth-backend/src/service/router.ts b/plugins/auth-backend/src/service/router.ts index 033f9f8d21..b954eb4dbb 100644 --- a/plugins/auth-backend/src/service/router.ts +++ b/plugins/auth-backend/src/service/router.ts @@ -23,6 +23,7 @@ import { DiscoveryService, HttpAuthService, LoggerService, + RootConfigService, TokenManagerService, } from '@backstage/backend-plugin-api'; import { defaultAuthProviderFactories } from '../providers'; @@ -44,7 +45,6 @@ import { readBackstageTokenExpiration } from './readBackstageTokenExpiration'; import { TokenIssuer } from '../identity/types'; import { StaticTokenIssuer } from '../identity/StaticTokenIssuer'; import { StaticKeyStore } from '../identity/StaticKeyStore'; -import { Config } from '@backstage/config'; import { bindProviderRouters, ProviderFactories } from '../providers/router'; /** @@ -54,7 +54,7 @@ import { bindProviderRouters, ProviderFactories } from '../providers/router'; export interface RouterOptions { logger: LoggerService; database: DatabaseService; - config: Config; + config: RootConfigService; discovery: DiscoveryService; tokenManager: TokenManagerService; auth?: AuthService; diff --git a/yarn.lock b/yarn.lock index 301d7de22f..8956a0159e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5146,7 +5146,6 @@ __metadata: "@backstage/catalog-client": "workspace:^" "@backstage/catalog-model": "workspace:^" "@backstage/cli": "workspace:^" - "@backstage/config": "workspace:^" "@backstage/errors": "workspace:^" "@backstage/plugin-auth-backend-module-atlassian-provider": "workspace:^" "@backstage/plugin-auth-backend-module-aws-alb-provider": "workspace:^" From 37f12918a6cdf98a5d5e1f24e2758af597e5f56c Mon Sep 17 00:00:00 2001 From: Johan Haals Date: Mon, 19 Aug 2024 08:12:43 +0200 Subject: [PATCH 3/3] chore: re-add config dependency Signed-off-by: Johan Haals --- plugins/auth-backend/package.json | 1 + yarn.lock | 1 + 2 files changed, 2 insertions(+) diff --git a/plugins/auth-backend/package.json b/plugins/auth-backend/package.json index 7402e0d242..9c7b205352 100644 --- a/plugins/auth-backend/package.json +++ b/plugins/auth-backend/package.json @@ -47,6 +47,7 @@ "@backstage/backend-plugin-api": "workspace:^", "@backstage/catalog-client": "workspace:^", "@backstage/catalog-model": "workspace:^", + "@backstage/config": "workspace:^", "@backstage/errors": "workspace:^", "@backstage/plugin-auth-backend-module-atlassian-provider": "workspace:^", "@backstage/plugin-auth-backend-module-aws-alb-provider": "workspace:^", diff --git a/yarn.lock b/yarn.lock index 8956a0159e..301d7de22f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5146,6 +5146,7 @@ __metadata: "@backstage/catalog-client": "workspace:^" "@backstage/catalog-model": "workspace:^" "@backstage/cli": "workspace:^" + "@backstage/config": "workspace:^" "@backstage/errors": "workspace:^" "@backstage/plugin-auth-backend-module-atlassian-provider": "workspace:^" "@backstage/plugin-auth-backend-module-aws-alb-provider": "workspace:^"