|
1
|
import { CardList } from "docs-ui" |
|
2
|
|
|
3
|
export const metadata = { |
|
4
|
title: `Auth Module Provider`, |
|
5
|
} |
|
6
|
|
|
7
|
# {metadata.title} |
|
8
|
|
|
9
|
In this guide, you’ll learn about the Auth Module Provider and how it's used. |
|
10
|
|
|
11
|
## What is an Auth Module Provider? |
|
12
|
|
|
13
|
An Auth Module Provider handles authenticating customers and users, either using custom logic or by integrating a third-party service. |
|
14
|
|
|
15
|
For example, the EmailPass Auth Module Provider authenticates a user using their email and password, whereas the Google Auth Module Provider authenticates users using their Google account. |
|
16
|
|
|
17
|
### Auth Providers List |
|
18
|
|
|
19
|
<CardList |
|
20
|
items={[ |
|
21
|
{ |
|
22
|
title: "Emailpass", |
|
23
|
href: "/commerce-modules/auth/auth-providers/emailpass" |
|
24
|
}, |
|
25
|
{ |
|
26
|
title: "Google", |
|
27
|
href: "/commerce-modules/auth/auth-providers/google" |
|
28
|
}, |
|
29
|
{ |
|
30
|
title: "GitHub", |
|
31
|
href: "/commerce-modules/auth/auth-providers/github" |
|
32
|
}, |
|
33
|
]} |
|
34
|
/> |
|
35
|
|
|
36
|
--- |
|
37
|
|
|
38
|
## How to Create an Auth Module Provider? |
|
39
|
|
|
40
|
An Auth Module Provider is a module whose service extends the `AbstractAuthModuleProvider` imported from `@medusajs/framework/utils`. |
|
41
|
|
|
42
|
The module can have multiple auth provider services, where each is registered as a separate auth provider. |
|
43
|
|
|
44
|
Refer to the [Create Auth Module Provider](/references/auth/provider) guide to learn how to create an Auth Module Provider. |
|
45
|
|
|
46
|
--- |
|
47
|
|
|
48
|
## Configure Allowed Auth Providers of Actor Types |
|
49
|
|
|
50
|
By default, the `user` actor type is restricted to the `emailpass` provider. All other actor types (for example, `customer`) can authenticate with any installed Auth Module Provider unless you explicitly restrict them. |
|
51
|
|
|
52
|
To configure which auth providers are allowed for each actor type, use the [authMethodsPerActor option](!docs!/learn/configurations/medusa-config#httpauthMethodsPerActor) in Medusa's configurations: |
|
53
|
|
|
54
|
```ts title="medusa-config.ts" |
|
55
|
module.exports = defineConfig({ |
|
56
|
projectConfig: { |
|
57
|
http: { |
|
58
|
authMethodsPerActor: { |
|
59
|
user: ["emailpass", "google"], |
|
60
|
customer: ["emailpass"], |
|
61
|
}, |
|
62
|
// ... |
|
63
|
}, |
|
64
|
// ... |
|
65
|
}, |
|
66
|
}) |
|
67
|
``` |
|
68
|
|
|
69
|
<Note title="Important"> |
|
70
|
|
|
71
|
When you specify the `authMethodsPerActor` configuration, it overrides the default. So, if you don't specify any providers for an actor type, users of that actor type can't authenticate with any provider. |
|
72
|
|
|
73
|
</Note> |