mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-08 11:30:12 +08:00
feat: update swagger, secure cookie
This commit is contained in:
1 parent
d939b7eb4d
commit
d745531a14
5 files changed
+26
-4
No files matched your search
@@ -118,7 +118,9 @@ export function logout(req, res) {
|
|||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
res.redirect('/login')
|
res.status(200).json({
|
||||||
|
message: 'logged out',
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,5 +8,6 @@ export default {
|
|||||||
dockerNetwork: get('DOCKER_NETWORK', 'linux-odyssey-players'),
|
dockerNetwork: get('DOCKER_NETWORK', 'linux-odyssey-players'),
|
||||||
isProduction: process.env.NODE_ENV === 'production',
|
isProduction: process.env.NODE_ENV === 'production',
|
||||||
hostPwd: get('HOST_PWD', ''),
|
hostPwd: get('HOST_PWD', ''),
|
||||||
expiry: get('EXPIRY', 1000 * 60 * 60),
|
containerExpiry: get('EXPIRY', 1000 * 60 * 60),
|
||||||
|
sessionMaxAge: get('SESSION_MAX_AGE', 1000 * 60 * 60 * 24 * 7),
|
||||||
}
|
}
|
||||||
@@ -7,8 +7,12 @@ export default session({
|
|||||||
secret: config.jwtSecret,
|
secret: config.jwtSecret,
|
||||||
resave: false,
|
resave: false,
|
||||||
saveUninitialized: false,
|
saveUninitialized: false,
|
||||||
|
rolling: true,
|
||||||
cookie: {
|
cookie: {
|
||||||
httpOnly: true,
|
httpOnly: true,
|
||||||
|
secure: config.isProduction,
|
||||||
|
sameSite: 'strict',
|
||||||
|
maxAge: config.sessionMaxAge,
|
||||||
},
|
},
|
||||||
store: MongoStore.create({
|
store: MongoStore.create({
|
||||||
mongoUrl: config.db,
|
mongoUrl: config.db,
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ export function genJWT(payload) {
|
|||||||
jwt.sign(
|
jwt.sign(
|
||||||
payload,
|
payload,
|
||||||
config.jwtSecret,
|
config.jwtSecret,
|
||||||
{ expiresIn: config.expiry },
|
{ expiresIn: config.containerExpiry },
|
||||||
(err, token) => {
|
(err, token) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
reject(err)
|
reject(err)
|
||||||
|
|||||||
+16
-1
@@ -285,7 +285,7 @@ paths:
|
|||||||
type: string
|
type: string
|
||||||
example: Logged out successfully
|
example: Logged out successfully
|
||||||
|
|
||||||
/auth/check:
|
/auth/check-username:
|
||||||
get:
|
get:
|
||||||
summary: Check if the username is already taken
|
summary: Check if the username is already taken
|
||||||
parameters:
|
parameters:
|
||||||
@@ -319,6 +319,21 @@ paths:
|
|||||||
type: string
|
type: string
|
||||||
example: Username is already taken
|
example: Username is already taken
|
||||||
|
|
||||||
|
/auth/check-session:
|
||||||
|
get:
|
||||||
|
summary: Check if the session is valid
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: Result
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
loggedIn:
|
||||||
|
type: boolean
|
||||||
|
example: true
|
||||||
|
|
||||||
/quests:
|
/quests:
|
||||||
get:
|
get:
|
||||||
summary: Get quests list
|
summary: Get quests list
|
||||||
|
|||||||
Reference in new issue
Block a user