-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into dependabot/nuget/src/Authorization/Azure.Sto…
…rage.Queues-12.20.0
- Loading branch information
Showing
89 changed files
with
3,952 additions
and
369 deletions.
There are no files selected for viewing
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,27 @@ | ||
namespace Altinn.Platform.Authorization.Configuration; | ||
|
||
/// <summary> | ||
/// Represents a set of configuration options needed for using the Altinn Platform Token Generator. | ||
/// </summary> | ||
public class TokenGeneratorSettings | ||
{ | ||
/// <summary> | ||
/// Gets or sets the url for the token generator. | ||
/// </summary> | ||
public string Url { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets user for authorized access to the token generator. | ||
/// </summary> | ||
public string User { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets password for authorized access to the token generator. | ||
/// </summary> | ||
public string Password { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the environment to use for the token generator. | ||
/// </summary> | ||
public string Env { get; set; } | ||
} |
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
66 changes: 66 additions & 0 deletions
66
src/Authorization/Controllers/AccessListAuthorizationController.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,66 @@ | ||
using System.Linq; | ||
using System.Net.Mime; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Altinn.Authorization.Errors; | ||
using Altinn.Authorization.Models.ResourceRegistry; | ||
using Altinn.Authorization.ProblemDetails; | ||
using Altinn.Platform.Authorization.Constants; | ||
using Altinn.Platform.Authorization.Models; | ||
using Altinn.Platform.Authorization.Services.Interface; | ||
using AltinnCore.Authentication.Constants; | ||
using Microsoft.AspNetCore.Authorization; | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace Altinn.Platform.Authorization.Controllers; | ||
|
||
/// <summary> | ||
/// Contains all actions related to the roles model | ||
/// </summary> | ||
[Route("authorization/api/v1/accesslist")] | ||
[ApiController] | ||
public class AccessListAuthorizationController : ControllerBase | ||
{ | ||
private readonly IAccessListAuthorization _accessListAuthorization; | ||
private readonly IResourceRegistry _resourceRegistry; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="AccessListAuthorizationController"/> class | ||
/// </summary> | ||
public AccessListAuthorizationController(IAccessListAuthorization accessListAuthorization, IResourceRegistry resourceRegistry) | ||
{ | ||
_accessListAuthorization = accessListAuthorization; | ||
_resourceRegistry = resourceRegistry; | ||
} | ||
|
||
/// <summary> | ||
/// Internal API for local cluster requests only. | ||
/// Authorization of a given subject for resource access through access lists for any service owner organization's access lists and resources. | ||
/// </summary> | ||
/// <param name="accessListAuthorizationRequest">Access list authorization request model</param> | ||
/// <param name="cancellationToken">The <see cref="CancellationToken"/></param> | ||
/// <returns>AccessListAuthorizationResponse</returns> | ||
[HttpPost] | ||
[Route("accessmanagement/authorization")] | ||
[ApiExplorerSettings(IgnoreApi = true)] | ||
[Authorize(Policy = AuthzConstants.POLICY_PLATFORMISSUER_ACCESSTOKEN)] | ||
[Consumes(MediaTypeNames.Application.Json)] | ||
[Produces(MediaTypeNames.Application.Json)] | ||
[ProducesResponseType(typeof(AccessListAuthorizationResponse), StatusCodes.Status200OK)] | ||
[ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)] | ||
[ProducesResponseType(typeof(void), StatusCodes.Status403Forbidden)] | ||
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status400BadRequest)] | ||
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status500InternalServerError)] | ||
public async Task<ActionResult> AuthorizeInternal(AccessListAuthorizationRequest accessListAuthorizationRequest, CancellationToken cancellationToken = default) | ||
{ | ||
Result<AccessListAuthorizationResponse> result = await _accessListAuthorization.Authorize(accessListAuthorizationRequest, cancellationToken); | ||
|
||
if (result.IsProblem) | ||
{ | ||
return result.Problem.ToActionResult(); | ||
} | ||
|
||
return Ok(result.Value); | ||
} | ||
} |
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,21 @@ | ||
#nullable enable | ||
|
||
using System.Net; | ||
using Altinn.Authorization.ProblemDetails; | ||
|
||
namespace Altinn.Authorization.Errors; | ||
|
||
/// <summary> | ||
/// Problem descriptors for Authorization | ||
/// </summary> | ||
public static class Problems | ||
{ | ||
private static readonly ProblemDescriptorFactory _factory | ||
= ProblemDescriptorFactory.New("AUTHZ"); | ||
|
||
/// <summary> | ||
/// Gets a <see cref="ProblemDescriptor"/> for not implemented feature. | ||
/// </summary> | ||
public static ProblemDescriptor NotImplemented { get; } | ||
= _factory.Create(0, HttpStatusCode.NotImplemented, "Not implemented."); | ||
} |
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,32 @@ | ||
#nullable enable | ||
|
||
using Altinn.Authorization.ProblemDetails; | ||
|
||
namespace Altinn.Authorization.Errors; | ||
|
||
/// <summary> | ||
/// Validation errors for Authorization | ||
/// </summary> | ||
public static class ValidationErrors | ||
{ | ||
private static readonly ValidationErrorDescriptorFactory _factory | ||
= ValidationErrorDescriptorFactory.New("AUTHZ"); | ||
|
||
/// <summary> | ||
/// Gets a validation error descriptor for when a provided resource registry identifier is not found as a valid resource. | ||
/// </summary> | ||
public static ValidationErrorDescriptor ResourceRegistry_ResourceIdentifier_NotFound { get; } | ||
= _factory.Create(0, "Unknown resource registry identifier."); | ||
|
||
/// <summary> | ||
/// Gets a validation error descriptor for when the authencticated organization number is not authorized as the competent authority owner of a resource registry resource. | ||
/// </summary> | ||
public static ValidationErrorDescriptor ResourceRegistry_CompetentAuthority_NotMatchingAuthenticatedOrganization { get; } | ||
= _factory.Create(1, "Authorized organization is not the competent authority owner of the requested resource."); | ||
|
||
/// <summary> | ||
/// Gets a validation error descriptor for when the authencticated organization code is not authorized as the competent authority owner of a resource registry resource. | ||
/// </summary> | ||
public static ValidationErrorDescriptor ResourceRegistry_CompetentAuthority_NotMatchingAuthenticatedOrgCode { get; } | ||
= _factory.Create(2, "Authorized organization code is not the competent authority owner of the requested resource."); | ||
} |
Oops, something went wrong.