|
|
|
@ -36,8 +36,7 @@ namespace Emby.Server.Implementations.HttpServer.Security
|
|
|
|
|
public AuthorizationInfo GetAuthorizationInfo(HttpRequest requestContext)
|
|
|
|
|
{
|
|
|
|
|
var auth = GetAuthorizationDictionary(requestContext);
|
|
|
|
|
var (authInfo, _) =
|
|
|
|
|
GetAuthorizationInfoFromDictionary(auth, requestContext.Headers, requestContext.Query);
|
|
|
|
|
var authInfo = GetAuthorizationInfoFromDictionary(auth, requestContext.Headers, requestContext.Query);
|
|
|
|
|
return authInfo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -49,19 +48,13 @@ namespace Emby.Server.Implementations.HttpServer.Security
|
|
|
|
|
private AuthorizationInfo GetAuthorization(HttpContext httpReq)
|
|
|
|
|
{
|
|
|
|
|
var auth = GetAuthorizationDictionary(httpReq);
|
|
|
|
|
var (authInfo, originalAuthInfo) =
|
|
|
|
|
GetAuthorizationInfoFromDictionary(auth, httpReq.Request.Headers, httpReq.Request.Query);
|
|
|
|
|
|
|
|
|
|
if (originalAuthInfo != null)
|
|
|
|
|
{
|
|
|
|
|
httpReq.Request.HttpContext.Items["OriginalAuthenticationInfo"] = originalAuthInfo;
|
|
|
|
|
}
|
|
|
|
|
var authInfo = GetAuthorizationInfoFromDictionary(auth, httpReq.Request.Headers, httpReq.Request.Query);
|
|
|
|
|
|
|
|
|
|
httpReq.Request.HttpContext.Items["AuthorizationInfo"] = authInfo;
|
|
|
|
|
return authInfo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private (AuthorizationInfo authInfo, AuthenticationInfo originalAuthenticationInfo) GetAuthorizationInfoFromDictionary(
|
|
|
|
|
private AuthorizationInfo GetAuthorizationInfoFromDictionary(
|
|
|
|
|
in Dictionary<string, string> auth,
|
|
|
|
|
in IHeaderDictionary headers,
|
|
|
|
|
in IQueryCollection queryString)
|
|
|
|
@ -108,13 +101,14 @@ namespace Emby.Server.Implementations.HttpServer.Security
|
|
|
|
|
Device = device,
|
|
|
|
|
DeviceId = deviceId,
|
|
|
|
|
Version = version,
|
|
|
|
|
Token = token
|
|
|
|
|
Token = token,
|
|
|
|
|
IsAuthenticated = false
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(token))
|
|
|
|
|
{
|
|
|
|
|
// Request doesn't contain a token.
|
|
|
|
|
return (null, null);
|
|
|
|
|
return authInfo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var result = _authRepo.Get(new AuthenticationInfoQuery
|
|
|
|
@ -122,6 +116,11 @@ namespace Emby.Server.Implementations.HttpServer.Security
|
|
|
|
|
AccessToken = token
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (result.Items.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
authInfo.IsAuthenticated = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var originalAuthenticationInfo = result.Items.Count > 0 ? result.Items[0] : null;
|
|
|
|
|
|
|
|
|
|
if (originalAuthenticationInfo != null)
|
|
|
|
@ -197,7 +196,7 @@ namespace Emby.Server.Implementations.HttpServer.Security
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (authInfo, originalAuthenticationInfo);
|
|
|
|
|
return authInfo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|