/// <summary>
        /// Initializes a new instance of the <see cref="PrincipalFactoryContext" /> class.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <param name="userName">user that have authenticated successfully.</param>
        public PrincipalFactoryContext(IHttpRequest request, IAuthenticationUser userName)
        {
            if (request == null) throw new ArgumentNullException("request");
            if (userName == null) throw new ArgumentNullException("userName");

            UserName = userName;
            Request = request;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="PrincipalFactoryContext" /> class.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <param name="userName">user that have authenticated successfully.</param>
        public PrincipalFactoryContext(IHttpRequest request, IAuthenticationUser userName)
        {
            if (request == null)
            {
                throw new ArgumentNullException("request");
            }
            if (userName == null)
            {
                throw new ArgumentNullException("userName");
            }

            UserName = userName;
            Request  = request;
        }
Exemple #3
0
        public void SignIn(IAuthenticationUser user, DateTime?expirantion = null, bool createPersistentCookie = true)
        {
            var now        = DateTime.UtcNow.ToLocalTime();
            var ticketName = _customerSettings.AuthenticationTicketName;
            var actualExpirationTimeSpan = expirantion.HasValue ?
                                           (expirantion.Value - now)
                : _expirationTimeSpan;

            var ticket = new FormsAuthenticationTicket(
                1 /*version*/,
                ticketName,
                now,
                now.Add(actualExpirationTimeSpan),
                createPersistentCookie,
                user.Guid.ToString(),
                FormsAuthentication.FormsCookiePath);

            var encryptedTicket = FormsAuthentication.Encrypt(ticket);

            var cookie = _httpContext.Request.Cookies[FormsAuthentication.FormsCookieName];

            if (cookie == null)
            {
                cookie = new HttpCookie(FormsAuthentication.FormsCookieName)
                {
                    HttpOnly = true
                };
                if (FormsAuthentication.CookieDomain != null)
                {
                    cookie.Domain = FormsAuthentication.CookieDomain;
                }
                if (ticket.IsPersistent)
                {
                    cookie.Expires = ticket.Expiration;
                }
                cookie.Secure = FormsAuthentication.RequireSSL;
                cookie.Path   = FormsAuthentication.FormsCookiePath;
            }

            var ticketDictionary = StringToAuthenticationTicket(cookie.Value);

            ticketDictionary[user.AuthenticationType.ToString().ToLower(CultureInfo.InvariantCulture)] = encryptedTicket;
            cookie.Value = AuthenticationTicketToString(ticketDictionary);

            _httpContext.Response.Cookies.Set(cookie);
        }
Exemple #4
0
 /// <summary>
 ///     Allows you to manage passwords by your self. Only works if the client supplies clear text passwords.
 /// </summary>
 /// <param name="user">User that your service returned from <c>Lookup</c>.</param>
 /// <param name="password">Password supplied by the client (web browser / http client)</param>
 /// <returns><c>true</c> if the user was authenticated</returns>
 public bool ComparePassword(IAuthenticationUser user, string password)
 {
     return(user.Password.Equals(password));
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="PrincipalFactoryContext" /> class.
 /// </summary>
 /// <param name="request">The request.</param>
 /// <param name="user">The user.</param>
 public PrincipalFactoryContext(IRequest request, IAuthenticationUser user)
 {
     User = user;
     Request = request;
 }
 /// <summary>
 ///     Allows you to manage passwords by your self. Only works if the client supplies clear text passwords.
 /// </summary>
 /// <param name="user">User that your service returned from <c>Lookup</c>.</param>
 /// <param name="password">Password supplied by the client (web browser / http client)</param>
 /// <returns><c>true</c> if the user was authenticated</returns>
 public bool ComparePassword(IAuthenticationUser user, string password)
 {
     return user.Password.Equals(password);
 }
Exemple #7
0
 public AuthenticationPresenter(IAuthenticationUser userview, IAuthenticationAddress addressview)
 {
     authenticationUserView    = userview;
     authenticationAddressView = addressview;
 }
Exemple #8
0
 public AuthController(IConfiguration _config, IAuthenticationUser _service)
 {
     config  = _config;
     service = _service;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="PrincipalFactoryContext" /> class.
 /// </summary>
 /// <param name="request">The request.</param>
 /// <param name="user">The user.</param>
 public PrincipalFactoryContext(IRequest request, IAuthenticationUser user)
 {
     this.User    = user;
     this.Request = request;
 }