1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-08-23 13:46:45 +02:00

feat: custom unleash auth header

This commit is contained in:
Fredrik Oseberg 2023-12-07 11:19:58 +01:00
parent 38d02e1a85
commit 3d25d1aaff
No known key found for this signature in database
GPG Key ID: 816A423246CADD4E
2 changed files with 7 additions and 2 deletions

View File

@ -48,7 +48,12 @@ const apiAccessMiddleware = (
}
try {
const apiToken = req.header('authorization');
const apiToken = req.header('x-unleash-auth')
? req.header('x-unleash-auth')
: req.header('authorization');
console.log('TOKEN', apiToken, req.headers);
if (!apiToken?.startsWith('user:')) {
const apiUser = apiToken
? apiTokenService.getUserForToken(apiToken)

View File

@ -20,7 +20,7 @@ const authorizationMiddleware = (
if (req.user) {
return next();
}
if (req.header('authorization')) {
if (req.header('x-unleash-auth') || req.header('authorization')) {
// API clients should get 401 with a basic body
const error = new UnauthorizedError(
'You must log in to use Unleash.',