mirror of
https://github.com/bitwarden/server.git
synced 2024-12-24 17:17:40 +01:00
Accept "Content-Language" header for JWT token
This commit is contained in:
parent
27216efd1f
commit
16e5ba5a76
@ -11,14 +11,24 @@ namespace Bit.Api.Utilities
|
||||
{
|
||||
return (request) =>
|
||||
{
|
||||
string authorization = request.Headers["Authorization"].FirstOrDefault();
|
||||
var authorization = request.Headers["Authorization"].FirstOrDefault();
|
||||
|
||||
if(string.IsNullOrWhiteSpace(authorization))
|
||||
{
|
||||
// Bearer token could exist in the 'Content-Language' header on clients that want to avoid pre-flights.
|
||||
var languageAuth = request.Headers["Content-Language"].FirstOrDefault();
|
||||
if(string.IsNullOrWhiteSpace(languageAuth) ||
|
||||
!languageAuth.StartsWith($"{headerScheme} ", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return request.Query[qsName].FirstOrDefault();
|
||||
}
|
||||
else
|
||||
{
|
||||
authorization = languageAuth.Split(',')[0];
|
||||
}
|
||||
}
|
||||
|
||||
if(authorization.StartsWith(headerScheme + " ", StringComparison.OrdinalIgnoreCase))
|
||||
if(authorization.StartsWith($"{headerScheme} ", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return authorization.Substring(headerScheme.Length + 1).Trim();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user