Skip to content

Commit

Permalink
Merge branch 'main' into merge-main-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Phil91 committed Feb 23, 2024
2 parents 1e2aba8 + 7e90b38 commit 0621449
Show file tree
Hide file tree
Showing 32 changed files with 823 additions and 194 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/nuget-package-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,4 @@ jobs:
- name: Create git tag
uses: rickstaa/action-create-tag@v1
with:
tag: v${{ steps.nugetPackageVersion.outputs.version }}
tag: ${{ steps.nugetPackageVersion.outputs.version }}
19 changes: 17 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,22 @@

New features, fixed bugs, known defects and other noteworthy changes to each release of the Catena-X Portal Backend.

## 1.8.0-RC5
## 1.8.0-RC7

### Feature
* Certificate Management (Administration Service)
* released new endpoint to fetch own company certificate data incl sorting and filters - GET /api/administration/companydata/companyCertificates
* released new endpoint to fetch other company certificate data using businesspartner number via the new endpoint GET /api/administration/companydata/{businessPartnerNumber}/companyCertificates

### Bugfix
* fixed endpoint GET /api/administration/user/owncompany/users/{userid} missing assignments of firstname, lastname and email were added to busineslogic and setters were removed from company-user related record-definitions
* fixed endpoint api/administration/registration/application/{applicationId}/decline
* fixed bpdm interface connection
* switch from Put to Post for the sharing-state/ready call
* add BpdmSharingStateBusinessPartnerType 'GENERIC'
* add BpdmSharingStateType 'Ready'

## 1.8.0-RC6

### Feature
* Certificate Management (Administration Service)
Expand All @@ -20,7 +35,7 @@ New features, fixed bugs, known defects and other noteworthy changes to each rel
* Added ValidCompany Attribute to endpoint POST api/registration/network/{externalId}/decline to initialize the companyId of the current user correctly
* External Registration submission endpoint POST /api/registration/Network/partnerRegistration/submit fixed

## 1.8.0-RC4
## 1.8.0-RC5

### Change
* Registration Service
Expand Down
2 changes: 1 addition & 1 deletion scripts/get_current_version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ else
version="$version_prefix-framework"
fi

echo "Version: $version"
echo "v$version"
2 changes: 1 addition & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
<Project>
<PropertyGroup>
<VersionPrefix>1.8.0</VersionPrefix>
<VersionSuffix>RC6</VersionSuffix>
<VersionSuffix>RC7</VersionSuffix>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -577,4 +577,33 @@ await _mailingService.SendMails(requesterEmail, mailParameters, Enumerable.Repea
/// <inheritdoc />
public IAsyncEnumerable<VerifiedCredentialTypeId> GetCertificateTypes() =>
_portalRepositories.GetInstance<ICompanySsiDetailsRepository>().GetCertificateTypes(_identityData.CompanyId);

/// <inheritdoc />
public async IAsyncEnumerable<CompanyCertificateBpnData> GetCompanyCertificatesByBpn(string businessPartnerNumber)
{
if (string.IsNullOrWhiteSpace(businessPartnerNumber))
{
throw new ControllerArgumentException("businessPartnerNumber must not be empty");
}

var companyCertificateRepository = _portalRepositories.GetInstance<ICompanyCertificateRepository>();

var companyId = await companyCertificateRepository.GetCompanyIdByBpn(businessPartnerNumber).ConfigureAwait(false);
if (companyId == Guid.Empty)
{
throw new ControllerArgumentException($"company does not exist for {businessPartnerNumber}");
}

await foreach (var data in companyCertificateRepository.GetCompanyCertificateData(companyId))
{
yield return data;
}
}

public Task<Pagination.Response<CompanyCertificateData>> GetAllCompanyCertificatesAsync(int page, int size, CertificateSorting? sorting, CompanyCertificateStatusId? certificateStatus, CompanyCertificateTypeId? certificateType) =>
Pagination.CreateResponseAsync(
page,
size,
_settings.MaxPageSize,
_portalRepositories.GetInstance<ICompanyCertificateRepository>().GetActiveCompanyCertificatePaginationSource(sorting, certificateStatus, certificateType, _identityData.CompanyId));
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ public interface ICompanyDataBusinessLogic
Task RejectCredential(Guid credentialId);

IAsyncEnumerable<VerifiedCredentialTypeId> GetCertificateTypes();

IAsyncEnumerable<CompanyCertificateBpnData> GetCompanyCertificatesByBpn(string businessPartnerNumber);
Task CreateCompanyCertificate(CompanyCertificateCreationData data, CancellationToken cancellationToken);

Task<Pagination.Response<CompanyCertificateData>> GetAllCompanyCertificatesAsync(int page, int size, CertificateSorting? sorting, CompanyCertificateStatusId? certificateStatus, CompanyCertificateTypeId? certificateType);
}
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,8 @@ public async Task DeclineRegistrationVerification(Guid applicationId, string com
await _provisioningManager.DeleteCentralRealmUserAsync(iamUserId).ConfigureAwait(false);
}
}

var emailData = await _portalRepositories.GetInstance<IApplicationRepository>().GetEmailDataUntrackedAsync(applicationId).ToListAsync(cancellationToken).ConfigureAwait(false);
userRepository.AttachAndModifyIdentities(companyUserIds.Select(userId => new ValueTuple<Guid, Action<Identity>?, Action<Identity>>(userId, null, identity => { identity.UserStatusId = UserStatusId.DELETED; })));

_checklistService.FinalizeChecklistEntryAndProcessSteps(
Expand All @@ -512,17 +514,17 @@ public async Task DeclineRegistrationVerification(Guid applicationId, string com
: new[] { ProcessStepTypeId.TRIGGER_CALLBACK_OSP_DECLINED });

await _portalRepositories.SaveAsync().ConfigureAwait(false);
await PostRegistrationCancelEmailAsync(applicationId, companyName, comment).ConfigureAwait(false);
await PostRegistrationCancelEmailAsync(emailData, companyName, comment).ConfigureAwait(false);
}

private async Task PostRegistrationCancelEmailAsync(Guid applicationId, string companyName, string comment)
private async Task PostRegistrationCancelEmailAsync(ICollection<EmailData> emailData, string companyName, string comment)
{
if (string.IsNullOrWhiteSpace(comment))
{
throw new ConflictException("No comment set.");
}

await foreach (var user in _portalRepositories.GetInstance<IApplicationRepository>().GetEmailDataUntrackedAsync(applicationId).ConfigureAwait(false))
foreach (var user in emailData)
{
var userName = string.Join(" ", new[] { user.FirstName, user.LastName }.Where(item => !string.IsNullOrWhiteSpace(item)));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,10 @@ await Task.WhenAll(details.IdpUserIds.Select(async x =>
new IdpUserId(
await GetDisplayName(x.Alias ?? throw new ConflictException("Alias must not be null")).ConfigureAwait(false),
x.Alias,
x.UserId))).ConfigureAwait(false));
x.UserId))).ConfigureAwait(false),
details.FirstName,
details.LastName,
details.Email);
}

public async Task<int> AddOwnCompanyUsersBusinessPartnerNumbersAsync(Guid userId, IEnumerable<string> businessPartnerNumbers)
Expand Down Expand Up @@ -366,7 +369,10 @@ await Task.WhenAll(details.IdpUserIds.Select(async x =>
new IdpUserId(
await GetDisplayName(x.Alias ?? throw new ConflictException("Alias must not be null")).ConfigureAwait(false),
x.Alias,
x.UserId))).ConfigureAwait(false));
x.UserId))).ConfigureAwait(false),
details.FirstName,
details.LastName,
details.Email);
}

public async Task<CompanyUserDetails> UpdateOwnUserDetails(Guid companyUserId, OwnCompanyUserEditableDetails ownCompanyUserEditableDetails)
Expand Down Expand Up @@ -419,12 +425,10 @@ await _provisioningManager.UpdateSharedRealmUserAsync(
userData.BusinessPartnerNumbers,
companyUser.CompanyName,
companyUser.UserStatusId,
userData.AssignedRoles)
{
FirstName = companyUser.Firstname,
LastName = companyUser.Lastname,
Email = companyUser.Email
};
userData.AssignedRoles,
companyUser.Firstname,
companyUser.Lastname,
companyUser.Email);
}

public async Task<int> DeleteOwnUserAsync(Guid companyUserId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,44 @@ public async Task<NoContentResult> CreateCompanyCertificate([FromForm] CompanyCe
return NoContent();
}

/// <summary>
/// Gets the companyCertificates Details
/// </summary>
/// <returns>the companyCertificates details</returns>
/// <remarks>Example: GET: api/administration/companydata/businessPartnerNumber}/companyCertificates</remarks>
/// <response code="200">Returns the companyCertificates details.</response>
[HttpGet]
[Authorize(Roles = "view_certificates")]
[Authorize(Policy = PolicyTypes.ValidCompany)]
[Route("company/{businessPartnerNumber}/companyCertificates")]
[ProducesResponseType(typeof(IEnumerable<CompanyCertificateBpnData>), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status400BadRequest)]
[ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status404NotFound)]
[ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status409Conflict)]
public IAsyncEnumerable<CompanyCertificateBpnData> GetCompanyCertificatesByBpn(string businessPartnerNumber) =>
_logic.GetCompanyCertificatesByBpn(businessPartnerNumber);

/// <summary>
/// Retrieves all company certificates with respect userId.
/// </summary>
/// <param name="page" example="0">Optional the page of company certificate.</param>
/// <param name="size" example="15">Amount of company certificate, default is 15.</param>
/// <param name="sorting" example="CertificateTypeAsc">Optional Sorting of the pagination</param>
/// <param name="certificateStatus" example="">Optional filter for company certificate status</param>
/// <param name="certificateType" example="">Optional filter for company certificate type</param>
/// <returns>Collection of all active company certificates.</returns>
/// <remarks>Example: GET /api/administration/companydata/companyCertificates</remarks>
/// <response code="200">Returns the list of all active company certificates.</response>
[HttpGet]
[Route("companyCertificates")]
[Authorize(Roles = "view_certificates")]
[Authorize(Policy = PolicyTypes.ValidIdentity)]
[Authorize(Policy = PolicyTypes.ValidCompany)]
[ProducesResponseType(typeof(Pagination.Response<ServiceOverviewData>), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status204NoContent)]
public Task<Pagination.Response<CompanyCertificateData>> GetAllCompanyCertificatesAsync([FromQuery] int page = 0, [FromQuery] int size = 15, [FromQuery] CertificateSorting? sorting = null, [FromQuery] CompanyCertificateStatusId? certificateStatus = null, [FromQuery] CompanyCertificateTypeId? certificateType = null) =>
_logic.GetAllCompanyCertificatesAsync(page, size, sorting, certificateStatus, certificateType);

/// <summary>
/// Gets all outstanding, existing and inactive credentials
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/********************************************************************************
* Copyright (c) 2021, 2023 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/

using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models;
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums;
using System.Text.Json.Serialization;

namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Models;

public record CompanyUserData(
[property: JsonPropertyName("companyUserId")]
Guid CompanyUserId,
[property: JsonPropertyName("status")]
UserStatusId UserStatusId,
[property: JsonPropertyName("firstName")]
string? FirstName,
[property: JsonPropertyName("lastName")]
string? LastName,
[property: JsonPropertyName("email")]
string? Email,
[property: JsonPropertyName("roles")]
IEnumerable<UserRoleData> Roles,
[property: JsonPropertyName("idpUserIds")]
IEnumerable<IdpUserId> IdpUserIds
);
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,22 @@
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/

using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models;
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums;
using System.Text.Json.Serialization;

namespace Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models;
namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Models;

public record CompanyUserDetails(
[property: JsonPropertyName("companyUserId")] Guid CompanyUserId,
[property: JsonPropertyName("created")] DateTimeOffset CreatedAt,
[property: JsonPropertyName("bpn")] IEnumerable<string> BusinessPartnerNumbers,
[property: JsonPropertyName("company")] string CompanyName,
[property: JsonPropertyName("status")] UserStatusId UserStatusId,
[property: JsonPropertyName("assignedRoles")] IEnumerable<CompanyUserAssignedRoleDetails> AssignedRoles)
{
[JsonPropertyName("firstName")]
public string? FirstName { get; set; }

[JsonPropertyName("lastName")]
public string? LastName { get; set; }

[JsonPropertyName("email")]
public string? Email { get; set; }
}
[property: JsonPropertyName("assignedRoles")] IEnumerable<CompanyUserAssignedRoleDetails> AssignedRoles,
[property: JsonPropertyName("firstName")] string? FirstName,
[property: JsonPropertyName("lastName")] string? LastName,
[property: JsonPropertyName("email")] string? Email);

public record CompanyUserDetailData(
[property: JsonPropertyName("companyUserId")] Guid CompanyUserId,
Expand All @@ -47,17 +41,10 @@ public record CompanyUserDetailData(
[property: JsonPropertyName("company")] string CompanyName,
[property: JsonPropertyName("status")] UserStatusId UserStatusId,
[property: JsonPropertyName("assignedRoles")] IEnumerable<CompanyUserAssignedRoleDetails> AssignedRoles,
[property: JsonPropertyName("idpUserIds")] IEnumerable<IdpUserId> IdpUserIds)
{
[JsonPropertyName("firstName")]
public string? FirstName { get; set; }

[JsonPropertyName("lastName")]
public string? LastName { get; set; }

[JsonPropertyName("email")]
public string? Email { get; set; }
}
[property: JsonPropertyName("idpUserIds")] IEnumerable<IdpUserId> IdpUserIds,
[property: JsonPropertyName("firstName")] string? FirstName,
[property: JsonPropertyName("lastName")] string? LastName,
[property: JsonPropertyName("email")] string? Email);

public record CompanyOwnUserDetails(
[property: JsonPropertyName("companyUserId")] Guid CompanyUserId,
Expand All @@ -67,70 +54,12 @@ public record CompanyOwnUserDetails(
[property: JsonPropertyName("status")] UserStatusId UserStatusId,
[property: JsonPropertyName("assignedRoles")] IEnumerable<CompanyUserAssignedRoleDetails> AssignedRoles,
[property: JsonPropertyName("admin")] IEnumerable<CompanyUserAdminDetails> AdminDetails,
[property: JsonPropertyName("idpUserIds")] IEnumerable<IdpUserId> IdpUserIds)
{
[JsonPropertyName("firstName")]
public string? FirstName { get; set; }

[JsonPropertyName("lastName")]
public string? LastName { get; set; }

[JsonPropertyName("email")]
public string? Email { get; set; }
}

public record CompanyUserAdminDetails(
[property: JsonPropertyName("id")] Guid CompanyUserId,
[property: JsonPropertyName("idpUserIds")] IEnumerable<IdpUserId> IdpUserIds,
[property: JsonPropertyName("firstName")] string? FirstName,
[property: JsonPropertyName("lastName")] string? LastName,
[property: JsonPropertyName("email")] string? Email);

public record CompanyUserAssignedRoleDetails(
[property: JsonPropertyName("appId")] Guid OfferId,
[property: JsonPropertyName("roles")] IEnumerable<string> UserRoles);

public record IdpUserId(
[property: JsonPropertyName("idpDisplayName")] string IdpDisplayName,
[property: JsonPropertyName("idpAlias")] string IdpAlias,
[property: JsonPropertyName("userId")] string UserId);

public record CompanyOwnUserTransferDetails(
[property: JsonPropertyName("companyUserId")] Guid CompanyUserId,
[property: JsonPropertyName("created")] DateTimeOffset CreatedAt,
[property: JsonPropertyName("bpn")] IEnumerable<string> BusinessPartnerNumbers,
[property: JsonPropertyName("company")] string CompanyName,
[property: JsonPropertyName("status")] UserStatusId UserStatusId,
[property: JsonPropertyName("assignedRoles")] IEnumerable<CompanyUserAssignedRoleDetails> AssignedRoles,
[property: JsonPropertyName("admin")] IEnumerable<CompanyUserAdminDetails> AdminDetails,
[property: JsonPropertyName("idpUserIds")] IEnumerable<IdpUserTransferId> IdpUserIds)
{
[JsonPropertyName("firstName")]
public string? FirstName { get; set; }

[JsonPropertyName("lastName")]
public string? LastName { get; set; }

[JsonPropertyName("email")]
public string? Email { get; set; }
}

public record CompanyUserDetailTransferData(
[property: JsonPropertyName("companyUserId")] Guid CompanyUserId,
[property: JsonPropertyName("created")] DateTimeOffset CreatedAt,
[property: JsonPropertyName("bpn")] IEnumerable<string> BusinessPartnerNumbers,
[property: JsonPropertyName("company")] string CompanyName,
[property: JsonPropertyName("status")] UserStatusId UserStatusId,
[property: JsonPropertyName("assignedRoles")] IEnumerable<CompanyUserAssignedRoleDetails> AssignedRoles,
[property: JsonPropertyName("idpUserIds")] IEnumerable<IdpUserTransferId> IdpUserIds)
{
[JsonPropertyName("firstName")]
public string? FirstName { get; set; }

[JsonPropertyName("lastName")]
public string? LastName { get; set; }

[JsonPropertyName("email")]
public string? Email { get; set; }
}

public record IdpUserTransferId(
[property: JsonPropertyName("alias")] string? Alias,
[property: JsonPropertyName("userId")] string UserId);
7 changes: 0 additions & 7 deletions src/administration/Administration.Service/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,6 @@
"ClientSecret": "",
"AuthRealm": "",
"UseAuthTrail": false
},
"shareddelete": {
"ConnectionString": "",
"ClientId": "",
"ClientSecret": "",
"AuthRealm": "",
"UseAuthTrail": false
}
},
"ConnectionStrings": {
Expand Down
Loading

0 comments on commit 0621449

Please sign in to comment.