From 9a08526842b5ac4dcdfd7c4d36fae8b5da32607b Mon Sep 17 00:00:00 2001 From: Jonathan Merriweather Date: Thu, 21 Feb 2013 18:31:25 +1100 Subject: [PATCH 1/2] Added current user assignment --- src/Nancy.Authentication.Ntlm/ModuleExtensions.cs | 7 +++++++ .../Security/INtlmIdentity.cs | 11 +++++++++++ .../Security/NtlmIdentity.cs | 15 +++++++++++++++ 3 files changed, 33 insertions(+) create mode 100644 src/Nancy.Authentication.Ntlm/Security/INtlmIdentity.cs create mode 100644 src/Nancy.Authentication.Ntlm/Security/NtlmIdentity.cs diff --git a/src/Nancy.Authentication.Ntlm/ModuleExtensions.cs b/src/Nancy.Authentication.Ntlm/ModuleExtensions.cs index 4ec5f70..c286f38 100644 --- a/src/Nancy.Authentication.Ntlm/ModuleExtensions.cs +++ b/src/Nancy.Authentication.Ntlm/ModuleExtensions.cs @@ -114,6 +114,13 @@ public static void RequiresNtlmAuthentication(this NancyModule module) Sessions[module.Request.Cookies["NTLM"]].ResetHandles(); Sessions[module.Request.Cookies["NTLM"]].UpdatePresence(); + // Create IUserIdentity and assign it to the current context + module.Context.CurrentUser = new NtlmIdentity() + { + UserName = type3Message.Username, + Domain = type3Message.Domain + }; + // Authorization successful return null; } diff --git a/src/Nancy.Authentication.Ntlm/Security/INtlmIdentity.cs b/src/Nancy.Authentication.Ntlm/Security/INtlmIdentity.cs new file mode 100644 index 0000000..889a8b1 --- /dev/null +++ b/src/Nancy.Authentication.Ntlm/Security/INtlmIdentity.cs @@ -0,0 +1,11 @@ +namespace Nancy.Authentication.Ntlm.Security +{ + using Nancy.Security; + using System; + + public interface INtlmIdentity : IUserIdentity + { + string Domain { get; set; } + Common.NtlmFlags Flags { get; set; } + } +} diff --git a/src/Nancy.Authentication.Ntlm/Security/NtlmIdentity.cs b/src/Nancy.Authentication.Ntlm/Security/NtlmIdentity.cs new file mode 100644 index 0000000..9311e27 --- /dev/null +++ b/src/Nancy.Authentication.Ntlm/Security/NtlmIdentity.cs @@ -0,0 +1,15 @@ +namespace Nancy.Authentication.Ntlm.Security +{ + using Nancy.Security; + using System; + using System.Collections.Generic; + + public class NtlmIdentity : INtlmIdentity + { + public IEnumerable Claims { get; set; } + + public string UserName { get; set; } + public string Domain { get; set; } + public Common.NtlmFlags Flags { get; set; } + } +} From d0f19f457f44e89fd029ede35029b3a6ea5f3524 Mon Sep 17 00:00:00 2001 From: Jonathan Merriweather Date: Sat, 23 Feb 2013 08:50:38 +1100 Subject: [PATCH 2/2] Added NtlmIdentity files to project --- src/Nancy.Authentication.Ntlm/Nancy.Authentication.Ntlm.csproj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Nancy.Authentication.Ntlm/Nancy.Authentication.Ntlm.csproj b/src/Nancy.Authentication.Ntlm/Nancy.Authentication.Ntlm.csproj index 8edbac3..227f774 100644 --- a/src/Nancy.Authentication.Ntlm/Nancy.Authentication.Ntlm.csproj +++ b/src/Nancy.Authentication.Ntlm/Nancy.Authentication.Ntlm.csproj @@ -50,11 +50,13 @@ + +