mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-19 12:59:39 -07:00
Implemented basic header auth controller
This commit is contained in:
parent
90171f9bb2
commit
ce175a8632
1 changed files with 32 additions and 0 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue