aboutsummaryrefslogtreecommitdiff
path: root/Jellyfin.Api/Auth/CustomAuthenticationHandler.cs
diff options
context:
space:
mode:
authorAnthony Lavado <anthony@lavado.ca>2020-08-08 13:22:36 -0400
committerGitHub <noreply@github.com>2020-08-08 13:22:36 -0400
commitb9fdbaeef326a06ba824cbb78a91f58afc535aab (patch)
tree915b3f9e787cde081af88465bf9c3f20228be3f3 /Jellyfin.Api/Auth/CustomAuthenticationHandler.cs
parent7e49358ba9c1fcf12f9e7b30601a9df568a65242 (diff)
parenta15be774ac606ec71f3ab0849a56ae08b8cc2f4d (diff)
Merge pull request #3812 from jellyfin/api-migration
Merge API Migration into master
Diffstat (limited to 'Jellyfin.Api/Auth/CustomAuthenticationHandler.cs')
-rw-r--r--Jellyfin.Api/Auth/CustomAuthenticationHandler.cs15
1 files changed, 13 insertions, 2 deletions
diff --git a/Jellyfin.Api/Auth/CustomAuthenticationHandler.cs b/Jellyfin.Api/Auth/CustomAuthenticationHandler.cs
index f86f75b1c..733c6959e 100644
--- a/Jellyfin.Api/Auth/CustomAuthenticationHandler.cs
+++ b/Jellyfin.Api/Auth/CustomAuthenticationHandler.cs
@@ -1,3 +1,4 @@
+using System.Globalization;
using System.Security.Authentication;
using System.Security.Claims;
using System.Text.Encodings.Web;
@@ -44,14 +45,24 @@ namespace Jellyfin.Api.Auth
var authorizationInfo = _authService.Authenticate(Request);
if (authorizationInfo == null)
{
- return Task.FromResult(AuthenticateResult.Fail("Invalid user"));
+ return Task.FromResult(AuthenticateResult.NoResult());
+ // TODO return when legacy API is removed.
+ // Don't spam the log with "Invalid User"
+ // return Task.FromResult(AuthenticateResult.Fail("Invalid user"));
}
var claims = new[]
{
new Claim(ClaimTypes.Name, authorizationInfo.User.Username),
- new Claim(ClaimTypes.Role, authorizationInfo.User.HasPermission(PermissionKind.IsAdministrator) ? UserRoles.Administrator : UserRoles.User)
+ new Claim(ClaimTypes.Role, authorizationInfo.User.HasPermission(PermissionKind.IsAdministrator) ? UserRoles.Administrator : UserRoles.User),
+ new Claim(InternalClaimTypes.UserId, authorizationInfo.UserId.ToString("N", CultureInfo.InvariantCulture)),
+ new Claim(InternalClaimTypes.DeviceId, authorizationInfo.DeviceId),
+ new Claim(InternalClaimTypes.Device, authorizationInfo.Device),
+ new Claim(InternalClaimTypes.Client, authorizationInfo.Client),
+ new Claim(InternalClaimTypes.Version, authorizationInfo.Version),
+ new Claim(InternalClaimTypes.Token, authorizationInfo.Token),
};
+
var identity = new ClaimsIdentity(claims, Scheme.Name);
var principal = new ClaimsPrincipal(identity);
var ticket = new AuthenticationTicket(principal, Scheme.Name);