Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove delegationcheck #440

Merged
merged 32 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
b1311bc
remove delegation check + use new create endpoint WIP
mgunnerud Oct 29, 2024
d8ab825
remove dead code
mgunnerud Oct 29, 2024
ee417f0
add problemDetails mapper
mgunnerud Oct 29, 2024
136d364
fix warnings + remove dead code
mgunnerud Oct 29, 2024
7eca096
fix warning
mgunnerud Oct 30, 2024
c1e9c3e
fix merge conflict
mgunnerud Nov 4, 2024
c42c687
Merge remote-tracking branch 'origin/main' into chore/remove-delegati…
mgunnerud Nov 18, 2024
38abd34
return 404 if request is not found
mgunnerud Nov 18, 2024
6b03937
show specific error message for request id not found
mgunnerud Nov 18, 2024
fe54a05
fix return type
mgunnerud Nov 18, 2024
18c6dec
add translations for delegation errors
mgunnerud Nov 20, 2024
a0f74d1
move parameter to pathname
mgunnerud Nov 20, 2024
112e03f
fix texts
mgunnerud Nov 20, 2024
7efef63
remove PDP mock + old dependencies
mgunnerud Nov 21, 2024
230e9c6
improve msw mock code + change mock to typescript
mgunnerud Nov 21, 2024
725b044
fix after change in backend
mgunnerud Nov 26, 2024
9cdcddb
merge med main
mgunnerud Nov 26, 2024
ada3387
update problem mapping
mgunnerud Nov 27, 2024
f92be43
fix merge conflicts
mgunnerud Nov 28, 2024
d5821a9
fixes
mgunnerud Nov 28, 2024
5e5f6f8
temp test fix
mgunnerud Nov 28, 2024
4d10610
minor size change
mgunnerud Nov 28, 2024
09810b1
remove logging information message
mgunnerud Nov 28, 2024
f21fb2a
add problem detail for non-existing system
mgunnerud Nov 29, 2024
8c14c9e
show error message if system is not found
mgunnerud Nov 29, 2024
4aa9c6e
test for not existing system
mgunnerud Nov 29, 2024
42ba4d3
rollback test change
mgunnerud Nov 29, 2024
652747f
Update build-deploy-at.yml
mgunnerud Nov 29, 2024
c8b010c
add Authorize attribute back
mgunnerud Nov 29, 2024
291fb0b
Merge branch 'chore/remove-delegationcheck' of https://github.com/Alt…
mgunnerud Nov 29, 2024
b1b8d15
fix error message mapping
mgunnerud Nov 29, 2024
bc76050
Merge branch 'main' into chore/remove-delegationcheck
mgunnerud Dec 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public static class HttpClientExtension
/// <param name="content">The http content.</param>
/// <param name="platformAccessToken">The platformAccess tokens.</param>
/// <returns>A HttpResponseMessage.</returns>
public static Task<HttpResponseMessage> PostAsync(this HttpClient httpClient, string authorizationToken, string requestUri, HttpContent content, string platformAccessToken = null)
public static Task<HttpResponseMessage> PostAsync(this HttpClient httpClient, string authorizationToken, string requestUri, HttpContent? content = null, string? platformAccessToken = null)
{
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, requestUri);
request.Headers.Add("Authorization", "Bearer " + authorizationToken);
Expand All @@ -36,7 +36,7 @@ public static Task<HttpResponseMessage> PostAsync(this HttpClient httpClient, st
/// <param name="content">The http content.</param>
/// <param name="platformAccessToken">The platformAccess tokens.</param>
/// <returns>A HttpResponseMessage.</returns>
public static Task<HttpResponseMessage> PutAsync(this HttpClient httpClient, string authorizationToken, string requestUri, HttpContent content, string platformAccessToken = null)
public static Task<HttpResponseMessage> PutAsync(this HttpClient httpClient, string authorizationToken, string requestUri, HttpContent content, string? platformAccessToken = null)
{
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Put, requestUri);
request.Headers.Add("Authorization", "Bearer " + authorizationToken);
Expand All @@ -57,7 +57,7 @@ public static Task<HttpResponseMessage> PutAsync(this HttpClient httpClient, str
/// <param name="requestUri">The request Uri.</param>
/// <param name="platformAccessToken">The platformAccess tokens.</param>
/// <returns>A HttpResponseMessage.</returns>
public static Task<HttpResponseMessage> GetAsync(this HttpClient httpClient, string authorizationToken, string requestUri, string platformAccessToken = null)
public static Task<HttpResponseMessage> GetAsync(this HttpClient httpClient, string authorizationToken, string requestUri, string? platformAccessToken = null)
{
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, requestUri);
request.Headers.Add("Authorization", "Bearer " + authorizationToken);
Expand All @@ -77,7 +77,7 @@ public static Task<HttpResponseMessage> GetAsync(this HttpClient httpClient, str
/// <param name="requestUri">The request Uri.</param>
/// <param name="platformAccessToken">The platformAccess tokens.</param>
/// <returns>A HttpResponseMessage.</returns>
public static Task<HttpResponseMessage> DeleteAsync(this HttpClient httpClient, string authorizationToken, string requestUri, string platformAccessToken = null)
public static Task<HttpResponseMessage> DeleteAsync(this HttpClient httpClient, string authorizationToken, string requestUri, string? platformAccessToken = null)
{
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Delete, requestUri);
request.Headers.Add("Authorization", "Bearer " + authorizationToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,46 @@ private static readonly ProblemDescriptorFactory _factory
public static ProblemDescriptor Generic_EndOfMethod { get; }
= _factory.Create(5, HttpStatusCode.BadRequest, "Default error at the end of logic chain. Not supposed to appear.");

/// <summary>
/// Gets a <see cref="ProblemDescriptor"/>.
/// </summary>
public static ProblemDescriptor RequestNotFound { get; }
= _factory.Create(10, HttpStatusCode.NotFound, "The request was not found for given party.");

/// <summary>
/// Gets a <see cref="ProblemDescriptor"/>.
/// </summary>
public static ProblemDescriptor SystemIdNotFound { get; }
= _factory.Create(11, HttpStatusCode.NotFound, "The Id does not refer to a Registered System.");

/// <summary>
/// Gets a <see cref="ProblemDescriptor"/>.
/// </summary>
public static ProblemDescriptor UnableToDoDelegationCheck { get; }
= _factory.Create(14, HttpStatusCode.InternalServerError, "DelegationCheck failed with unknown error.");

/// <summary>
/// Gets a <see cref="ProblemDescriptor"/>.
/// </summary>
public static ProblemDescriptor DelegationRightMissingRoleAccess { get; }
= _factory.Create(16, HttpStatusCode.Forbidden, "DelegationCheck failed with error: Has not access by a delegation of role in ER or Altinn.");

/// <summary>
/// Gets a <see cref="ProblemDescriptor"/>.
/// </summary>
public static ProblemDescriptor DelegationRightMissingDelegationAccess { get; }
= _factory.Create(18, HttpStatusCode.Forbidden, "DelegationCheck failed with error: Has not access by direct delegation.");

/// <summary>
/// Gets a <see cref="ProblemDescriptor"/>.
/// </summary>
public static ProblemDescriptor DelegationRightMissingSrrRightAccess { get; }
= _factory.Create(19, HttpStatusCode.Forbidden, "DelegationCheck failed with error: The service requires explicit access in SRR and the reportee is missing this.");

/// <summary>
/// Gets a <see cref="ProblemDescriptor"/>.
/// </summary>
public static ProblemDescriptor DelegationRightInsufficientAuthenticationLevel { get; }
= _factory.Create(20, HttpStatusCode.Forbidden, "DelegationCheck failed with error: The service requires explicit authentication level and the reportee is missing this.");

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using Altinn.Authorization.ProblemDetails;

namespace Altinn.Authentication.UI.Core.Common.Problems;
/// <summary>
/// Problem descriptors for the Authentication UI BFF.
/// </summary>
public static class ProblemMapper
{
public static ProblemDescriptor MapToAuthUiError(string? authErrorCode)
{
return authErrorCode switch
{
"AUTH-00001" => Problem.Rights_NotFound_Or_NotDelegable,
"AUTH-00002" => Problem.Rights_FailedToDelegate,
"AUTH-00003" => Problem.SystemUser_FailedToCreate,
"AUTH-00004" => Problem.SystemUser_AlreadyExists,
"AUTH-00011" => Problem.SystemIdNotFound,
"AUTH-00014" => Problem.UnableToDoDelegationCheck,
"AUTH-00016" => Problem.DelegationRightMissingRoleAccess,
"AUTH-00018" => Problem.DelegationRightMissingDelegationAccess,
"AUTH-00019" => Problem.DelegationRightMissingSrrRightAccess,
"AUTH-00020" => Problem.DelegationRightInsufficientAuthenticationLevel,
_ => Problem.Generic_EndOfMethod,
};
}
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ namespace Altinn.Authentication.UI.Core.SystemUsers;
public interface ISystemUserClient
{
Task<SystemUser?> GetSpecificSystemUserReal(int partyId, Guid id, CancellationToken cancellationToken = default);
Task<SystemUser?> PostNewSystemUserReal(int partyId, CreateSystemUserRequestToAuthComp newSystemUserDescriptor, CancellationToken cancellation = default);
Task<Result<SystemUser>> CreateSystemUser(int partyId, SystemUserRequestDto newSystemUser, CancellationToken cancellation = default);
Task<Result<bool>> DeleteSystemUserReal(int partyId, Guid id, CancellationToken cancellationToken = default);
Task<bool> ChangeSystemUserRealTitle(string newTitle, Guid id, CancellationToken cancellationToken = default);
Task<bool> ChangeSystemUserRealDescription(string newDescr, Guid id, CancellationToken cancellationToken = default);
Task<List<SystemUser>> GetSystemUserRealsForChosenUser(int id, CancellationToken cancellationToken = default);
Task<bool> ChangeSystemUserRealProduct(string selectedSystemType, Guid id, CancellationToken cancellationToken = default);
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,11 @@ public interface ISystemUserService
/// <summary>
/// Return all system users created for a given party
/// </summary>
Task<List<SystemUser>> GetAllSystemUsersForParty(int partyId, CancellationToken cancellationToken = default);
Task<Result<List<SystemUser>>> GetAllSystemUsersForParty(int partyId, CancellationToken cancellationToken = default);
Task<SystemUser?> GetSpecificSystemUserDTO(int partyId, Guid id, CancellationToken cancellationToken = default);

/// <summary>
/// Creates a system user
/// </summary>
Task<Result<SystemUser>> CreateSystemUser(int partyId, CreateSystemUserRequestToAuthComp newSystemUserDescriptor, CancellationToken cancellation = default);


Task<Result<SystemUser>> CreateSystemUser(int partyId, SystemUserRequestDto newSystemUserDescriptor, CancellationToken cancellation = default);

/// <summary>
/// Deletes system user
/// </summary>
Expand All @@ -27,14 +24,4 @@ public interface ISystemUserService
/// Change system user title
/// </summary>
Task<bool> ChangeSystemUserTitle(string newTitle, Guid id, CancellationToken cancellationToken = default);

/// <summary>
/// Change system user description
/// </summary>
Task<bool> ChangeSystemUserDescription(string newDescr, Guid id, CancellationToken cancellationToken = default);

/// <summary>
/// Change system user product. To do. Do we need this?
/// </summary>
Task<bool> ChangeSystemUserProduct(string selectedSystemType, Guid id, CancellationToken cancellationToken = default);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,25 @@

namespace Altinn.Authentication.UI.Core.SystemUsers;

public sealed record CreateSystemUserRequestGUI
/// <summary>
/// When the Frontend POST a new SystemUser this is the DTO
/// sent to the Authentication Component
/// </summary>
public class SystemUserRequestDto
{
/// <summary>
/// The Title is set by the end-user in the Frontend, by default it is the same as the System's Display Name
/// Even if this DTO allows null, the db field is of course still required
/// </summary>
[JsonPropertyName("integrationTitle")]
public string? IntegrationTitle { get; set; }
public string IntegrationTitle { get; set; }

/// <summary>
/// For off the shelf systems.
/// Should probably be human readable (instead of a GUID) but unique string without whitespace
/// The "real" Authentication Component should validate that the SystemName is unique
/// Retrieved from the SystemRegister, the full CRUD Api is in a different service
/// </summary>
[JsonPropertyName("selectedSystemType")]
public string? SelectedSystemType { get; set; }
[JsonPropertyName("systemId")]
public string SystemId { get; set; }
}
Loading
Loading