Commit 456937ad authored by Benedikt Heinrichs's avatar Benedikt Heinrichs
Browse files

Fix the Bearer Authorization

parent d9412715
......@@ -112,7 +112,7 @@ namespace Coscine.Api.Project.Tests
request.SetupGet(x => x.Headers).Returns(
new HeaderDictionary {
{"X-Requested-With", "XMLHttpRequest"},
{"bearer", jwtHandler.GenerateJwtToken(values)}
{"Authorization", "Bearer " + jwtHandler.GenerateJwtToken(values)}
}
);
......
......@@ -33,9 +33,18 @@ namespace Coscine.Api.Project
public User GetUserFromToken()
{
var bearer = _controller.Request.Headers["bearer"];
var authorization = _controller.Request.Headers["Authorization"].ToArray();
string bearer = null;
foreach (var line in authorization)
{
if (line.Contains("Bearer"))
{
bearer = line;
}
}
if (!string.IsNullOrWhiteSpace(bearer))
{
bearer = bearer.Replace("Bearer", "").Trim();
JWTHandler jwtHandler = new JWTHandler(Program.Configuration);
var claims = jwtHandler.GetContents(bearer);
var userClaim = (from claimObj in claims
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment