1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-18 16:11:28 -05:00

remove old token retrieval schemes

This commit is contained in:
Kyle Spearrin
2018-01-03 14:11:56 -05:00
parent 3251c4b574
commit f61acdd3b9
3 changed files with 1 additions and 59 deletions

View File

@ -1,42 +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[] authHeaderSchemes)
{
return (request) =>
{
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("Bearer ", StringComparison.OrdinalIgnoreCase))
{
return request.Query["access_token"].FirstOrDefault();
}
else
{
authorization = languageAuth.Split(',')[0];
}
}
foreach(var headerScheme in authHeaderSchemes)
{
if(authorization.StartsWith($"{headerScheme} ", StringComparison.OrdinalIgnoreCase))
{
return authorization.Substring(headerScheme.Length + 1).Trim();
}
}
return null;
};
}
}
}