aboutsummaryrefslogtreecommitdiff
path: root/Jellyfin.Server.Implementations/Security/AuthorizationContext.cs
diff options
context:
space:
mode:
authorCody Robibero <cody@robibe.ro>2023-10-10 15:58:51 -0600
committerCody Robibero <cody@robibe.ro>2023-10-10 15:59:34 -0600
commit6bd6fb6e0a4828cc5cb16a4e48a8fba20a7d6305 (patch)
tree208e41ce44cb66107843dd2fdb80cbe673bc1240 /Jellyfin.Server.Implementations/Security/AuthorizationContext.cs
parentbc88c96cbe13301ee6e5f6a2d688a4c90338281d (diff)
parent74f61fbd79ef2e2ad4a986f5f886581b2827de07 (diff)
Merge branch 'master' into chromecast-config
# Conflicts: # Emby.Server.Implementations/ApplicationHost.cs
Diffstat (limited to 'Jellyfin.Server.Implementations/Security/AuthorizationContext.cs')
-rw-r--r--Jellyfin.Server.Implementations/Security/AuthorizationContext.cs30
1 files changed, 5 insertions, 25 deletions
diff --git a/Jellyfin.Server.Implementations/Security/AuthorizationContext.cs b/Jellyfin.Server.Implementations/Security/AuthorizationContext.cs
index 700e63970..77f8f7071 100644
--- a/Jellyfin.Server.Implementations/Security/AuthorizationContext.cs
+++ b/Jellyfin.Server.Implementations/Security/AuthorizationContext.cs
@@ -49,14 +49,13 @@ namespace Jellyfin.Server.Implementations.Security
/// <summary>
/// Gets the authorization.
/// </summary>
- /// <param name="httpReq">The HTTP req.</param>
+ /// <param name="httpContext">The HTTP context.</param>
/// <returns>Dictionary{System.StringSystem.String}.</returns>
- private async Task<AuthorizationInfo> GetAuthorization(HttpContext httpReq)
+ private async Task<AuthorizationInfo> GetAuthorization(HttpContext httpContext)
{
- var auth = GetAuthorizationDictionary(httpReq);
- var authInfo = await GetAuthorizationInfoFromDictionary(auth, httpReq.Request.Headers, httpReq.Request.Query).ConfigureAwait(false);
+ var authInfo = await GetAuthorizationInfo(httpContext.Request).ConfigureAwait(false);
- httpReq.Request.HttpContext.Items["AuthorizationInfo"] = authInfo;
+ httpContext.Request.HttpContext.Items["AuthorizationInfo"] = authInfo;
return authInfo;
}
@@ -80,7 +79,6 @@ namespace Jellyfin.Server.Implementations.Security
auth.TryGetValue("Token", out token);
}
-#pragma warning disable CA1508 // string.IsNullOrEmpty(token) is always false.
if (string.IsNullOrEmpty(token))
{
token = headers["X-Emby-Token"];
@@ -118,7 +116,6 @@ namespace Jellyfin.Server.Implementations.Security
// Request doesn't contain a token.
return authInfo;
}
-#pragma warning restore CA1508
authInfo.HasToken = true;
var dbContext = await _jellyfinDbProvider.CreateDbContextAsync().ConfigureAwait(false);
@@ -219,24 +216,7 @@ namespace Jellyfin.Server.Implementations.Security
/// <summary>
/// Gets the auth.
/// </summary>
- /// <param name="httpReq">The HTTP req.</param>
- /// <returns>Dictionary{System.StringSystem.String}.</returns>
- private static Dictionary<string, string>? GetAuthorizationDictionary(HttpContext httpReq)
- {
- var auth = httpReq.Request.Headers["X-Emby-Authorization"];
-
- if (string.IsNullOrEmpty(auth))
- {
- auth = httpReq.Request.Headers[HeaderNames.Authorization];
- }
-
- return auth.Count > 0 ? GetAuthorization(auth[0]) : null;
- }
-
- /// <summary>
- /// Gets the auth.
- /// </summary>
- /// <param name="httpReq">The HTTP req.</param>
+ /// <param name="httpReq">The HTTP request.</param>
/// <returns>Dictionary{System.StringSystem.String}.</returns>
private static Dictionary<string, string>? GetAuthorizationDictionary(HttpRequest httpReq)
{