< Summary - Jellyfin

Information
Class: Emby.Server.Implementations.HttpServer.Security.AuthService
Assembly: Emby.Server.Implementations
File(s): /srv/git/jellyfin/Emby.Server.Implementations/HttpServer/Security/AuthService.cs
Line coverage
100%
Covered lines: 2
Uncovered lines: 0
Coverable lines: 2
Total lines: 42
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%

File(s)

/srv/git/jellyfin/Emby.Server.Implementations/HttpServer/Security/AuthService.cs

#LineLine coverage
 1#pragma warning disable CS1591
 2
 3using System.Threading.Tasks;
 4using Jellyfin.Data.Enums;
 5using MediaBrowser.Controller.Net;
 6using Microsoft.AspNetCore.Http;
 7
 8namespace Emby.Server.Implementations.HttpServer.Security
 9{
 10    public class AuthService : IAuthService
 11    {
 12        private readonly IAuthorizationContext _authorizationContext;
 13
 14        public AuthService(
 15            IAuthorizationContext authorizationContext)
 16        {
 2117            _authorizationContext = authorizationContext;
 2118        }
 19
 20        public async Task<AuthorizationInfo> Authenticate(HttpRequest request)
 21        {
 22            var auth = await _authorizationContext.GetAuthorizationInfo(request).ConfigureAwait(false);
 23
 24            if (!auth.HasToken)
 25            {
 26                return auth;
 27            }
 28
 29            if (!auth.IsAuthenticated)
 30            {
 31                throw new SecurityException("Invalid token.");
 32            }
 33
 34            if (auth.User?.HasPermission(PermissionKind.IsDisabled) ?? false)
 35            {
 36                throw new SecurityException("User account has been disabled.");
 37            }
 38
 39            return auth;
 40        }
 41    }
 42}