private static ExternaProviderStatusModel CreateExternalProviderStatusModel(AuthenticationDescription existProviders, IEnumerable<LoginDto> logins)
 {
     return new ExternaProviderStatusModel
     {
         ProviderIconUrl = string.Format("/wwwroot/img/{0}.png", existProviders.Caption),
         Status = logins.Any(i => i.LoginType.ToString() == existProviders.Caption)
     };
 }
Example #2
0
 /// <summary>
 /// Create an instance of the result object
 /// </summary>
 /// <param name="identity">Assigned to the Identity property. May be null.</param>
 /// <param name="extra">Assigned to the Extra property. An empty Extra instance is created if needed.</param>
 /// <param name="description">Assigned to the Description property. An empty AuthenticationDescription instance is created if needed.</param>
 public AuthenticateResult(IIdentity identity, IDictionary <string, string> extra, IDictionary <string, object> description)
 {
     if (identity != null)
     {
         Identity = identity as ClaimsIdentity ?? new ClaimsIdentity(identity);
     }
     Extra       = new AuthenticationExtra(extra);
     Description = new AuthenticationDescription(description);
 }
Example #3
0
 /// <summary>
 /// Create an instance of the result object
 /// </summary>
 /// <param name="identity">Assigned to the Identity property. May be null.</param>
 /// <param name="extra">Assigned to the Extra property. An empty Extra instance is created if needed.</param>
 /// <param name="description">Assigned to the Description property. An empty AuthenticationDescription instance is created if needed.</param>
 public AuthenticateResult(IIdentity identity, IDictionary<string, string> extra, IDictionary<string, object> description)
 {
     if (identity != null)
     {
         Identity = identity as ClaimsIdentity ?? new ClaimsIdentity(identity);
     }
     Extra = new AuthenticationExtra(extra);
     Description = new AuthenticationDescription(description);
 }
        public SamlAuthenticationOptions() : base("SAML2") {
            Description = new AuthenticationDescription
            {
                AuthenticationType = "SAML2",
                Caption = "Saml 2.0 Authentication protocol for OWIN"
            };
			SignInAsAuthenticationType = "SAML2";
            MetadataPath = "/saml2/metadata";
            LoginPath = "/saml2/login";
            LogoutPath = "/saml2/logout";
            GetFromCache = s => memoryCache.Get(s);
            SetInCache = (s, o, d) => memoryCache.Set(s, o, d);
        }
Example #5
0
 public IEnumerable<AuthenticationDescription> GetAuthenticationTypes(Func<AuthenticationDescription, bool> predicate)
 {
     // TODO: refactor the signature to remove the .Wait() on this call path
     var descriptions = new List<AuthenticationDescription>();
     _request.GetAuthenticationTypes((properties, _) =>
     {
         var description = new AuthenticationDescription(properties);
         if (predicate(description))
         {
             descriptions.Add(description);
         }
     }, null).Wait();
     return descriptions;
 }
        public IEnumerable <AuthenticationDescription> GetAuthenticationTypes(Func <AuthenticationDescription, bool> predicate)
        {
            // TODO: refactor the signature to remove the .Wait() on this call path
            var descriptions = new List <AuthenticationDescription>();

            GetAuthenticationTypes(rawDescription =>
            {
                var description = new AuthenticationDescription(rawDescription);
                if (predicate(description))
                {
                    descriptions.Add(description);
                }
            }).Wait();
            return(descriptions);
        }
 /// <summary>
 /// Create an instance of the result object
 /// </summary>
 /// <param name="identity">Assigned to Identity. May be null.</param>
 /// <param name="properties">Assigned to Properties. Contains extra information carried along with the identity.</param>
 /// <param name="description">Assigned to Description. Contains information describing the authentication provider.</param>
 public AuthenticateResult(IIdentity identity, AuthenticationProperties properties, AuthenticationDescription description)
 {
     if (properties == null)
     {
         throw new ArgumentNullException("properties");
     }
     if (description == null)
     {
         throw new ArgumentNullException("description");
     }
     if (identity != null)
     {
         Identity = identity as ClaimsIdentity ?? new ClaimsIdentity(identity);
     }
     Properties = properties;
     Description = description;
 }
 /// <summary>
 /// Create an instance of the result object
 /// </summary>
 /// <param name="identity">Assigned to Identity. May be null.</param>
 /// <param name="properties">Assigned to Properties. Contains extra information carried along with the identity.</param>
 /// <param name="description">Assigned to Description. Contains information describing the authentication provider.</param>
 public AuthenticateResult(IIdentity identity, AuthenticationProperties properties, AuthenticationDescription description)
 {
     if (properties == null)
     {
         throw new ArgumentNullException("properties");
     }
     if (description == null)
     {
         throw new ArgumentNullException("description");
     }
     if (identity != null)
     {
         Identity = identity as ClaimsIdentity ?? new ClaimsIdentity(identity);
     }
     Properties  = properties;
     Description = description;
 }
 public IEnumerable<AuthenticationDescription> GetAuthenticationTypes(Func<AuthenticationDescription, bool> predicate)
 {
     // TODO: refactor the signature to remove the .Wait() on this call path
     var descriptions = new List<AuthenticationDescription>();
     GetAuthenticationTypes(rawDescription =>
     {
         var description = new AuthenticationDescription(rawDescription);
         if (predicate(description))
         {
             descriptions.Add(description);
         }
     }).Wait();
     return descriptions;
 }
        public void UnassignOAuthProvider(AuthenticationDescription model)
        {
            var userId = _context.User.Identity.GetUserId();
             var login = _userManager.GetLogins(userId)
            .FirstOrDefault(x => x.LoginProvider == model.AuthenticationType);
             var result = _userManager.RemoveLogin(userId, login);
             if (result.Succeeded)
             {
            var user = _userManager.FindById(userId);
            SignIn(user, isPersistent: false);
            RedirectToManager(ManageMessageId.RemoveLoginSuccess);
            return;
             }

             RedirectToManager(ManageMessageId.Error);
        }
        public void AssignOAuthProvider(AuthenticationDescription model)
        {
            var properties = new AuthenticationProperties
             {
            RedirectUri = StateController
               .GetNavigationLink(
                  "ExternalLoginHandler", new NavigationData
                  {
                     {ProviderNameKey, model.AuthenticationType},
                     {ReturnUrlKey, StateContext.Bag.ReturnUrl}
                  })
             };

             if (_context.User.Identity.IsAuthenticated)
             {
            properties.Dictionary[XsrfKey] = _context.User.Identity.GetUserId();
             }

             _authenticationManager.Challenge(properties, model.AuthenticationType);
             _response.StatusCode = 401;
             _response.End();
        }