-
Notifications
You must be signed in to change notification settings - Fork 0
/
auth.js
60 lines (56 loc) · 2.72 KB
/
auth.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import NextAuth from "next-auth";
// export const { handlers, signIn, signOut, auth } = NextAuth(request, {
// providers: [
// {
// id: "my-auth-server", // signIn("my-provider") and will be part of the callback URL
// name: "My auth server", // optional, used on the default login page as the button text.
// type: "oidc", // or "oauth" for OAuth 2 providers
// issuer: "http://localhost:8090", // to infer the .well-known/openid-configuration URL
// authorization: 'http://localhost:8090/oauth2/authorize',
// token: 'http://localhost:8090/oauth2/token',
// clientId: process.env.AUTH_CLIENT_ID, // from the provider's dashboard
// clientSecret: process.env.AUTH_CLIENT_SECRET, // from the provider's dashboard
// }
// ],
// });
/*export const { handlers, signIn, signOut, auth } = NextAuth(request => {
//console.log(request);
console.log(this);
return {
providers: [
{
id: "my-auth-server", // signIn("my-provider") and will be part of the callback URL
name: "My auth server", // optional, used on the default login page as the button text.
type: "oidc", // or "oauth" for OAuth 2 providers
issuer: "http://localhost:8090", // to infer the .well-known/openid-configuration URL
authorization: 'http://localhost:8090/oauth2/authorize',
token: 'http://localhost:8090/oauth2/token',
clientId: process.env.AUTH_CLIENT_ID, // from the provider's dashboard
clientSecret: process.env.AUTH_CLIENT_SECRET, // from the provider's dashboard
}
],
}
});*/
export const { handlers, signIn, signOut, auth } = NextAuth(function config(request) {
console.log(auth);
if (!auth) {
return signIn("my-auth-server");
}
return {
providers: [
{
id: "my-auth-server", // signIn("my-provider") and will be part of the callback URL
name: "My auth server", // optional, used on the default login page as the button text.
type: "oidc", // or "oauth" for OAuth 2 providers
issuer: "http://localhost:8090", // to infer the .well-known/openid-configuration URL
authorization: 'http://localhost:8090/oauth2/authorize',
token: 'http://localhost:8090/oauth2/token',
clientId: process.env.AUTH_CLIENT_ID, // from the provider's dashboard
clientSecret: process.env.AUTH_CLIENT_SECRET, // from the provider's dashboard
}
],
trustHost: true,
secret: process.env.AUTH_SECRET,
basePath: "/auth"
}
});