Example #1
0
        protected override Task ApplyResponseGrantAsync()
        {
            AuthenticationResponseRevoke signout = Helper.LookupSignOut(Options.AuthenticationType, Options.AuthenticationMode);

            if (signout != null)
            {
                // Base logout url
                var logoutUri = $"https://{Options.Domain}/v2/logout?client_id={Options.ClientId}";

                // Add redirect after logout
                var postLogoutUri = signout.Properties.RedirectUri;
                if (!string.IsNullOrEmpty(postLogoutUri))
                {
                    if (postLogoutUri.StartsWith("/"))
                    {
                        // transform to absolute
                        postLogoutUri = Request.Scheme + "://" + Request.Host + postLogoutUri;
                    }
                    logoutUri += $"&returnTo={Uri.EscapeDataString(postLogoutUri)}";
                }

                // Handle federated logout
                if (signout.Properties.Dictionary.ContainsKey(".federated") &&
                    signout.Properties.Dictionary[".federated"] == "true")
                {
                    logoutUri += "&federated";
                }

                var logoutContext = new Auth0ApplyLogoutContext(
                    Context, Options, signout.Properties, logoutUri);
                Options.Provider.ApplyLogout(logoutContext);
            }

            return(base.ApplyResponseGrantAsync());
        }
Example #2
0
 /// <summary>
 /// Called when the logout endpoint is called.
 /// </summary>
 /// <param name="context">Contains redirect URI and <see cref="AuthenticationProperties"/> of the logout  </param>
 public virtual void ApplyLogout(Auth0ApplyLogoutContext context)
 {
     OnApplyLogout(context);
 }