Last active
November 24, 2023 14:07
-
-
Save toniengelhardt/f16669979e609d68bfb2c54dd8a488e7 to your computer and use it in GitHub Desktop.
nuxt-alt/auth config for Django backend w/ simple-jwt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
auth: { | |
globalMiddleware: true, | |
redirectStrategy: 'query', // IMPORTANT! Otherwise, there will be an infinite logout loop. | |
watchLoggedIn: true, | |
cookie: { | |
prefix: 'auth.', | |
options: { | |
path: '/', | |
secure: process.env.NODE_ENV === 'production', // Enable only in production. | |
sameSite: 'lax', // IMPORTANT! | |
}, | |
}, | |
redirect: { | |
login: '/login', | |
logout: '/login', | |
callback: '/login', | |
home: '/', | |
}, | |
strategies: { | |
local: { | |
scheme: 'refresh', | |
token: { | |
property: 'access', | |
type: 'JWT', | |
}, | |
refreshToken: { | |
property: 'refresh', | |
data: 'refresh', // IMPORTANT! Note that the refresh token is not a JWT token. | |
}, | |
user: { | |
property: false, | |
}, | |
endpoints: { | |
login: { | |
url: `${process.env.API_URL}/auth/token/`, | |
method: 'post', | |
}, | |
refresh: { | |
url: `${process.env.API_URL}/auth/token/refresh/`, | |
method: 'post', | |
}, | |
user: false, | |
logout: { | |
url: `${process.env.API_URL}/auth/logout/`, | |
method: 'post', | |
}, | |
}, | |
}, | |
google: { | |
clientId: process.env.GOOGLE_CLIENT_ID, | |
responseType: 'code', | |
codeChallengeMethod: '', // This is important! | |
endpoints: { | |
scope: ['openid', 'profile', 'email'], | |
token: `${process.env.API_URL}/auth/social/google/`, | |
userInfo: `${process.env.API_URL}/users/me/`, | |
}, | |
token: { | |
// The token type needs to match the AUTH_HEADER_TYPES setting under | |
// SIMPLE_JWT in the Django settings (Bearer by default). | |
type: 'JWT', | |
property: 'access', | |
}, | |
refreshToken: { | |
// The refresh token is not a JWT token! | |
property: 'refresh', | |
}, | |
}, | |
}, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment