yavsc/testOauthClient/Controllers/AuthenticationController.cs

26 lines
1 KiB
C#
Raw Normal View History

2016-06-01 23:47:06 +02:00

2016-06-12 02:31:59 +02:00
using System.Threading.Tasks;
2016-06-01 23:47:06 +02:00
using Microsoft.AspNet.Http.Authentication;
using Microsoft.AspNet.Mvc;
namespace Mvc.Client.Controllers {
public class AuthenticationController : Controller {
[HttpGet("~/signin")]
2016-06-12 02:31:59 +02:00
public ActionResult SignIn(string returnUrl="/") {
2016-06-01 23:47:06 +02:00
// Instruct the OIDC client middleware to redirect the user agent to the identity provider.
2016-06-12 02:31:59 +02:00
// 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 };
2016-06-12 01:32:51 +02:00
return new ChallengeResult("Yavsc", properties);
2016-06-01 23:47:06 +02:00
}
2016-06-12 02:31:59 +02:00
[HttpGet("~/signout")]
public async Task<IActionResult> SignOut(string returnUrl="/") {
await HttpContext.Authentication.SignOutAsync("Bearer");
return Redirect(returnUrl);
}
2016-06-01 23:47:06 +02:00
}
}