Files
myeasycms-v2/apps/web/config/auth.config.ts
giancarlo 2acd9c7d10 Refactor mailer setup and validate web configuration in app
This commit refactors how SMTP configuration for mailers is set up and introduces schema validation for incoming configurations. The mailer modules have been restructured, with schema definition files added, and redundant codes removed. Moreover, web application configuration now has minimum validation on name and title, and URL validation has been added.
2024-03-27 14:10:53 +08:00

56 lines
1.0 KiB
TypeScript

import type { Provider } from '@supabase/gotrue-js';
import { z } from 'zod';
const providers: z.ZodType<Provider> = getProviders();
const AuthConfigSchema = z.object({
providers: z.object({
password: z.boolean({
description: 'Enable password authentication.',
}),
magicLink: z.boolean({
description: 'Enable magic link authentication.',
}),
oAuth: providers.array(),
}),
});
const authConfig = AuthConfigSchema.parse({
// NB: Enable the providers below in the Supabase Console
// in your production project
providers: {
password: true,
magicLink: false,
oAuth: ['google'],
},
});
export default authConfig;
function getProviders() {
return z.enum([
'apple',
'azure',
'bitbucket',
'discord',
'facebook',
'figma',
'github',
'gitlab',
'google',
'kakao',
'keycloak',
'linkedin',
'linkedin_oidc',
'notion',
'slack',
'spotify',
'twitch',
'twitter',
'workos',
'zoom',
'fly',
]);
}