mirror of
https://github.com/directus/directus.git
synced 2026-01-29 18:48:04 -05:00
Fix cookie return config
This commit is contained in:
@@ -37,10 +37,13 @@ const app = express()
|
||||
.use(logger())
|
||||
.use(bodyParser.json())
|
||||
.use(extractToken)
|
||||
|
||||
// the auth endpoints allow you to login/logout etc. It should ignore the authentication check
|
||||
.use('/auth', authRouter)
|
||||
|
||||
.use(authenticate)
|
||||
.use('/activity', activityRouter)
|
||||
.use('/assets', assetsRouter)
|
||||
.use('/auth', authRouter)
|
||||
.use('/collections', collectionsRouter)
|
||||
.use('/collection_presets', collectionPresetsRouter)
|
||||
.use('/extensions', extensionsRouter)
|
||||
|
||||
@@ -9,6 +9,7 @@ import { InvalidCredentialsException } from '../exceptions';
|
||||
* Verify the passed JWT and assign the user ID and role to `req`
|
||||
*/
|
||||
const authenticate: RequestHandler = asyncHandler(async (req, res, next) => {
|
||||
/** @todo base this on a validation middleware on permissions */
|
||||
if (!req.token) return next();
|
||||
|
||||
if (isJWT(req.token)) {
|
||||
|
||||
@@ -65,12 +65,11 @@ router.post(
|
||||
if (mode === 'cookie') {
|
||||
res.cookie('directus_refresh_token', refreshToken, {
|
||||
httpOnly: true,
|
||||
expires: refreshTokenExpiration,
|
||||
maxAge: ms(process.env.REFRESH_TOKEN_TTL) / 1000,
|
||||
maxAge: ms(process.env.REFRESH_TOKEN_TTL),
|
||||
secure: process.env.REFRESH_TOKEN_COOKIE_SECURE === 'true' ? true : false,
|
||||
sameSite:
|
||||
(process.env.REFRESH_TOKEN_COOKIE_SAME_SITE as 'lax' | 'strict' | 'none') ||
|
||||
'lax',
|
||||
'strict',
|
||||
});
|
||||
}
|
||||
|
||||
@@ -108,12 +107,11 @@ router.post(
|
||||
if (mode === 'cookie') {
|
||||
res.cookie('directus_refresh_token', refreshToken, {
|
||||
httpOnly: true,
|
||||
expires: refreshTokenExpiration,
|
||||
maxAge: ms(process.env.REFRESH_TOKEN_TTL) / 1000,
|
||||
maxAge: ms(process.env.REFRESH_TOKEN_TTL),
|
||||
secure: process.env.REFRESH_TOKEN_COOKIE_SECURE === 'true' ? true : false,
|
||||
sameSite:
|
||||
(process.env.REFRESH_TOKEN_COOKIE_SAME_SITE as 'lax' | 'strict' | 'none') ||
|
||||
'lax',
|
||||
'strict',
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user