Beispiel #1
0
        public JsonResult OnPost()
        {
            login_db           _context = new login_db(AppGlobal.get_db_option()); //simplifying context initializer by override
            AppResponseMessage arm      = new AppResponseMessage();                //inisialisasi ARM sebagai standarisasi respon balik

            try {
                using (var transaction = _context.Database.BeginTransaction()) {
                    if (Request.Query["f"] == "logout_handler")
                    {
                        var history_id = User.FindFirst("history_id").Value;

                        var history = _context.t_login_history.FirstOrDefault(e => e.t_login_history_id == Convert.ToInt32(history_id));

                        history.logout_time = DateTime.Now;
                        _context.t_login_history.Update(history);
                        _context.SaveChanges();

                        AuthenticationHttpContextExtensions.SignOutAsync(HttpContext, CookieAuthenticationDefaults.AuthenticationScheme);

                        arm.success();
                        arm.message = "Success";
                    }
                    transaction.Commit();
                    _context.SaveChanges();
                }
            } catch (Exception ex) {
                arm.fail();
                arm.message = ex.Message;
            }
            return(new JsonResult(arm)); //return ARM dg method JsonResult untuk auto serialize ke format JSON
        }
Beispiel #2
0
        /// <summary>
        /// THIS LOGS OUT OF BOTH IPD AND mvc app
        /// </summary>
        /// <returns></returns>
        public async Task Logout()
        {
            //only logs out of client not IDP
            await AuthenticationHttpContextExtensions.SignOutAsync(HttpContext, "Cookies");

            await AuthenticationHttpContextExtensions.SignOutAsync(HttpContext, "oidc");
        }
        public async System.Threading.Tasks.Task <IActionResult> logout()
        {
            await AuthenticationHttpContextExtensions.SignOutAsync(HttpContext);

            _requestItemsService.Logout();
            return(LocalRedirect("/"));
        }
        public async Task Logout()
        {
            // TODO: Does not remove the antiforgery token from cookies
            await AuthenticationHttpContextExtensions.SignOutAsync(HttpContext, "Cookies");

            await AuthenticationHttpContextExtensions.SignOutAsync(HttpContext, "oidc");
        }
        public async Task <IActionResult> Signout()
        {
            ViewData["AdfsLogoutUrl"] = _configuration["AdfsLogoutUrl"];
            await AuthenticationHttpContextExtensions.SignOutAsync(HttpContext, "Cookies");

            return(Redirect("/"));
        }
Beispiel #6
0
        public async Task <IActionResult> Logout()
        {
            //FormsAuthentication.SignOut();
            await AuthenticationHttpContextExtensions.SignOutAsync(
                this.HttpContext, CookieAuthenticationDefaults.AuthenticationScheme);

            return(this.Redirect(Url.Action("Index", "Home")));
        }
Beispiel #7
0
        public async Task <IActionResult> Login(string returnUrl = null)
        {
            // Clear the existing external cookie to ensure a clean login process
            await AuthenticationHttpContextExtensions.SignOutAsync(HttpContext);

            ViewData["ReturnUrl"] = returnUrl;
            return(View());
        }
Beispiel #8
0
        public async System.Threading.Tasks.Task <IActionResult> logout()
        {
            await AuthenticationHttpContextExtensions.SignOutAsync(HttpContext);

            _requestItemsService.Logout();
            _configuration["quickstart"] = "false";
            return(LocalRedirect("/?egName=home"));
        }
Beispiel #9
0
        public async Task <IActionResult> Login()
        {
            if (IsAuthenticated)
            {
                await AuthenticationHttpContextExtensions.SignOutAsync(HttpContext, authenticationScheme);
            }

            return(View());
        }
Beispiel #10
0
        /// <summary>
        /// Attempts to sign out user.
        /// </summary>
        /// <returns>Default route view.</returns>
        public async Task <IActionResult> Logout()
        {
            if (User.Identity.IsAuthenticated)
            {
                await AuthenticationHttpContextExtensions.SignOutAsync(HttpContext, CookieAuthenticationDefaults.AuthenticationScheme);
            }

            return(Redirect("/"));
        }
Beispiel #11
0
 public async Task <int> Logout()
 {
     try
     {
         await AuthenticationHttpContextExtensions.SignOutAsync(HttpContext);
     }
     catch (Exception ex)
     {
         string msg = ex.Message;
         return(-1);
     }
     return(0);
 }
Beispiel #12
0
        public async Task <IActionResult> Logout(string providerId)
        {
            var scheme = "SPIDCookie";
            await AuthenticationHttpContextExtensions.SignOutAsync(HttpContext, scheme);

            providerId = Request.Cookies["SpidIdp"];

            var spidProviderConfiguration = new SpidProviderConfiguration();

            _configuration.GetSection("Spid:" + providerId).Bind(spidProviderConfiguration);

            string spidLogoutRequest = GetSpidLogoutRequest(spidProviderConfiguration);

            string redirectUri = Request.Headers["Referer"].ToString();// Request.QueryString["RedirectUrl"];
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters.Add("SAMLRequest", System.Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(spidLogoutRequest)));
            parameters.Add("RelayState", System.Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(redirectUri)));


            var inputs = new StringBuilder();


            foreach (var parameter in parameters)
            {
                var name  = (parameter.Key);
                var value = (parameter.Value);

                var input = string.Format(CultureInfo.InvariantCulture, InputTagFormat, name, value);
                inputs.AppendLine(input);
            }



            var content = string.Format(CultureInfo.InvariantCulture, HtmlFormFormat, spidProviderConfiguration.IdentityProviderLogoutPostUrl, inputs);
            var buffer  = Encoding.UTF8.GetBytes(content);

            Response.ContentLength = buffer.Length;
            Response.ContentType   = "text/html;charset=UTF-8";

            // Emit Cache-Control=no-cache to prevent client caching.
            Response.Headers[HeaderNames.CacheControl] = "no-cache";
            Response.Headers[HeaderNames.Pragma]       = "no-cache";
            Response.Headers[HeaderNames.Expires]      = "-1";

            await Response.Body.WriteAsync(buffer, 0, buffer.Length);

            return(Ok());

            //return RedirectToAction("Index","Home");
        }
        public async Task <IActionResult> Logout(string logoutId)
        {
            var logout = await _interaction.GetLogoutContextAsync(logoutId);

            await AuthenticationHttpContextExtensions.SignOutAsync(Request.HttpContext);

            if (!string.IsNullOrEmpty(logout.PostLogoutRedirectUri))
            {
                return(Redirect(logout.PostLogoutRedirectUri));
            }
            var refererUrl = Request.Headers["Referer"].ToString();

            return(Redirect(refererUrl));
        }
Beispiel #14
0
        public async Task <IActionResult> Logout()
        {
            var authenticated = httpContextAccessor.HttpContext.User.Identity.IsAuthenticated;

            if (authenticated)
            {
                await AuthenticationHttpContextExtensions.SignOutAsync(HttpContext);
            }

            // redirect to the home page
            return(RedirectToRoute(new
            {
                controller = "Home",
                action = "Index"
            }));
        }
        public async Task <IActionResult> Login(string returnUrl = null)
        {
            if (User.Identity.IsAuthenticated)
            {
                return(RedirectToAction("Index", "Home"));
            }
            if (returnUrl == null)
            {
                ViewData["ReturnUrl"] = Request.Headers["Referer"].ToString();
            }
            else
            {
                ViewData["ReturnUrl"] = returnUrl;
            }
            await AuthenticationHttpContextExtensions.SignOutAsync(HttpContext, IdentityConstants.ExternalScheme);

            return(View());
        }
Beispiel #16
0
        public async Task <IActionResult> Login(string returnUrl = null)
        {
            // If Windows Auth is enabled, check for a user and either sign up or sign in directly
            if (_config.GetValue <Enums.AuthenticationMode>("Customization:AuthenticationMode") == Enums.AuthenticationMode.Windows &&
                User.Identity.IsAuthenticated)
            {
                var identity = ((ClaimsIdentity)HttpContext.User.Identity);

                var username = identity.Name.Split('\\').Last();
                var domain   = identity.Name.Split('\\').First();
                var email    = string.Format("{0}@{1}.local", username, domain);

                var user = await _userManager.FindByEmailAsync(email);

                if (user == null)
                {
                    var rnd   = RandomNumberGenerator.Create();
                    var bytes = new byte[64];
                    rnd.GetBytes(bytes);

                    user = await CreateUser(username, "", "", email, Base64UrlTextEncoder.Encode(bytes));
                }

                await _signInManager.SignInAsync(user, isPersistent : false);

                if (!String.IsNullOrWhiteSpace(returnUrl))
                {
                    return(Redirect(returnUrl));
                }
                else
                {
                    return(RedirectToAction("Index", "Home"));
                }
            }
            else
            {
                // Clear the existing external cookie to ensure a clean login process
                await AuthenticationHttpContextExtensions.SignOutAsync(HttpContext);

                ViewData["ReturnUrl"] = returnUrl;
                return(View());
            }
        }
Beispiel #17
0
        public async Task <IActionResult> LoginAsync(string returnUrl)
        {
            // Sign out any previous sessions
            await AuthenticationHttpContextExtensions.SignOutAsync(HttpContext, IdentityConstants.ApplicationScheme);

            // Sign user in with the valid credentials
            var result = await mSignInManger.PasswordSignInAsync("jonny", "password", true, false);

            // If successful
            if (result.Succeeded)
            {
                // If no return url
                if (string.IsNullOrEmpty(returnUrl))
                {
                    // Go to home
                    return(RedirectToAction(nameof(Index)));
                }

                // Otherwise go to return url
                return(Redirect(returnUrl));
            }

            return(Content("Failed to login", "text/html"));
        }
Beispiel #18
0
        public async Task <IActionResult> Logout()
        {
            await AuthenticationHttpContextExtensions.SignOutAsync(HttpContext, AUTH_NAME);

            return(RedirectToAction("Beta", "Home"));
        }
Beispiel #19
0
 private async Task SignOut()
 {
     await AuthenticationHttpContextExtensions.SignOutAsync(_contextAcessor.HttpContext);
 }
        public async Task <IActionResult> Logout()
        {
            await AuthenticationHttpContextExtensions.SignOutAsync(HttpContext, CookieAuthenticationDefaults.AuthenticationScheme);

            return(RedirectToAction("Index", "Home"));
        }
Beispiel #21
0
        public async Task <IActionResult> Logout()
        {
            await AuthenticationHttpContextExtensions.SignOutAsync(HttpContext);

            return(RedirectToAction("Oauth"));
        }
Beispiel #22
0
        public async Task <IActionResult> LogOut()
        {
            await AuthenticationHttpContextExtensions.SignOutAsync(HttpContext);

            return(RedirectToAction("index", "home", new { area = "" }));
        }
Beispiel #23
0
 public void Logout()
 {
     AuthenticationHttpContextExtensions.SignOutAsync(HttpContext, CookieAuthenticationDefaults.AuthenticationScheme);
 }
        public async Task <IActionResult> Logout()
        {
            await AuthenticationHttpContextExtensions.SignOutAsync(HttpContext, CookieAuthenticationDefaults.AuthenticationScheme);

            return(Ok());
        }
Beispiel #25
0
        public async Task <IActionResult> SignOutAsync()
        {
            await AuthenticationHttpContextExtensions.SignOutAsync(HttpContext, IdentityConstants.ApplicationScheme);

            return(Content("done"));
        }
Beispiel #26
0
        public async Task <IActionResult> SignOut()
        {
            await AuthenticationHttpContextExtensions.SignOutAsync(this.HttpContext, "Cookies");

            return(this.RedirectToAction("Index", "Home"));
        }
Beispiel #27
0
 public async Task SignOutAsync()
 {
     await AuthenticationHttpContextExtensions.SignOutAsync(_httpContextAccessor.HttpContext);
 }
Beispiel #28
0
        public async Task Logout()
        {
            await AuthenticationHttpContextExtensions.SignOutAsync(HttpContext, CookieAuthenticationDefaults.AuthenticationScheme);

            await AuthenticationHttpContextExtensions.SignOutAsync(HttpContext, OpenIdConnectDefaults.AuthenticationScheme);
        }
Beispiel #29
0
        public async Task Logout()
        {
            await AuthenticationHttpContextExtensions.SignOutAsync(HttpContext, "Cookies");

            await AuthenticationHttpContextExtensions.SignOutAsync(HttpContext, "oidc");
        }
Beispiel #30
0
        public async System.Threading.Tasks.Task <IActionResult> SignOut()
        {
            await AuthenticationHttpContextExtensions.SignOutAsync(HttpContext);

            return(RedirectToAction("Index", "Home"));
        }