diff --git a/.changeset/twenty-jeans-speak.md b/.changeset/twenty-jeans-speak.md index c7385031e6..fddcc2eedd 100644 --- a/.changeset/twenty-jeans-speak.md +++ b/.changeset/twenty-jeans-speak.md @@ -1,5 +1,5 @@ --- -'@backstage/plugin-auth-backend': minor +'@backstage/plugin-auth-backend': patch --- Added authentication provider for Azure Easy Authentication. diff --git a/docs/auth/microsoft/azure-easyauth.md b/docs/auth/microsoft/azure-easyauth.md index 00d798dce9..3571a3e5c5 100644 --- a/docs/auth/microsoft/azure-easyauth.md +++ b/docs/auth/microsoft/azure-easyauth.md @@ -19,7 +19,7 @@ export default async function createPlugin( env: PluginEnvironment, ): Promise { const authProviderFactories = { - 'azure-easyAuth': providers.easyAuth.create({ + 'azure-easyauth': providers.easyAuth.create({ signIn: { resolver: async (info, ctx) => { const { @@ -52,7 +52,7 @@ export default async function createPlugin( ``` Now the backend is ready to serve auth requests on the -`/api/auth/azure-easyAuth/refresh` endpoint. All that's left is to update the frontend +`/api/auth/azure-easyauth/refresh` endpoint. All that's left is to update the frontend sign-in mechanism to poll that endpoint through the IAP, on the user's behalf. ## Frontend Changes @@ -65,7 +65,7 @@ installed in `packages/app/src/App.tsx` like this: const app = createApp({ components: { -+ SignInPage: props => , ++ SignInPage: props => , ``` See the [Sign-In with Proxy Providers](../index.md#sign-in-with-proxy-providers) section for more information. diff --git a/plugins/auth-backend/src/providers/azure-easyauth/provider.test.ts b/plugins/auth-backend/src/providers/azure-easyauth/provider.test.ts index f9f0796f7a..b521ddeb10 100644 --- a/plugins/auth-backend/src/providers/azure-easyauth/provider.test.ts +++ b/plugins/auth-backend/src/providers/azure-easyauth/provider.test.ts @@ -256,7 +256,7 @@ describe('easyAuth factory', () => { }); expect(() => factory({} as any)).toThrow( - 'Authentication provider is not Azure Active Directory', + 'Authentication provider is not Azure Active Directory', ); }); diff --git a/plugins/auth-backend/src/providers/azure-easyauth/provider.ts b/plugins/auth-backend/src/providers/azure-easyauth/provider.ts index 8debc3afb6..405ca9ed59 100644 --- a/plugins/auth-backend/src/providers/azure-easyauth/provider.ts +++ b/plugins/auth-backend/src/providers/azure-easyauth/provider.ts @@ -178,25 +178,15 @@ function validateAppServiceConfiguration(env: NodeJS.ProcessEnv) { if (env.WEBSITE_SKU === undefined) { throw new Error('Backstage is not running on Azure App Services'); } - if (!isEqualCaseInsensitive(env.WEBSITE_AUTH_ENABLED, 'True')) { + if (env.WEBSITE_AUTH_ENABLED?.toLowerCase() !== 'true') { throw new Error('Azure App Services does not have authentication enabled'); } if ( - !isEqualCaseInsensitive( - env.WEBSITE_AUTH_DEFAULT_PROVIDER, - 'AzureActiveDirectory', - ) + env.WEBSITE_AUTH_DEFAULT_PROVIDER?.toLowerCase() !== 'azureactivedirectory' ) { - throw new Error('Authentication provider is not Azure Active Directory'); + throw new Error('Authentication provider is not Azure Active Directory'); } - if (!isEqualCaseInsensitive(process.env.WEBSITE_AUTH_TOKEN_STORE, 'True')) { + if (process.env.WEBSITE_AUTH_TOKEN_STORE?.toLowerCase() !== 'true') { throw new Error('Token Store is not enabled'); } } - -function isEqualCaseInsensitive(left: string | undefined, right: string) { - return ( - left !== undefined && - right.localeCompare(left, undefined, { sensitivity: 'base' }) === 0 - ); -}