Skip to content

Commit 7927dd4

Browse files
authored
docs: adds auth example for useAPIKey and disableLocalStrategy (#3007)
1 parent 4233426 commit 7927dd4

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

docs/authentication/config.mdx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,22 @@ const response = await fetch("http://localhost:3000/api/pages", {
6363

6464
Payload ensures that the same, uniform access control is used across all authentication strategies. This enables you to utilize your existing access control configurations with both API keys and the standard email/password authentication. This consistency can aid in maintaining granular control over your API keys.
6565

66+
#### API Key *Only* Authentication
67+
68+
If you want to use API keys as the only authentication method for a collection, you can disable the default local strategy by setting `disableLocalStrategy` to `true` on the collection's `auth` property. This will disable the ability to authenticate with email and password, and will only allow for authentication via API key.
69+
70+
```ts
71+
import { CollectionConfig } from 'payload/types';
72+
73+
export const Customers: CollectionConfig = {
74+
slug: 'customers',
75+
auth: {
76+
useAPIKey: true,
77+
disableLocalStrategy: true,
78+
}
79+
};
80+
```
81+
6682
### Forgot Password
6783

6884
You can customize how the Forgot Password workflow operates with the following options on the `auth.forgotPassword` property:

0 commit comments

Comments
 (0)