aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Server.Implementations/HttpServer/Security/AuthService.cs
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2014-07-02 01:16:59 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2014-07-02 01:16:59 -0400
commit9bab99d4d8659e69478722d72028e84b64575ab2 (patch)
treea9cd44ae3dd2c68ef28cdc296b2115122986fc34 /MediaBrowser.Server.Implementations/HttpServer/Security/AuthService.cs
parent389390b82ecfbb48e0486f8f132046ddf8624e00 (diff)
run all ajax through apiclient
Diffstat (limited to 'MediaBrowser.Server.Implementations/HttpServer/Security/AuthService.cs')
-rw-r--r--MediaBrowser.Server.Implementations/HttpServer/Security/AuthService.cs48
1 files changed, 46 insertions, 2 deletions
diff --git a/MediaBrowser.Server.Implementations/HttpServer/Security/AuthService.cs b/MediaBrowser.Server.Implementations/HttpServer/Security/AuthService.cs
index ddb583f5d..1a7f9db28 100644
--- a/MediaBrowser.Server.Implementations/HttpServer/Security/AuthService.cs
+++ b/MediaBrowser.Server.Implementations/HttpServer/Security/AuthService.cs
@@ -1,4 +1,7 @@
-using MediaBrowser.Controller.Net;
+using MediaBrowser.Controller.Entities;
+using MediaBrowser.Controller.Library;
+using MediaBrowser.Controller.Net;
+using MediaBrowser.Controller.Session;
using ServiceStack;
using ServiceStack.Auth;
using ServiceStack.Web;
@@ -10,6 +13,17 @@ namespace MediaBrowser.Server.Implementations.HttpServer.Security
{
public class AuthService : IAuthService
{
+ public AuthService(IUserManager userManager, ISessionManager sessionManager, IAuthorizationContext authorizationContext)
+ {
+ AuthorizationContext = authorizationContext;
+ SessionManager = sessionManager;
+ UserManager = userManager;
+ }
+
+ public IUserManager UserManager { get; private set; }
+ public ISessionManager SessionManager { get; private set; }
+ public IAuthorizationContext AuthorizationContext { get; private set; }
+
/// <summary>
/// Restrict authentication to a specific <see cref="IAuthProvider"/>.
/// For example, if this attribute should only permit access
@@ -37,7 +51,32 @@ namespace MediaBrowser.Server.Implementations.HttpServer.Security
private void ValidateUser(IRequest req)
{
- var user = req.TryResolve<ISessionContext>().GetUser(req);
+ User user = null;
+
+ //This code is executed before the service
+ var auth = AuthorizationContext.GetAuthorizationInfo(req);
+
+ if (auth != null)
+ {
+ if (!string.IsNullOrWhiteSpace(auth.UserId))
+ {
+ var userId = auth.UserId;
+
+ user = UserManager.GetUserById(new Guid(userId));
+ }
+
+ string deviceId = auth.DeviceId;
+ string device = auth.Device;
+ string client = auth.Client;
+ string version = auth.Version;
+
+ if (!string.IsNullOrEmpty(client) && !string.IsNullOrEmpty(deviceId) && !string.IsNullOrEmpty(device) && !string.IsNullOrEmpty(version))
+ {
+ var remoteEndPoint = req.RemoteIp;
+
+ SessionManager.LogSessionActivity(client, version, deviceId, device, remoteEndPoint, user);
+ }
+ }
if (user == null || user.Configuration.IsDisabled)
{
@@ -74,6 +113,11 @@ namespace MediaBrowser.Server.Implementations.HttpServer.Security
}
}
+ private void LogRequest()
+ {
+
+ }
+
protected bool DoHtmlRedirectIfConfigured(IRequest req, IResponse res, bool includeRedirectParam = false)
{
var htmlRedirect = this.HtmlRedirect ?? AuthenticateService.HtmlRedirect;