mirror of
https://github.com/bitwarden/server.git
synced 2025-07-03 17:12:49 -05:00
move TokenRetrieval to api
This commit is contained in:
@ -1,30 +0,0 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace Bit.Core.IdentityServer
|
||||
{
|
||||
public static class TokenRetrieval
|
||||
{
|
||||
public static Func<HttpRequest, string> FromAuthorizationHeaderOrQueryString(string headerScheme = "Bearer",
|
||||
string qsName = "account_token")
|
||||
{
|
||||
return (request) =>
|
||||
{
|
||||
string authorization = request.Headers["Authorization"].FirstOrDefault();
|
||||
|
||||
if(string.IsNullOrWhiteSpace(authorization))
|
||||
{
|
||||
return request.Query[qsName].FirstOrDefault();
|
||||
}
|
||||
|
||||
if(authorization.StartsWith(headerScheme + " ", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return authorization.Substring(headerScheme.Length + 1).Trim();
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user