Add OAuth2 support
This commit is contained in:
29
Oqtane.Server/Pages/External.cshtml.cs
Normal file
29
Oqtane.Server/Pages/External.cshtml.cs
Normal file
@ -0,0 +1,29 @@
|
||||
using System.Net;
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
using Microsoft.AspNetCore.Authentication.OpenIdConnect;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Oqtane.Extensions;
|
||||
|
||||
namespace Oqtane.Pages
|
||||
{
|
||||
public class ExternalModel : PageModel
|
||||
{
|
||||
public IActionResult OnGetAsync(string returnurl)
|
||||
{
|
||||
returnurl = (returnurl == null) ? "/" : returnurl;
|
||||
returnurl = (!returnurl.StartsWith("/")) ? "/" + returnurl : returnurl;
|
||||
|
||||
var providertype = HttpContext.GetAlias().SiteSettings.GetValue("ExternalLogin:ProviderType", "");
|
||||
if (providertype != "")
|
||||
{
|
||||
return new ChallengeResult(providertype, new AuthenticationProperties { RedirectUri = returnurl });
|
||||
}
|
||||
else
|
||||
{
|
||||
HttpContext.Response.StatusCode = (int)HttpStatusCode.Forbidden;
|
||||
return new EmptyResult();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user