1
0
mirror of https://github.com/bitwarden/server synced 2026-01-05 10:03:23 +00:00

Turn on file scoped namespaces (#2225)

This commit is contained in:
Justin Baur
2022-08-29 14:53:16 -04:00
committed by GitHub
parent 7c4521e0b4
commit 34fb4cca2a
1206 changed files with 73816 additions and 75022 deletions

View File

@@ -1,30 +1,29 @@
using Microsoft.AspNetCore.Http;
namespace Bit.Core.IdentityServer
namespace Bit.Core.IdentityServer;
public static class TokenRetrieval
{
public static class TokenRetrieval
private static string _headerScheme = "Bearer ";
private static string _queuryScheme = "access_token";
private static string _authHeader = "Authorization";
public static Func<HttpRequest, string> FromAuthorizationHeaderOrQueryString()
{
private static string _headerScheme = "Bearer ";
private static string _queuryScheme = "access_token";
private static string _authHeader = "Authorization";
public static Func<HttpRequest, string> FromAuthorizationHeaderOrQueryString()
return (request) =>
{
return (request) =>
var authorization = request.Headers[_authHeader].FirstOrDefault();
if (string.IsNullOrWhiteSpace(authorization))
{
var authorization = request.Headers[_authHeader].FirstOrDefault();
if (string.IsNullOrWhiteSpace(authorization))
{
return request.Query[_queuryScheme].FirstOrDefault();
}
return request.Query[_queuryScheme].FirstOrDefault();
}
if (authorization.StartsWith(_headerScheme, StringComparison.OrdinalIgnoreCase))
{
return authorization.Substring(_headerScheme.Length).Trim();
}
if (authorization.StartsWith(_headerScheme, StringComparison.OrdinalIgnoreCase))
{
return authorization.Substring(_headerScheme.Length).Trim();
}
return null;
};
}
return null;
};
}
}