Make auth cookies secure and strict
an admin panel should have high auth cookie security. Signed-off-by: r3g_5z <june@girlboss.ceo>
This commit is contained in:
parent
56f6210b6a
commit
c136a5227f
1 changed files with 4 additions and 4 deletions
|
@ -1,14 +1,14 @@
|
|||
import Cookies from 'js-cookie'
|
||||
|
||||
const TokenKey = 'Admin-Token'
|
||||
const AuthHostKey = 'Auth-Host'
|
||||
const TokenKey = process.env.NODE_ENV === 'production' ? '__Host-Admin-Token' : 'Admin-Token'
|
||||
const AuthHostKey = process.env.NODE_ENV === 'production' ? '__Host-Auth-Host' : 'Auth-Host'
|
||||
|
||||
export function getToken() {
|
||||
return Cookies.get(TokenKey)
|
||||
}
|
||||
|
||||
export function setToken(token) {
|
||||
return Cookies.set(TokenKey, token)
|
||||
return process.env.NODE_ENV === 'production' ? Cookies.set(TokenKey, token, { secure: true, sameSite: 'strict' }) : Cookies.set(TokenKey, token)
|
||||
}
|
||||
|
||||
export function removeToken() {
|
||||
|
@ -20,7 +20,7 @@ export function getAuthHost() {
|
|||
}
|
||||
|
||||
export function setAuthHost(token) {
|
||||
return Cookies.set(AuthHostKey, token)
|
||||
return process.env.NODE_ENV === 'production' ? Cookies.set(AuthHostKey, token, { secure: true, sameSite: 'strict' }) : Cookies.set(AuthHostKey, token)
|
||||
}
|
||||
|
||||
export function removeAuthHost() {
|
||||
|
|
Loading…
Reference in a new issue