-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cdae4a6
commit ce5f840
Showing
4 changed files
with
57 additions
and
8 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
backend/src/Designer/Controllers/AnsattPortenController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using System.Threading.Tasks; | ||
using Altinn.Studio.Designer.Constants; | ||
using Altinn.Studio.Designer.Models.Dto; | ||
using Microsoft.AspNetCore.Authentication; | ||
using Microsoft.AspNetCore.Authorization; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.FeatureManagement.Mvc; | ||
|
||
namespace Altinn.Studio.Designer.Controllers; | ||
|
||
[FeatureGate(StudioFeatureFlags.AnsattPorten)] | ||
[Route("designer/api/[controller]")] | ||
[ApiController] | ||
public class AnsattPortenController(IAuthenticationService authService) : ControllerBase | ||
{ | ||
[Authorize(AnsattPortenConstants.AnsattportenAuthorizationPolicy)] | ||
[HttpGet("login")] | ||
public async Task<IActionResult> Login([FromQuery] string redirectTo) | ||
{ | ||
await Task.CompletedTask; | ||
if (!Url.IsLocalUrl(redirectTo)) | ||
{ | ||
return Forbid(); | ||
} | ||
|
||
return LocalRedirect(redirectTo); | ||
} | ||
|
||
[AllowAnonymous] | ||
[HttpGet("auth-status")] | ||
public async Task<IActionResult> AuthStatus() | ||
{ | ||
await Task.CompletedTask; | ||
var authenticateResult = | ||
await authService.AuthenticateAsync(HttpContext, | ||
AnsattPortenConstants.AnsattportenAuthenticationScheme); | ||
|
||
var authStatus = new AuthStatus | ||
{ | ||
IsLoggedIn = authenticateResult.Succeeded | ||
}; | ||
|
||
return Ok(authStatus); | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace Altinn.Studio.Designer.Models.Dto; | ||
|
||
public class AuthStatus | ||
{ | ||
public bool IsLoggedIn { get; set; } | ||
} |