-
Notifications
You must be signed in to change notification settings - Fork 120
fix(auth-app): handle no auth provider configured error #4716
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@red-hat-developer-hub/backstage-plugin-app-auth': minor | ||
| --- | ||
|
|
||
| Replaces the broken Guest/GitHub fallback with a descriptive ErrorPanel when auth.providers is empty or misconfigured. Removed DEFAULT_PROVIDER = 'github', auth providers need to explicitly installed dynamically. Also removed behavior when default Guest login when `auth.environment` is development. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -46,8 +46,6 @@ import { | |
| } from '../AuthApiRefs'; | ||
| import { signInTranslationRef } from '../translations/signIn'; | ||
|
|
||
| const DEFAULT_PROVIDER = 'github'; | ||
|
|
||
| const createProviders = (t: (key: string, params?: any) => string) => | ||
| new Map<string, SignInProviderConfig | string>([ | ||
| [ | ||
|
|
@@ -209,17 +207,15 @@ export function SignInPage(props: SignInPageProps): React.JSX.Element { | |
| </ErrorPanel> | ||
| ); | ||
| } | ||
| const isDevEnv = authEnvironment === 'development'; | ||
|
|
||
| const signInPage = configApi.getOptional<string | string[]>('signInPage'); | ||
| let providerNames: string[]; | ||
| if (signInPage === undefined) { | ||
| const fromAuth = | ||
| providerNames = | ||
| configApi | ||
| .getOptionalConfig('auth.providers') | ||
| ?.keys() | ||
| ?.filter(providerId => providerId !== 'guest') ?? []; | ||
| providerNames = fromAuth.length > 0 ? fromAuth : [DEFAULT_PROVIDER]; | ||
| } else { | ||
| providerNames = Array.isArray(signInPage) ? signInPage : [signInPage]; | ||
| } | ||
|
|
@@ -233,8 +229,20 @@ export function SignInPage(props: SignInPageProps): React.JSX.Element { | |
| ); | ||
|
|
||
| if (providerConfigs.length === 0) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Blocker —
If guest sign-in remains supported, resolve |
||
| const defaultProvider = providers.get(DEFAULT_PROVIDER); | ||
| if (defaultProvider) providerConfigs.push(defaultProvider); | ||
| return ( | ||
| <ErrorPanel | ||
| error={new Error(t('signIn.config.noConfiguredProviders.error'))} | ||
| title={t('signIn.config.noConfiguredProviders.panelTitle')} | ||
| > | ||
| <Typography variant="body2" component="div"> | ||
| {t('signIn.config.noConfiguredProviders.description', { | ||
| replace: { | ||
| authProvidersKey: <code>auth.providers</code>, | ||
| }, | ||
| })} | ||
| </Typography> | ||
| </ErrorPanel> | ||
| ); | ||
| } | ||
|
|
||
| if (providerConfigs.some(config => typeof config === 'string')) { | ||
|
|
@@ -244,16 +252,12 @@ export function SignInPage(props: SignInPageProps): React.JSX.Element { | |
| return <ProxiedSignInPage {...props} provider={proxiedProvider} />; | ||
| } | ||
|
|
||
| const providerList = isDevEnv | ||
| ? ['guest' as const, ...(providerConfigs as SignInProviderConfig[])] | ||
| : (providerConfigs as SignInProviderConfig[]); | ||
|
|
||
| return ( | ||
| <CCSignInPage | ||
| {...props} | ||
| title={t('signIn.page.title')} | ||
| align="center" | ||
| providers={providerList} | ||
| providers={providerConfigs as SignInProviderConfig[]} | ||
| /> | ||
| ); | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Blocker — guest-only
auth.providersbreaks default app-defaults devWhen
signInPageis omitted, keys underauth.providersare used butguestis filtered out. With onlyguest: {}configured (seeworkspaces/app-defaults/app-config.yaml),providerNamesis empty and this branch shows the new ErrorPanel.That replaces today’s dev behavior (implicit GitHub fallback + auto-prepended Guest). Please confirm intent and either:
auth.providers.guestexists andauth.environment === 'development'), orAlso consider a distinct message when the only configured provider is
guest— the current copy points atauth.providerseven though guest is already set.