I can't believe it but I have sign in with Microsoft working!
This commit is contained in:
29
packages/backend/convex/custom/auth/providers/entra.ts
Normal file
29
packages/backend/convex/custom/auth/providers/entra.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { type AuthProviderMaterializedConfig } from '@convex-dev/auth/server';
|
||||
|
||||
export const Entra: AuthProviderMaterializedConfig = {
|
||||
id: 'microsoft-entra-id',
|
||||
name: 'Microsoft Entra ID',
|
||||
type: 'oauth',
|
||||
issuer: process.env.AUTH_MICROSOFT_ENTRA_ID_ISSUER!,
|
||||
client: {
|
||||
id: process.env.AUTH_MICROSOFT_ENTRA_ID_ID!,
|
||||
secret: process.env.AUTH_MICROSOFT_ENTRA_ID_SECRET!,
|
||||
},
|
||||
authorization: {
|
||||
url: process.env.AUTH_MICROSOFT_ENTRA_ID_AUTH_URL!,
|
||||
params: {
|
||||
scope: 'openid profile email offline_access',
|
||||
response_type: 'code',
|
||||
},
|
||||
},
|
||||
token:
|
||||
'https://login.microsoftonline.com/16200986-86f1-44d2-974c-cfa99352722c/oauth2/v2.0/token',
|
||||
userinfo: 'https://graph.microsoft.com/oidc/userinfo',
|
||||
profile(profile) {
|
||||
return {
|
||||
id: profile.sub,
|
||||
name: profile.name,
|
||||
email: profile.email,
|
||||
};
|
||||
},
|
||||
};
|
18
packages/backend/convex/custom/auth/providers/password.ts
Normal file
18
packages/backend/convex/custom/auth/providers/password.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { ConvexError } from 'convex/values';
|
||||
import { Password as DefaultPassword } from '@convex-dev/auth/providers/Password';
|
||||
import { validatePassword } from '../password/validate';
|
||||
import type { DataModel } from '../../../_generated/dataModel';
|
||||
|
||||
export const Password = DefaultPassword<DataModel>({
|
||||
profile(params, ctx) {
|
||||
return {
|
||||
email: params.email as string,
|
||||
name: params.name as string,
|
||||
};
|
||||
},
|
||||
validatePasswordRequirements: (password: string) => {
|
||||
if (!validatePassword(password)) {
|
||||
throw new ConvexError('Invalid password.');
|
||||
}
|
||||
},
|
||||
});
|
Reference in New Issue
Block a user