Exemplo n.º 1
0
        public async Task <ActionResult> Login(LoginViewModel model, string returnUrl)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            // Check if we need to login user locally (in case no SAML Identity Provider is registered for specified email domain)
            var emailDomain = Utils.GetEmailDomain(model.Email);
            var isSamlAuthenticationRequired =
                SamlIdentityProvidersRepository.IsSamlAuthenticationRequired(emailDomain);

            if (isSamlAuthenticationRequired)
            {
                return(RedirectToAction("Login", "SAML", new { domain = emailDomain, returnUrl = returnUrl }));
            }

            // Authenticate locally
            var succeeded = _authenticationService.Authenticate(AuthenticationType.Local, model.Email, model.Password);

            if (succeeded)
            {
                return(RedirectToLocal(returnUrl));
            }

            ModelState.AddModelError("", "Invalid login attempt.");

            return(View(model));
        }
Exemplo n.º 2
0
        public ActionResult Login(string domain, string returnUrl)
        {
            SamlPocTraceListener.Log("SAML", $"SamlController.SingleSignOn: Request for SSO with IdP of domain {domain} received.");

            // Get appropriate IdP name
            var idpName = SamlIdentityProvidersRepository.GetIdentityProviderName(domain);

            if (idpName == null)
            {
                SamlPocTraceListener.Log("SAML", $"SamlController.SingleSignOn: IdP for domain {domain} not found.");

                return(View("Error"));
            }

            // To login at the service provider, initiate single sign-on to the identity provider (SP-initiated SSO).
            SAMLServiceProvider.InitiateSSO(Response, returnUrl, idpName);

            SamlPocTraceListener.Log("SAML", $"SamlController.SingleSignOn: SSO with IdP {idpName} initiated.");

            return(new EmptyResult());
        }
Exemplo n.º 3
0
 public ActionResult Login(string returnUrl)
 {
     ViewBag.ReturnUrl         = returnUrl;
     ViewBag.IdentityProviders = SamlIdentityProvidersRepository.GetRegisteredIdentityProviders();
     return(View());
 }
Exemplo n.º 4
0
        public void Configuration(IAppBuilder app)
        {
            ConfigureAuth(app);

            SamlConfigurationManager.Configure(SamlIdentityProvidersRepository.GetInstance());
        }