summaryrefslogtreecommitdiff
path: root/slips/src/app/Marina/Web/AuthenticationHttpModule.cs
diff options
context:
space:
mode:
authormokhan <mokhan@da190166-9cfc-4ee1-ae03-434a172be219>2009-02-21 21:44:27 +0000
committermokhan <mokhan@da190166-9cfc-4ee1-ae03-434a172be219>2009-02-21 21:44:27 +0000
commit1dfdccb8118aeaa3cd844ac8de2a672c93312166 (patch)
tree4b19e7f816ab1019f180a46b68572af4b66fe4bc /slips/src/app/Marina/Web/AuthenticationHttpModule.cs
parent42d66bcab8262c7b8b2452615df535e694a3ec1c (diff)
git-svn-id: http://svn.xp-dev.com/svn/mokhan-sait@2 da190166-9cfc-4ee1-ae03-434a172be219
Diffstat (limited to 'slips/src/app/Marina/Web/AuthenticationHttpModule.cs')
-rw-r--r--slips/src/app/Marina/Web/AuthenticationHttpModule.cs28
1 files changed, 28 insertions, 0 deletions
diff --git a/slips/src/app/Marina/Web/AuthenticationHttpModule.cs b/slips/src/app/Marina/Web/AuthenticationHttpModule.cs
new file mode 100644
index 0000000..c90c317
--- /dev/null
+++ b/slips/src/app/Marina/Web/AuthenticationHttpModule.cs
@@ -0,0 +1,28 @@
+using System.Security.Principal;
+using System.Web;
+using System.Web.Security;
+
+namespace Marina.Web {
+ public class AuthenticationHttpModule : IHttpModule {
+ public void Init( HttpApplication context ) {
+ context.AuthenticateRequest += delegate { AuthenticateHttpRequest( ); };
+ }
+
+ public void Dispose() {}
+
+ public void AuthenticateHttpRequest() {
+ HttpCookie cookie = GetCookieFrom( HttpContext.Current );
+ if ( null != cookie ) {
+ BindPrincipalToThreadUsing( FormsAuthentication.Decrypt( cookie.Value ).Name );
+ }
+ }
+
+ private HttpCookie GetCookieFrom( HttpContext context ) {
+ return context.Request.Cookies[ FormsAuthentication.FormsCookieName ];
+ }
+
+ private void BindPrincipalToThreadUsing( string username ) {
+ HttpContext.Current.User = new GenericPrincipal( new GenericIdentity( username ), new string[] {"Customer"} );
+ }
+ }
+} \ No newline at end of file