Raw
1 ---
2 sidebar_label: "Module Options"
3 ---
4
5 import { Table } from "docs-ui"
6
7 export const metadata = {
8 title: `User Module Options`,
9 }
10
11 # {metadata.title}
12
13 In this guide, you'll learn about the options you can pass to the User Module.
14
15 ## Options Example
16
17 ```ts title="medusa-config.ts"
18 module.exports = defineConfig({
19 // ...
20 modules: [
21 {
22 resolve: "@medusajs/medusa/user",
23 options: {
24 jwt_secret: process.env.JWT_SECRET,
25 jwt_public_key: process.env.JWT_PUBLIC_KEY,
26 valid_duration: 60 * 60 * 24, // 24 hours
27 jwt_options: {
28 algorithm: process.env.JWT_ALGORITHM || "RS256",
29 issuer: process.env.JWT_ISSUER || "medusa",
30 },
31 jwt_verify_options: {
32 algorithms: [process.env.JWT_ALGORITHM || "RS256"],
33 issuer: process.env.JWT_ISSUER || "medusa",
34 },
35 },
36 },
37 ],
38 })
39 ```
40
41 ### Environment Variables
42
43 Make sure to add the necessary environment variables for the above options to your `.env` file:
44
45 ```bash
46 JWT_SECRET=supersecret
47 # Optional: For asymmetric key validation
48 JWT_PUBLIC_KEY=your_public_key_here
49 JWT_ALGORITHM=RS256
50 JWT_ISSUER=medusa
51 ```
52
53 ### All Options
54
55 <Table>
56 <Table.Header>
57 <Table.Row>
58 <Table.HeaderCell>
59 Option
60 </Table.HeaderCell>
61 <Table.HeaderCell>
62 Description
63 </Table.HeaderCell>
64 <Table.HeaderCell className="w-[15%]">
65 Required
66 </Table.HeaderCell>
67 <Table.HeaderCell className="w-[15%]">
68 Default
69 </Table.HeaderCell>
70 </Table.Row>
71 </Table.Header>
72 <Table.Body>
73 <Table.Row>
74 <Table.Cell>
75
76 `jwt_secret`
77
78 </Table.Cell>
79 <Table.Cell>
80
81 A string indicating the secret used to sign the invite tokens.
82
83 </Table.Cell>
84 <Table.Cell>
85
86 Yes
87
88 </Table.Cell>
89 <Table.Cell>
90
91 \-
92
93 </Table.Cell>
94 </Table.Row>
95 <Table.Row>
96 <Table.Cell>
97
98 `jwt_public_key`
99
100 </Table.Cell>
101 <Table.Cell>
102
103 A string indicating the public key used to verify JWT tokens when using asymmetric validation. Only used when the JWT secret is a private key for asymmetric signing.
104
105 Learn more in the [Asymmetric Encryption](!docs!/learn/configurations/medusa-config/asymmetric-encryption) guide.
106
107 </Table.Cell>
108 <Table.Cell>
109
110 No
111
112 </Table.Cell>
113 <Table.Cell>
114
115 \-
116
117 </Table.Cell>
118 </Table.Row>
119 <Table.Row>
120 <Table.Cell>
121
122 `valid_duration`
123
124 </Table.Cell>
125 <Table.Cell>
126
127 A number indicating the duration in seconds that an invite token is valid. This is used to set the expiration time for invite tokens.
128
129 </Table.Cell>
130 <Table.Cell>
131
132 No
133
134 </Table.Cell>
135 <Table.Cell>
136
137 `86400` seconds (`1` day)
138
139 </Table.Cell>
140 </Table.Row>
141 <Table.Row>
142 <Table.Cell>
143
144 `jwt_options`
145
146 </Table.Cell>
147 <Table.Cell>
148
149 An object containing options for signing JWT tokens when using asymmetric signing with a private/public key pair. Accepts any options from [jsonwebtoken's SignOptions](https://github.com/auth0/node-jsonwebtoken#usage), such as `algorithm`. If `expiresIn` is provided here, it will be used as a fallback if `valid_duration` is not set.
150
151 Learn more in the [Asymmetric Encryption](!docs!/learn/configurations/medusa-config/asymmetric-encryption) guide.
152
153 </Table.Cell>
154 <Table.Cell>
155
156 No
157
158 </Table.Cell>
159 <Table.Cell>
160
161 `{}`
162
163 </Table.Cell>
164 </Table.Row>
165 <Table.Row>
166 <Table.Cell>
167
168 `jwt_verify_options`
169
170 </Table.Cell>
171 <Table.Cell>
172
173 An object containing options for verifying JWT tokens when using asymmetric validation with a private/public key pair. Accepts any options from [jsonwebtoken's VerifyOptions](https://github.com/auth0/node-jsonwebtoken#jwtverifytoken-secretorpublickey-options-callback), such as `algorithms`. If not provided, the `jwt_options` will be used for verification.
174
175 Learn more in the [Asymmetric Encryption](!docs!/learn/configurations/medusa-config/asymmetric-encryption) guide.
176
177 </Table.Cell>
178 <Table.Cell>
179
180 No
181
182 </Table.Cell>
183 <Table.Cell>
184
185 Value of `jwt_options`
186
187 </Table.Cell>
188 </Table.Row>
189 </Table.Body>
190 </Table>
191