feat: add ldap and oidc support (#1497)
Co-authored-by: Thomas Camlong <49837342+ajnart@users.noreply.github.com> Co-authored-by: Tagaishi <Tagaishi@hotmail.ch>
This commit is contained in:
46
src/utils/auth/index.ts
Normal file
46
src/utils/auth/index.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
import { DefaultSession } from 'next-auth';
|
||||
import { CredentialsConfig, OAuthConfig } from 'next-auth/providers';
|
||||
import { env } from '~/env';
|
||||
|
||||
export { default as adapter, onCreateUser } from './adapter';
|
||||
|
||||
/**
|
||||
* Module augmentation for `next-auth` types. Allows us to add custom properties to the `session`
|
||||
* object and keep type safety.
|
||||
*
|
||||
* @see https://next-auth.js.org/getting-started/typescript#module-augmentation
|
||||
*/
|
||||
declare module 'next-auth' {
|
||||
interface Session extends DefaultSession {
|
||||
user: DefaultSession['user'] & {
|
||||
id: string;
|
||||
isAdmin: boolean;
|
||||
colorScheme: 'light' | 'dark' | 'environment';
|
||||
autoFocusSearch: boolean;
|
||||
language: string;
|
||||
// ...other properties
|
||||
// role: UserRole;
|
||||
};
|
||||
}
|
||||
|
||||
interface User {
|
||||
isAdmin: boolean;
|
||||
isOwner?: boolean;
|
||||
// ...other properties
|
||||
// role: UserRole;
|
||||
}
|
||||
}
|
||||
|
||||
declare module 'next-auth/jwt' {
|
||||
interface JWT {
|
||||
id: string;
|
||||
isAdmin: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
export const providers: (CredentialsConfig | OAuthConfig<any>)[] = [];
|
||||
|
||||
if (env.AUTH_PROVIDER?.includes('ldap')) providers.push((await import('./ldap')).default);
|
||||
if (env.AUTH_PROVIDER?.includes('credentials'))
|
||||
providers.push((await import('./credentials')).default);
|
||||
if (env.AUTH_PROVIDER?.includes('oidc')) providers.push((await import('./oidc')).default);
|
||||
Reference in New Issue
Block a user