You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
1.1 KiB
26 lines
1.1 KiB
using Microsoft.AspNetCore.Authentication;
|
|
using Microsoft.AspNetCore.Authentication.Cookies;
|
|
using Microsoft.AspNetCore.Authentication.OpenIdConnect;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace Mvc.Client.Controllers;
|
|
|
|
public class AuthenticationController : Controller
|
|
{
|
|
[HttpGet("~/login")]
|
|
public ActionResult LogIn()
|
|
{
|
|
// Instruct the OIDC client middleware to redirect the user agent to the identity provider.
|
|
// Note: the authenticationType parameter must match the value configured in Startup.cs
|
|
return Challenge(new AuthenticationProperties { RedirectUri = "/" }, OpenIdConnectDefaults.AuthenticationScheme);
|
|
}
|
|
|
|
[HttpGet("~/logout"), HttpPost("~/logout")]
|
|
public ActionResult LogOut()
|
|
{
|
|
// Instruct the cookies middleware to delete the local cookie created when the user agent
|
|
// is redirected from the identity provider after a successful authorization flow and
|
|
// to redirect the user agent to the identity provider to sign out.
|
|
return SignOut(CookieAuthenticationDefaults.AuthenticationScheme, OpenIdConnectDefaults.AuthenticationScheme);
|
|
}
|
|
}
|
|
|