auth-backend-module-microsoft-provider: avoid halting backend startup

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2024-09-12 13:21:27 +02:00
parent 3a196e0635
commit 339c67dc52
2 changed files with 12 additions and 6 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-auth-backend-module-guest-provider': patch
---
This provider will now reject authentication attempts rather than halt backend startup when `dangerouslyAllowOutsideDevelopment` is not set in production.
@@ -15,7 +15,7 @@
*/
import { createProxyAuthenticator } from '@backstage/plugin-auth-node';
import { NotImplementedError } from '@backstage/errors';
import { NotAllowedError } from '@backstage/errors';
export const guestAuthenticator = createProxyAuthenticator({
defaultProfileTransform: async () => {
@@ -25,13 +25,14 @@ export const guestAuthenticator = createProxyAuthenticator({
const allowOutsideDev = config.getOptionalBoolean(
'dangerouslyAllowOutsideDevelopment',
);
if (process.env.NODE_ENV !== 'development' && allowOutsideDev !== true) {
throw new NotImplementedError(
'The guest provider cannot be used outside of a development environment',
return process.env.NODE_ENV !== 'development' && allowOutsideDev !== true;
},
async authenticate(_, disabled) {
if (disabled) {
throw new NotAllowedError(
"The guest provider cannot be used outside of a development environment unless 'auth.providers.guest.dangerouslyAllowOutsideDevelopment' is enabled",
);
}
},
async authenticate() {
return { result: {} };
},
});