Inheritance: iServe.Models.Security.IServeUser, IAuditable
Ejemplo n.º 1
0
        public iServeController()
        {
            // iServeAlpha
            JojoTheIndianCircusBoy principal = System.Threading.Thread.CurrentPrincipal as Principal;

            if (principal != null) {
                _currentUser = principal.CurrentUser as User;
            }
        }
Ejemplo n.º 2
0
        protected void Application_AuthenticateRequest(object sender, EventArgs e)
        {
            if (!(HttpContext.Current.User == null)) {
                if (HttpContext.Current.User.Identity.IsAuthenticated) {
                    // Extract the forms authentication cookie
                    HttpCookie authCookie = Context.Request.Cookies[FormsAuthentication.FormsCookieName];
                    FormsAuthenticationTicket authTicket = FormsAuthentication.Decrypt(authCookie.Value);

                    // Get the UserID out of the cookie
                    User user = new User(authTicket.UserData);

                    Principal principal = new Principal(HttpContext.Current.User.Identity, user);
                    HttpContext.Current.User = principal;
                    System.Threading.Thread.CurrentPrincipal = principal;
                }
            }
        }
Ejemplo n.º 3
0
 public NeedController(IModelFactory<iServeDBProcedures> modelFactory, User currentUser)
     : base(currentUser)
 {
     Model = modelFactory;
 }
Ejemplo n.º 4
0
 public iServeController(User currentUser)
 {
     _currentUser = currentUser;
 }
Ejemplo n.º 5
0
        private void WriteAuthCookie(User user)
        {
            //int userID, string username) {
            double formsAuthTimeout = 40;
            string userData = user.ToDelimitedString();

            FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(
                                                            1,				// version
                                                            user.Name,		// user name
                                                            DateTime.Now,	// creation
                                                            DateTime.Now.AddMinutes(formsAuthTimeout),  // Expiration
                                                            false,			// isPersistent
                                                            user.ToDelimitedString() // user data (just user object in simple delimited string)
                                                            );
            string encryptedTicket = FormsAuthentication.Encrypt(authTicket);
            HttpCookie authCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);

            // Make sure we mark the cookie as "Secure" if RequireSSL is set in the web.config.
            //  If we don't, the FIRST issuing of this cookie will not be secure
            //  (as we are the ones that did it) while the second issuing (when it's
            //  being refreshed) will be secure. That would cause intermittent problems with
            //  timeout-like behaviors around "timeout/2" minutes into the user's session.
            authCookie.Secure = FormsAuthentication.RequireSSL;
            authCookie.HttpOnly = true;
            HttpContext.Response.Cookies.Add(authCookie);
        }