feat: add OAUTH_SCOPES to environment types and update authOptions for dynamic scope handling
This commit is contained in:
parent
1c897648f7
commit
3ac29ae909
@ -10,3 +10,4 @@ OAUTH_AUTHORIZATION_URL=
|
|||||||
OAUTH_TOKEN_URL=
|
OAUTH_TOKEN_URL=
|
||||||
OAUTH_USERINFO_URL=
|
OAUTH_USERINFO_URL=
|
||||||
OAUTH_JWKS_ENDPOINT=
|
OAUTH_JWKS_ENDPOINT=
|
||||||
|
OAUTH_SCOPES="openid email profile offline_access"
|
1
src/app/types/env.d.ts
vendored
1
src/app/types/env.d.ts
vendored
@ -8,5 +8,6 @@ declare namespace NodeJS {
|
|||||||
OAUTH_USERINFO_URL: string;
|
OAUTH_USERINFO_URL: string;
|
||||||
OAUTH_ISSUER: string;
|
OAUTH_ISSUER: string;
|
||||||
OAUTH_JWKS_ENDPOINT: string;
|
OAUTH_JWKS_ENDPOINT: string;
|
||||||
|
OAUTH_SCOPES: string;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
2
src/app/types/next-auth.d.ts
vendored
2
src/app/types/next-auth.d.ts
vendored
@ -56,7 +56,7 @@ declare module "next-auth/jwt" {
|
|||||||
accessToken: string;
|
accessToken: string;
|
||||||
accessTokenExpires: Moment;
|
accessTokenExpires: Moment;
|
||||||
refreshToken: string;
|
refreshToken: string;
|
||||||
refreshTokenExpires: Moment;
|
refreshTokenExpires: Moment | undefined;
|
||||||
error?: string;
|
error?: string;
|
||||||
user: User | AdapterUser;
|
user: User | AdapterUser;
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ export const authOptions: AuthOptions = {
|
|||||||
authorization: {
|
authorization: {
|
||||||
url: process.env.OAUTH_AUTHORIZATION_URL,
|
url: process.env.OAUTH_AUTHORIZATION_URL,
|
||||||
params: {
|
params: {
|
||||||
scope: "openid email profile",
|
scope: process.env.OAUTH_SCOPES,
|
||||||
response_type: "code",
|
response_type: "code",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -49,10 +49,11 @@ export const authOptions: AuthOptions = {
|
|||||||
token.refreshToken = account.refresh_token;
|
token.refreshToken = account.refresh_token;
|
||||||
|
|
||||||
token.accessTokenExpires = moment.unix(account.expires_at);
|
token.accessTokenExpires = moment.unix(account.expires_at);
|
||||||
token.refreshTokenExpires = moment().add(
|
|
||||||
account.refresh_expires_in,
|
token.refreshTokenExpires =
|
||||||
"seconds",
|
account.refresh_expires_in != 0
|
||||||
);
|
? moment().add(account.refresh_expires_in, "seconds")
|
||||||
|
: undefined;
|
||||||
|
|
||||||
const accessTokenDecode = jsonwebtoken.decode(
|
const accessTokenDecode = jsonwebtoken.decode(
|
||||||
account.access_token,
|
account.access_token,
|
||||||
|
Loading…
Reference in New Issue
Block a user