You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
#ROBOMERGE-AUTHOR: ben.marsh #ROBOMERGE-SOURCE: CL 17926237 in //UE5/Main/... #ROBOMERGE-BOT: STARSHIP (Main -> Release-Engine-Test) (v885-17909292) [CL 17926263 by ben marsh in ue5-release-engine-test branch]
68 lines
1.7 KiB
C#
68 lines
1.7 KiB
C#
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
using HordeServer.Authentication;
|
|
using Microsoft.AspNetCore.Authentication;
|
|
using Microsoft.AspNetCore.Authentication.Cookies;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using System.Threading.Tasks;
|
|
|
|
/// <summary>
|
|
/// Dashboard authorization challenge controller
|
|
/// </summary>
|
|
[ApiController]
|
|
[Route("[controller]")]
|
|
public class DashboardChallengeController : Controller
|
|
{
|
|
const string DefaultAuthenticationScheme = OktaDefaults.AuthenticationScheme;
|
|
|
|
/// <summary>
|
|
/// Challenge endpoint for the dashboard, using cookie authentication scheme
|
|
/// </summary>
|
|
/// <returns>Ok on authorized, otherwise will 401</returns>
|
|
[HttpGet]
|
|
[Authorize]
|
|
[Route("/api/v1/dashboard/challenge")]
|
|
public StatusCodeResult GetChallenge()
|
|
{
|
|
return Ok();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Login to server, redirecting to the specified URL on success
|
|
/// </summary>
|
|
/// <param name="Redirect"></param>
|
|
/// <returns></returns>
|
|
[HttpGet]
|
|
[Route("/api/v1/dashboard/login")]
|
|
public IActionResult Login([FromQuery] string? Redirect)
|
|
{
|
|
return new ChallengeResult(DefaultAuthenticationScheme, new AuthenticationProperties { RedirectUri = Redirect ?? "/" });
|
|
}
|
|
|
|
/// <summary>
|
|
/// Logout of the current account
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpGet]
|
|
[Route("/api/v1/dashboard/logout")]
|
|
public async Task<StatusCodeResult> Logout()
|
|
{
|
|
await HttpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);
|
|
try
|
|
{
|
|
await HttpContext.SignOutAsync(DefaultAuthenticationScheme);
|
|
}
|
|
#pragma warning disable CA1031 // Do not catch general exception types
|
|
catch
|
|
#pragma warning restore CA1031
|
|
{
|
|
}
|
|
|
|
return Ok();
|
|
}
|
|
|
|
|
|
} |