1
0
Fork 0
mirror of https://github.com/zigzap/zap.git synced 2025-10-21 07:34:08 +00:00

Basic Auth now accepts Authorization header

This commit is contained in:
Rene Schallner 2023-05-01 05:58:11 +02:00
parent d0c59ab008
commit 5a942869a9

View file

@ -170,10 +170,16 @@ pub fn BasicAuth(comptime Lookup: type, comptime kind: BasicAuthStrategy) type {
pub fn authenticateRequest(self: *Self, r: *const zap.SimpleRequest) bool { pub fn authenticateRequest(self: *Self, r: *const zap.SimpleRequest) bool {
zap.debug("AUTHENTICATE REQUEST\n", .{}); zap.debug("AUTHENTICATE REQUEST\n", .{});
if (extractAuthHeader(.Basic, r)) |auth_header| { if (extractAuthHeader(.Basic, r)) |auth_header| {
zap.debug("Auth Header found!\n", .{}); zap.debug("Authentication Header found!\n", .{});
return self.authenticate(auth_header); return self.authenticate(auth_header);
} else {
// try with .Authorization
if (extractAuthHeader(.Bearer, r)) |auth_header| {
zap.debug("Authorization Header found!\n", .{});
return self.authenticate(auth_header);
}
} }
zap.debug("NO Auth Header found!\n", .{}); zap.debug("NO fitting Auth Header found!\n", .{});
return false; return false;
} }
}; };