Skip to content

Commit 6501038

Browse files
committed
PKCE workflow integration
1 parent ca3f7e2 commit 6501038

File tree

7 files changed

+583
-754
lines changed

7 files changed

+583
-754
lines changed

dev/src/app/(app)/page.tsx

Lines changed: 15 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -4,51 +4,26 @@ const Page = () => {
44
return (
55
<article className={["container"].filter(Boolean).join(" ")}>
66
<h1>
7-
Payload 3.0 <span className="rainbow">BETA</span>!
7+
<span className="rainbow">Payload Oauth2 Plugin</span>
88
</h1>
9-
<p>
10-
This BETA is rapidly evolving, you can report any bugs against{" "}
11-
<a
12-
href="https://github.com/payloadcms/payload-3.0-demo/issues"
13-
target="_blank"
14-
>
15-
the repo
16-
</a>{" "}
17-
or in the{" "}
18-
<a
19-
href="https://discord.com/channels/967097582721572934/1215659716538273832"
20-
target="_blank"
21-
>
22-
dedicated channel in Discord
23-
</a>
24-
.
25-
</p>
26-
9+
<p>Features</p>
10+
<ul>
11+
<li>✅ Compatible with Payload v3</li>
12+
<li>🔐 Configures OAuth2 with any providers</li>
13+
<li>✨ Zero dependencies</li>
14+
<li>⚙ Highly customizable</li>
15+
</ul>
2716
<p>
2817
<strong>
29-
Payload is running at <Link href="/admin">/admin</Link>
18+
You can check some <Link href="/admin">SSO examples here</Link>. Make
19+
sure to configure the OAuth2 plugin environment variables.
3020
</strong>
3121
</p>
32-
33-
<p>
34-
<Link href="/my-route" target="_blank">
35-
/my-route
36-
</Link>{" "}
37-
contains an example of a custom route running the Local API.
38-
</p>
39-
40-
<p>You can use the Local API in your server components like this:</p>
41-
<pre>
42-
<code>
43-
{`import { getPayload } from 'payload'
44-
import configPromise from "@payload-config";
45-
const payload = await getPayload({ config: configPromise })
46-
47-
const data = await payload.find({
48-
collection: 'posts',
49-
})`}
50-
</code>
51-
</pre>
22+
<small>
23+
<a href="https://github.com/payloadcms/payload" target="_blank">
24+
https://github.com/payloadcms/payload
25+
</a>{" "}
26+
</small>
5227
</article>
5328
);
5429
};

dev/src/payload-types.ts

Lines changed: 71 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -63,21 +63,23 @@ export type SupportedTimezones =
6363

6464
export interface Config {
6565
auth: {
66-
'local-users': LocalUserAuthOperations;
6766
users: UserAuthOperations;
67+
'local-users': LocalUserAuthOperations;
6868
};
6969
blocks: {};
7070
collections: {
71-
'local-users': LocalUser;
7271
users: User;
72+
'local-users': LocalUser;
73+
'payload-kv': PayloadKv;
7374
'payload-locked-documents': PayloadLockedDocument;
7475
'payload-preferences': PayloadPreference;
7576
'payload-migrations': PayloadMigration;
7677
};
7778
collectionsJoins: {};
7879
collectionsSelect: {
79-
'local-users': LocalUsersSelect<false> | LocalUsersSelect<true>;
8080
users: UsersSelect<false> | UsersSelect<true>;
81+
'local-users': LocalUsersSelect<false> | LocalUsersSelect<true>;
82+
'payload-kv': PayloadKvSelect<false> | PayloadKvSelect<true>;
8183
'payload-locked-documents': PayloadLockedDocumentsSelect<false> | PayloadLockedDocumentsSelect<true>;
8284
'payload-preferences': PayloadPreferencesSelect<false> | PayloadPreferencesSelect<true>;
8385
'payload-migrations': PayloadMigrationsSelect<false> | PayloadMigrationsSelect<true>;
@@ -89,18 +91,18 @@ export interface Config {
8991
globalsSelect: {};
9092
locale: null;
9193
user:
92-
| (LocalUser & {
93-
collection: 'local-users';
94-
})
9594
| (User & {
9695
collection: 'users';
96+
})
97+
| (LocalUser & {
98+
collection: 'local-users';
9799
});
98100
jobs: {
99101
tasks: unknown;
100102
workflows: unknown;
101103
};
102104
}
103-
export interface LocalUserAuthOperations {
105+
export interface UserAuthOperations {
104106
forgotPassword: {
105107
email: string;
106108
password: string;
@@ -118,7 +120,7 @@ export interface LocalUserAuthOperations {
118120
password: string;
119121
};
120122
}
121-
export interface UserAuthOperations {
123+
export interface LocalUserAuthOperations {
122124
forgotPassword: {
123125
email: string;
124126
password: string;
@@ -136,6 +138,16 @@ export interface UserAuthOperations {
136138
password: string;
137139
};
138140
}
141+
/**
142+
* This interface was referenced by `Config`'s JSON-Schema
143+
* via the `definition` "users".
144+
*/
145+
export interface User {
146+
id: number;
147+
email: string;
148+
updatedAt: string;
149+
createdAt: string;
150+
}
139151
/**
140152
* This interface was referenced by `Config`'s JSON-Schema
141153
* via the `definition` "local-users".
@@ -151,18 +163,31 @@ export interface LocalUser {
151163
hash?: string | null;
152164
loginAttempts?: number | null;
153165
lockUntil?: string | null;
166+
sessions?:
167+
| {
168+
id: string;
169+
createdAt?: string | null;
170+
expiresAt: string;
171+
}[]
172+
| null;
154173
password?: string | null;
155174
}
156175
/**
157176
* This interface was referenced by `Config`'s JSON-Schema
158-
* via the `definition` "users".
177+
* via the `definition` "payload-kv".
159178
*/
160-
export interface User {
179+
export interface PayloadKv {
161180
id: number;
162-
email: string;
163-
sub?: string | null;
164-
updatedAt: string;
165-
createdAt: string;
181+
key: string;
182+
data:
183+
| {
184+
[k: string]: unknown;
185+
}
186+
| unknown[]
187+
| string
188+
| number
189+
| boolean
190+
| null;
166191
}
167192
/**
168193
* This interface was referenced by `Config`'s JSON-Schema
@@ -171,23 +196,23 @@ export interface User {
171196
export interface PayloadLockedDocument {
172197
id: number;
173198
document?:
174-
| ({
175-
relationTo: 'local-users';
176-
value: number | LocalUser;
177-
} | null)
178199
| ({
179200
relationTo: 'users';
180201
value: number | User;
202+
} | null)
203+
| ({
204+
relationTo: 'local-users';
205+
value: number | LocalUser;
181206
} | null);
182207
globalSlug?: string | null;
183208
user:
184-
| {
185-
relationTo: 'local-users';
186-
value: number | LocalUser;
187-
}
188209
| {
189210
relationTo: 'users';
190211
value: number | User;
212+
}
213+
| {
214+
relationTo: 'local-users';
215+
value: number | LocalUser;
191216
};
192217
updatedAt: string;
193218
createdAt: string;
@@ -199,13 +224,13 @@ export interface PayloadLockedDocument {
199224
export interface PayloadPreference {
200225
id: number;
201226
user:
202-
| {
203-
relationTo: 'local-users';
204-
value: number | LocalUser;
205-
}
206227
| {
207228
relationTo: 'users';
208229
value: number | User;
230+
}
231+
| {
232+
relationTo: 'local-users';
233+
value: number | LocalUser;
209234
};
210235
key?: string | null;
211236
value?:
@@ -231,6 +256,15 @@ export interface PayloadMigration {
231256
updatedAt: string;
232257
createdAt: string;
233258
}
259+
/**
260+
* This interface was referenced by `Config`'s JSON-Schema
261+
* via the `definition` "users_select".
262+
*/
263+
export interface UsersSelect<T extends boolean = true> {
264+
email?: T;
265+
updatedAt?: T;
266+
createdAt?: T;
267+
}
234268
/**
235269
* This interface was referenced by `Config`'s JSON-Schema
236270
* via the `definition` "local-users_select".
@@ -245,16 +279,21 @@ export interface LocalUsersSelect<T extends boolean = true> {
245279
hash?: T;
246280
loginAttempts?: T;
247281
lockUntil?: T;
282+
sessions?:
283+
| T
284+
| {
285+
id?: T;
286+
createdAt?: T;
287+
expiresAt?: T;
288+
};
248289
}
249290
/**
250291
* This interface was referenced by `Config`'s JSON-Schema
251-
* via the `definition` "users_select".
292+
* via the `definition` "payload-kv_select".
252293
*/
253-
export interface UsersSelect<T extends boolean = true> {
254-
email?: T;
255-
sub?: T;
256-
updatedAt?: T;
257-
createdAt?: T;
294+
export interface PayloadKvSelect<T extends boolean = true> {
295+
key?: T;
296+
data?: T;
258297
}
259298
/**
260299
* This interface was referenced by `Config`'s JSON-Schema

0 commit comments

Comments
 (0)