guest-provider: Error if used outside of dev env
This will spare us one warning when running with `NODE_ENV !== 'development'` Signed-off-by: Nikolai Røed Kristiansen <nikolai.kristiansen@remarkable.no>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-auth-backend-module-guest-provider': patch
|
||||
---
|
||||
|
||||
Error if used outside of a development environment
|
||||
@@ -15,12 +15,22 @@
|
||||
*/
|
||||
|
||||
import { createProxyAuthenticator } from '@backstage/plugin-auth-node';
|
||||
import { NotImplementedError } from '@backstage/errors';
|
||||
|
||||
export const guestAuthenticator = createProxyAuthenticator({
|
||||
defaultProfileTransform: async () => {
|
||||
return { profile: {} };
|
||||
},
|
||||
initialize() {},
|
||||
initialize({ config }) {
|
||||
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',
|
||||
);
|
||||
}
|
||||
},
|
||||
async authenticate() {
|
||||
return { result: {} };
|
||||
},
|
||||
|
||||
@@ -31,16 +31,10 @@ export const authModuleGuestProvider = createBackendModule({
|
||||
register(reg) {
|
||||
reg.registerInit({
|
||||
deps: {
|
||||
logger: coreServices.logger,
|
||||
providers: authProvidersExtensionPoint,
|
||||
config: coreServices.rootConfig,
|
||||
},
|
||||
async init({ providers, logger, config }) {
|
||||
if (process.env.NODE_ENV !== 'development') {
|
||||
logger.warn(
|
||||
'You should NOT be using the guest provider outside of a development environment.',
|
||||
);
|
||||
}
|
||||
async init({ providers, config }) {
|
||||
providers.registerProvider({
|
||||
providerId: 'guest',
|
||||
factory: createProxyAuthProviderFactory({
|
||||
|
||||
Reference in New Issue
Block a user