< 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
81%
Covered lines: 9
Uncovered lines: 2
Coverable lines: 11
Total lines: 43
Line coverage: 81.8%
Branch coverage
62%
Covered branches: 5
Total branches: 8
Branch coverage: 62.5%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100 1/23/2026 - 12:11:06 AM Line coverage: 100% (2/2) Total lines: 434/19/2026 - 12:14:27 AM Line coverage: 81.8% (9/11) Branch coverage: 62.5% (5/8) Total lines: 43 4/19/2026 - 12:14:27 AM Line coverage: 81.8% (9/11) Branch coverage: 62.5% (5/8) Total lines: 43

Coverage delta

Coverage delta 19 -19

Metrics

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

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;
 5using Jellyfin.Database.Implementations.Enums;
 6using MediaBrowser.Controller.Net;
 7using Microsoft.AspNetCore.Http;
 8
 9namespace Emby.Server.Implementations.HttpServer.Security
 10{
 11    public class AuthService : IAuthService
 12    {
 13        private readonly IAuthorizationContext _authorizationContext;
 14
 15        public AuthService(
 16            IAuthorizationContext authorizationContext)
 17        {
 2018            _authorizationContext = authorizationContext;
 2019        }
 20
 21        public async Task<AuthorizationInfo> Authenticate(HttpRequest request)
 22        {
 17023            var auth = await _authorizationContext.GetAuthorizationInfo(request).ConfigureAwait(false);
 24
 17025            if (!auth.HasToken)
 26            {
 7427                return auth;
 28            }
 29
 9630            if (!auth.IsAuthenticated)
 31            {
 032                throw new SecurityException("Invalid token.");
 33            }
 34
 9635            if (auth.User?.HasPermission(PermissionKind.IsDisabled) ?? false)
 36            {
 037                throw new SecurityException("User account has been disabled.");
 38            }
 39
 9640            return auth;
 17041        }
 42    }
 43}