mirror of
https://git.unistra.fr/aius/root/ldap-overleaf-sl.git
synced 2025-05-04 11:45:26 +02:00
Make the oauth2 state length configurable (#65)
* Increase state lenght to 8 * feat: make the state length configurable
This commit is contained in:
parent
f6aea77284
commit
0fd1a2765e
5 changed files with 8 additions and 2 deletions
|
@ -158,6 +158,8 @@ OAUTH2_TOKEN_URL: YOUR_OAUTH2_TOKEN_URL
|
||||||
# One of ["application/x-www-form-urlencoded", "application/json"]
|
# One of ["application/x-www-form-urlencoded", "application/json"]
|
||||||
# Default "application/x-www-form-urlencoded"
|
# Default "application/x-www-form-urlencoded"
|
||||||
OAUTH2_TOKEN_CONTENT_TYPE: "application/x-www-form-urlencoded"
|
OAUTH2_TOKEN_CONTENT_TYPE: "application/x-www-form-urlencoded"
|
||||||
|
# OAUTH2_STATE_LENGTH: Length of the OAuth2 state
|
||||||
|
OAUTH2_STATE_LENGTH: 6
|
||||||
# Fetch user profile api endpoint
|
# Fetch user profile api endpoint
|
||||||
OAUTH2_PROFILE_URL: YOUR_OAUTH2_PROFILE_URL
|
OAUTH2_PROFILE_URL: YOUR_OAUTH2_PROFILE_URL
|
||||||
|
|
||||||
|
|
|
@ -91,6 +91,7 @@ services:
|
||||||
# OAUTH2_AUTHORIZATION_URL: YOUR_OAUTH2_AUTHORIZATION_URL
|
# OAUTH2_AUTHORIZATION_URL: YOUR_OAUTH2_AUTHORIZATION_URL
|
||||||
# OAUTH2_TOKEN_URL: YOUR_OAUTH2_TOKEN_URL
|
# OAUTH2_TOKEN_URL: YOUR_OAUTH2_TOKEN_URL
|
||||||
# OAUTH2_TOKEN_CONTENT_TYPE: # One of ['application/x-www-form-urlencoded', 'application/json']
|
# OAUTH2_TOKEN_CONTENT_TYPE: # One of ['application/x-www-form-urlencoded', 'application/json']
|
||||||
|
# OAUTH2_STATE_LENGTH: Length of the OAuth2 state (default: 6)
|
||||||
# OAUTH2_PROFILE_URL: YOUR_OAUTH2_PROFILE_URL
|
# OAUTH2_PROFILE_URL: YOUR_OAUTH2_PROFILE_URL
|
||||||
# OAUTH2_USER_ATTR_EMAIL: email
|
# OAUTH2_USER_ATTR_EMAIL: email
|
||||||
# OAUTH2_USER_ATTR_UID: id
|
# OAUTH2_USER_ATTR_UID: id
|
||||||
|
|
|
@ -172,6 +172,7 @@ services:
|
||||||
# OAUTH2_AUTHORIZATION_URL: YOUR_OAUTH2_AUTHORIZATION_URL
|
# OAUTH2_AUTHORIZATION_URL: YOUR_OAUTH2_AUTHORIZATION_URL
|
||||||
# OAUTH2_TOKEN_URL: YOUR_OAUTH2_TOKEN_URL
|
# OAUTH2_TOKEN_URL: YOUR_OAUTH2_TOKEN_URL
|
||||||
# OAUTH2_TOKEN_CONTENT_TYPE: # One of ['application/x-www-form-urlencoded', 'application/json']
|
# OAUTH2_TOKEN_CONTENT_TYPE: # One of ['application/x-www-form-urlencoded', 'application/json']
|
||||||
|
# OAUTH2_STATE_LENGTH: Length of the OAuth2 state (default: 6)
|
||||||
# OAUTH2_PROFILE_URL: YOUR_OAUTH2_PROFILE_URL
|
# OAUTH2_PROFILE_URL: YOUR_OAUTH2_PROFILE_URL
|
||||||
# OAUTH2_USER_ATTR_EMAIL: email
|
# OAUTH2_USER_ATTR_EMAIL: email
|
||||||
# OAUTH2_USER_ATTR_UID: id
|
# OAUTH2_USER_ATTR_UID: id
|
||||||
|
|
|
@ -89,6 +89,7 @@ services:
|
||||||
# OAUTH2_AUTHORIZATION_URL: YOUR_OAUTH2_AUTHORIZATION_URL
|
# OAUTH2_AUTHORIZATION_URL: YOUR_OAUTH2_AUTHORIZATION_URL
|
||||||
# OAUTH2_TOKEN_URL: YOUR_OAUTH2_TOKEN_URL
|
# OAUTH2_TOKEN_URL: YOUR_OAUTH2_TOKEN_URL
|
||||||
# OAUTH2_TOKEN_CONTENT_TYPE: # One of ['application/x-www-form-urlencoded', 'application/json']
|
# OAUTH2_TOKEN_CONTENT_TYPE: # One of ['application/x-www-form-urlencoded', 'application/json']
|
||||||
|
# OAUTH2_STATE_LENGTH: Length of the OAuth2 state (default: 6)
|
||||||
# OAUTH2_PROFILE_URL: YOUR_OAUTH2_PROFILE_URL
|
# OAUTH2_PROFILE_URL: YOUR_OAUTH2_PROFILE_URL
|
||||||
# OAUTH2_USER_ATTR_EMAIL: email
|
# OAUTH2_USER_ATTR_EMAIL: email
|
||||||
# OAUTH2_USER_ATTR_UID: id
|
# OAUTH2_USER_ATTR_UID: id
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
268a268,364
|
268a269,366
|
||||||
>
|
>
|
||||||
> // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
> // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
||||||
> oauth2Redirect(req, res, next) {
|
> oauth2Redirect(req, res, next) {
|
||||||
> // random state
|
> // random state
|
||||||
> const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
|
> const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
|
||||||
> const state = new Array(6).fill(0).map(() => characters.charAt(Math.floor(Math.random() * characters.length))).join("")
|
> const stateLength = Number(process.env.OAUTH2_STATE_LENGTH || 6)
|
||||||
|
> const state = new Array(stateLength).fill(0).map(() => characters.charAt(Math.floor(Math.random() * characters.length))).join("")
|
||||||
> req.session.oauth2State = state
|
> req.session.oauth2State = state
|
||||||
>
|
>
|
||||||
> const redirectURI = encodeURIComponent(`${process.env.SHARELATEX_SITE_URL}/oauth/callback`)
|
> const redirectURI = encodeURIComponent(`${process.env.SHARELATEX_SITE_URL}/oauth/callback`)
|
||||||
|
|
Loading…
Add table
Reference in a new issue