yavsc/testOauthClient/Controllers/AuthenticationController.cs

26 lines
1.0 KiB
C#

8 years ago

using System.Threading.Tasks;
8 years ago
using Microsoft.AspNet.Http.Authentication;
using Microsoft.AspNet.Mvc;
namespace Mvc.Client.Controllers {
public class AuthenticationController : Controller {
[HttpGet("~/signin")]
public ActionResult SignIn(string returnUrl="/") {
8 years ago
// 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.
// But, this redirect URI doesn't need to match the OAuth parameter, it's serialized in the query state,
// to be used once the identification ends.
var properties = new AuthenticationProperties { RedirectUri = returnUrl };
8 years ago
return new ChallengeResult("Yavsc", properties);
8 years ago
}
[HttpGet("~/signout")]
public async Task<IActionResult> SignOut(string returnUrl="/") {
await HttpContext.Authentication.SignOutAsync("Bearer");
return Redirect(returnUrl);
}
8 years ago
}
}