Implemented basic header auth controller

pull/4510/head
Francesco Servida 3 years ago
parent 90171f9bb2
commit ce175a8632
No known key found for this signature in database
GPG Key ID: 653390DF958E310B

@ -272,5 +272,37 @@ namespace Ombi.Controllers.V1
return ip; return ip;
} }
[HttpPost("header_auth")]
[ProducesResponseType(401)]
public async Task<IActionResult> HeaderAuth()
{
string username = null;
// Check if Header Auth is enabled and Proxy IP is trusted
// TODO
// var ombiSettings = await repo.GetSettingsAsync();
// END TODO
if (Request.HttpContext?.Request?.Headers != null && Request.HttpContext.Request.Headers.ContainsKey("X-Remote-User"))
{
username = Request.HttpContext.Request.Headers["X-Remote-User"].ToString();
// Check if user exists
var user = await _userManager.FindByNameAsync(username);
if (user == null)
{
return new UnauthorizedResult();
}
return await CreateToken(true, user);
}
else
{
return new UnauthorizedResult();
}
}
} }
} }

Loading…
Cancel
Save