mirror of
https://github.com/Unleash/unleash.git
synced 2025-08-27 13:49:10 +02:00
feat: custom unleash auth header
This commit is contained in:
parent
38d02e1a85
commit
3d25d1aaff
@ -48,7 +48,12 @@ const apiAccessMiddleware = (
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
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:')) {
|
if (!apiToken?.startsWith('user:')) {
|
||||||
const apiUser = apiToken
|
const apiUser = apiToken
|
||||||
? apiTokenService.getUserForToken(apiToken)
|
? apiTokenService.getUserForToken(apiToken)
|
||||||
|
@ -20,7 +20,7 @@ const authorizationMiddleware = (
|
|||||||
if (req.user) {
|
if (req.user) {
|
||||||
return next();
|
return next();
|
||||||
}
|
}
|
||||||
if (req.header('authorization')) {
|
if (req.header('x-unleash-auth') || req.header('authorization')) {
|
||||||
// API clients should get 401 with a basic body
|
// API clients should get 401 with a basic body
|
||||||
const error = new UnauthorizedError(
|
const error = new UnauthorizedError(
|
||||||
'You must log in to use Unleash.',
|
'You must log in to use Unleash.',
|
||||||
|
Loading…
Reference in New Issue
Block a user