@@ -7,7 +7,7 @@ import NextAuth from 'next-auth';
77import type { Provider } from 'next-auth/providers' ;
88
99import { getProviderConstructor } from '#app/(auth)/providers/providers.ts' ;
10- import { OIDC_ENABLED } from '#utils/constants .ts' ;
10+ import { runtimeConfig } from '#contexts/App/runtime-config .ts' ;
1111import { routes } from '#utils/router.ts' ;
1212
1313import type { ProviderConfig } from './types' ;
@@ -19,7 +19,9 @@ const providers: Provider[] = [];
1919
2020export const AUTH_COOKIE_NAME = 'beeai-platform' ;
2121
22- if ( OIDC_ENABLED ) {
22+ const { isAuthEnabled } = runtimeConfig ;
23+
24+ if ( isAuthEnabled ) {
2325 try {
2426 const providersJson = process . env . OIDC_PROVIDERS ;
2527 if ( ! providersJson ) {
@@ -68,7 +70,7 @@ export const { handlers, signIn, signOut, auth } = NextAuth({
6870 session : { strategy : 'jwt' } ,
6971 trustHost : true ,
7072 // Prevents nextauth errors when authentication is disabled and NEXTAUTH_SECRET is not provided
71- secret : OIDC_ENABLED ? process . env . NEXTAUTH_SECRET : 'dummy_secret' ,
73+ secret : isAuthEnabled ? process . env . NEXTAUTH_SECRET : 'dummy_secret' ,
7274 cookies : {
7375 sessionToken : {
7476 name : AUTH_COOKIE_NAME ,
@@ -81,7 +83,7 @@ export const { handlers, signIn, signOut, auth } = NextAuth({
8183 } ,
8284 callbacks : {
8385 authorized : ( { auth } ) => {
84- return OIDC_ENABLED ? Boolean ( auth ) : true ;
86+ return isAuthEnabled ? Boolean ( auth ) : true ;
8587 } ,
8688 jwt : async ( { token, account, trigger, session } ) => {
8789 if ( trigger === 'update' ) {
0 commit comments