コード例 #1
0
        public ActionResult Login(SamlLoginModel model)
        {
            if (ModelState.IsValid)
            {
                AccountSettings accountSettings = new AccountSettings();

                var samlResponse = new Response(accountSettings);
                samlResponse.LoadXmlFromBase64(model.SAMLResponse);

                if (samlResponse.IsValid())
                {
                    FormsAuthentication.SetAuthCookie(samlResponse.GetNameID(), true);

                    // Redirect to targetURL, or to /Home by default

                    return RedirectToAction("Index", "Home");
                }
                else
                {
                    ModelState.AddModelError("", "The user name or password provided is incorrect.");
                }
            }
            else
            {
                ModelState.AddModelError("", "The user name or password provided is incorrect.");
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
コード例 #2
0
ファイル: AuthRequest.cs プロジェクト: skradel/dotnet-saml
        public AuthRequest(AppSettings appSettings, AccountSettings accountSettings)
        {
            this.appSettings = appSettings;
            this.accountSettings = accountSettings;

            id = "_" + System.Guid.NewGuid().ToString();
            issue_instant = DateTime.UtcNow.ToString("yyyy-mm-ddTH:mm:ssZ");
        }
コード例 #3
0
        public ActionResult Login()
        {
            AccountSettings accountSettings = new AccountSettings();

            AuthRequest req = new AuthRequest(new AppSettings(), accountSettings);

            return this.Redirect(accountSettings.idp_sso_target_url + "?SAMLRequest=" + Server.UrlEncode(req.GetRequest(AuthRequest.AuthRequestFormat.Base64)));
        }
コード例 #4
0
ファイル: Response.cs プロジェクト: skradel/dotnet-saml
 public Response(AccountSettings accountSettings)
 {
     this.accountSettings = accountSettings;
     certificate = new Certificate();
     certificate.LoadCertificate(accountSettings.certificate);
 }