Skip to content

Commit

Permalink
feat(n2n): add network registration (#255)
Browse files Browse the repository at this point in the history
adjust POST: api/administration/identityprovider/owncompany/identityproviders
* add onboardingServiceProviderId to companyApplication
* feat(n2n): add partner registration
* add registration database changes
* add user synchronization process
* add seeding for n2n
* tests: add tests for n2n
* feat(n2n): add retrigger endpoint
* chore: update DEPENDENCIES file
* feat(n2n): send mail for n2n registration
* feat(n2n): adjust mail template
* chore: use CreateOwnCompanyIdpUsersAsync
* feat(n2n): add additional data to networkRegistration
* fix(n2n): set correct idp link data
* chore(networkregistration): optimize input validation
* feat(n2n): adjust registration request
* tests: add unit tests for n2n executor
Refs: CPLP-2637, CPLP-3151, CPLP-3145, CPLP-3146, CPLP-3149, CPLP-3150, CPLP-3200
---------
Co-authored-by: Norbert Truchsess <norbert.truchsess@t-online.de>
Reviewed-by: Norbert Truchsess <norbert.truchsess@t-online.de>
  • Loading branch information
Phil91 authored Sep 21, 2023
1 parent f40605d commit aae9911
Show file tree
Hide file tree
Showing 109 changed files with 12,232 additions and 191 deletions.
60 changes: 60 additions & 0 deletions src/Portal.Backend.sln
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,14 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mailing.Service", "mailing\
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mailing.Service.Tests", "..\tests\mailing\Mailing.Service.Tests\Mailing.Service.Tests.csproj", "{1EAF34DA-6D16-4F5E-86F4-344185F53942}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetworkRegistration.Executor", "processes\NetworkRegistration.Executor\NetworkRegistration.Executor.csproj", "{19639645-A115-4824-865F-5559DA8B892A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetworkRegistration.Library.Tests", "..\tests\processes\NetworkRegistration.Library.Tests\NetworkRegistration.Library.Tests.csproj", "{3B41408A-CDFE-4EEE-9660-FE6755FD2075}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetworkRegistration.Library", "processes\NetworkRegistration.Library\NetworkRegistration.Library.csproj", "{C53EAB34-1F66-48F8-88AB-226BE142D1CF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetworkRegistration.Executor", "..\tests\processes\NetworkRegistration.Executor\NetworkRegistration.Executor.csproj", "{469F8BD7-C2A7-4C5B-8280-095C7102E60E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -1368,6 +1376,54 @@ Global
{1EAF34DA-6D16-4F5E-86F4-344185F53942}.Release|x64.Build.0 = Release|Any CPU
{1EAF34DA-6D16-4F5E-86F4-344185F53942}.Release|x86.ActiveCfg = Release|Any CPU
{1EAF34DA-6D16-4F5E-86F4-344185F53942}.Release|x86.Build.0 = Release|Any CPU
{19639645-A115-4824-865F-5559DA8B892A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{19639645-A115-4824-865F-5559DA8B892A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{19639645-A115-4824-865F-5559DA8B892A}.Debug|x64.ActiveCfg = Debug|Any CPU
{19639645-A115-4824-865F-5559DA8B892A}.Debug|x64.Build.0 = Debug|Any CPU
{19639645-A115-4824-865F-5559DA8B892A}.Debug|x86.ActiveCfg = Debug|Any CPU
{19639645-A115-4824-865F-5559DA8B892A}.Debug|x86.Build.0 = Debug|Any CPU
{19639645-A115-4824-865F-5559DA8B892A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{19639645-A115-4824-865F-5559DA8B892A}.Release|Any CPU.Build.0 = Release|Any CPU
{19639645-A115-4824-865F-5559DA8B892A}.Release|x64.ActiveCfg = Release|Any CPU
{19639645-A115-4824-865F-5559DA8B892A}.Release|x64.Build.0 = Release|Any CPU
{19639645-A115-4824-865F-5559DA8B892A}.Release|x86.ActiveCfg = Release|Any CPU
{19639645-A115-4824-865F-5559DA8B892A}.Release|x86.Build.0 = Release|Any CPU
{3B41408A-CDFE-4EEE-9660-FE6755FD2075}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3B41408A-CDFE-4EEE-9660-FE6755FD2075}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3B41408A-CDFE-4EEE-9660-FE6755FD2075}.Debug|x64.ActiveCfg = Debug|Any CPU
{3B41408A-CDFE-4EEE-9660-FE6755FD2075}.Debug|x64.Build.0 = Debug|Any CPU
{3B41408A-CDFE-4EEE-9660-FE6755FD2075}.Debug|x86.ActiveCfg = Debug|Any CPU
{3B41408A-CDFE-4EEE-9660-FE6755FD2075}.Debug|x86.Build.0 = Debug|Any CPU
{3B41408A-CDFE-4EEE-9660-FE6755FD2075}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3B41408A-CDFE-4EEE-9660-FE6755FD2075}.Release|Any CPU.Build.0 = Release|Any CPU
{3B41408A-CDFE-4EEE-9660-FE6755FD2075}.Release|x64.ActiveCfg = Release|Any CPU
{3B41408A-CDFE-4EEE-9660-FE6755FD2075}.Release|x64.Build.0 = Release|Any CPU
{3B41408A-CDFE-4EEE-9660-FE6755FD2075}.Release|x86.ActiveCfg = Release|Any CPU
{3B41408A-CDFE-4EEE-9660-FE6755FD2075}.Release|x86.Build.0 = Release|Any CPU
{C53EAB34-1F66-48F8-88AB-226BE142D1CF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C53EAB34-1F66-48F8-88AB-226BE142D1CF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C53EAB34-1F66-48F8-88AB-226BE142D1CF}.Debug|x64.ActiveCfg = Debug|Any CPU
{C53EAB34-1F66-48F8-88AB-226BE142D1CF}.Debug|x64.Build.0 = Debug|Any CPU
{C53EAB34-1F66-48F8-88AB-226BE142D1CF}.Debug|x86.ActiveCfg = Debug|Any CPU
{C53EAB34-1F66-48F8-88AB-226BE142D1CF}.Debug|x86.Build.0 = Debug|Any CPU
{C53EAB34-1F66-48F8-88AB-226BE142D1CF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C53EAB34-1F66-48F8-88AB-226BE142D1CF}.Release|Any CPU.Build.0 = Release|Any CPU
{C53EAB34-1F66-48F8-88AB-226BE142D1CF}.Release|x64.ActiveCfg = Release|Any CPU
{C53EAB34-1F66-48F8-88AB-226BE142D1CF}.Release|x64.Build.0 = Release|Any CPU
{C53EAB34-1F66-48F8-88AB-226BE142D1CF}.Release|x86.ActiveCfg = Release|Any CPU
{C53EAB34-1F66-48F8-88AB-226BE142D1CF}.Release|x86.Build.0 = Release|Any CPU
{469F8BD7-C2A7-4C5B-8280-095C7102E60E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{469F8BD7-C2A7-4C5B-8280-095C7102E60E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{469F8BD7-C2A7-4C5B-8280-095C7102E60E}.Debug|x64.ActiveCfg = Debug|Any CPU
{469F8BD7-C2A7-4C5B-8280-095C7102E60E}.Debug|x64.Build.0 = Debug|Any CPU
{469F8BD7-C2A7-4C5B-8280-095C7102E60E}.Debug|x86.ActiveCfg = Debug|Any CPU
{469F8BD7-C2A7-4C5B-8280-095C7102E60E}.Debug|x86.Build.0 = Debug|Any CPU
{469F8BD7-C2A7-4C5B-8280-095C7102E60E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{469F8BD7-C2A7-4C5B-8280-095C7102E60E}.Release|Any CPU.Build.0 = Release|Any CPU
{469F8BD7-C2A7-4C5B-8280-095C7102E60E}.Release|x64.ActiveCfg = Release|Any CPU
{469F8BD7-C2A7-4C5B-8280-095C7102E60E}.Release|x64.Build.0 = Release|Any CPU
{469F8BD7-C2A7-4C5B-8280-095C7102E60E}.Release|x86.ActiveCfg = Release|Any CPU
{469F8BD7-C2A7-4C5B-8280-095C7102E60E}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -1471,5 +1527,9 @@ Global
{9D574E57-75A6-4965-AF23-ACE0BB9CD0B3} = {323C198D-A8C6-4EB0-8B79-72624275E35F}
{E1D41A07-F468-4D13-8185-35F127230B17} = {46383371-8252-4598-9350-A97692851408}
{6113B579-C995-47F8-9AC1-4CC6EFDDD883} = {68D43DB1-DFC5-4F15-A2B4-6BA18B875F9E}
{19639645-A115-4824-865F-5559DA8B892A} = {282CEF03-292F-4A49-83C6-997567D0FF5F}
{3B41408A-CDFE-4EEE-9660-FE6755FD2075} = {323C198D-A8C6-4EB0-8B79-72624275E35F}
{C53EAB34-1F66-48F8-88AB-226BE142D1CF} = {282CEF03-292F-4A49-83C6-997567D0FF5F}
{469F8BD7-C2A7-4C5B-8280-095C7102E60E} = {323C198D-A8C6-4EB0-8B79-72624275E35F}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
<ProjectReference Include="..\..\framework\Framework.Web\Framework.Web.csproj" />
<ProjectReference Include="..\..\mailing\Mailing.SendMail\Mailing.SendMail.csproj" />
<ProjectReference Include="..\..\notifications\Notifications.Library\Notifications.Library.csproj" />
<ProjectReference Include="..\..\processes\NetworkRegistration.Library\NetworkRegistration.Library.csproj" />
<ProjectReference Include="..\..\processes\OfferSubscription.Library\OfferSubscription.Library.csproj" />
<ProjectReference Include="..\..\provisioning\Provisioning.Library\Provisioning.Library.csproj" />
<ProjectReference Include="..\..\portalbackend\PortalBackend.DBAccess\PortalBackend.DBAccess.csproj" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/********************************************************************************
* Copyright (c) 2021, 2023 BMW Group AG
* 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.Administration.Service.Models;
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums;

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

public interface INetworkBusinessLogic
{
Task HandlePartnerRegistration(PartnerRegistrationData data);

Task RetriggerSynchronizeUser(Guid externalId, ProcessStepTypeId processStepTypeId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,18 @@ public ValueTask<IdentityProviderDetails> CreateOwnCompanyIdentityProviderAsync(
IamIdentityProviderProtocol.OIDC => IdentityProviderCategoryId.KEYCLOAK_OIDC,
_ => throw new ControllerArgumentException($"unexcepted value of protocol: '{protocol}'", nameof(protocol))
};
var requiredCompanyRoles = typeId switch
{
IdentityProviderTypeId.OWN => Enumerable.Empty<CompanyRoleId>(),
IdentityProviderTypeId.MANAGED => new[] { CompanyRoleId.OPERATOR, CompanyRoleId.ONBOARDING_SERVICE_PROVIDER },
_ => throw new ControllerArgumentException($"creation of identityProviderType {typeId} is not supported")
};
if (displayName != null)
{
ValidateDisplayName(displayName);
}

return CreateOwnCompanyIdentityProviderInternalAsync(identityProviderCategory, protocol, typeId, displayName);
return CreateOwnCompanyIdentityProviderInternalAsync(identityProviderCategory, protocol, typeId, displayName, requiredCompanyRoles);
}

private static void ValidateDisplayName(string displayName)
Expand All @@ -98,16 +104,10 @@ private static void ValidateDisplayName(string displayName)
}
}

private async ValueTask<IdentityProviderDetails> CreateOwnCompanyIdentityProviderInternalAsync(IdentityProviderCategoryId identityProviderCategory, IamIdentityProviderProtocol protocol, IdentityProviderTypeId typeId, string? displayName)
private async ValueTask<IdentityProviderDetails> CreateOwnCompanyIdentityProviderInternalAsync(IdentityProviderCategoryId identityProviderCategory, IamIdentityProviderProtocol protocol, IdentityProviderTypeId typeId, string? displayName, IEnumerable<CompanyRoleId> requiredCompanyRoles)
{
var companyId = _identityService.IdentityData.CompanyId;
var identityProviderRepository = _portalRepositories.GetInstance<IIdentityProviderRepository>();
var requiredCompanyRoles = typeId switch
{
IdentityProviderTypeId.OWN => Enumerable.Empty<CompanyRoleId>(),
IdentityProviderTypeId.MANAGED => new[] { CompanyRoleId.OPERATOR, CompanyRoleId.ONBOARDING_SERVICE_PROVIDER },
_ => throw new ControllerArgumentException($"creation of identityProviderType {typeId} is not supported")
};
var result = await _portalRepositories.GetInstance<ICompanyRepository>().CheckCompanyAndCompanyRolesAsync(companyId, requiredCompanyRoles).ConfigureAwait(false);
if (!result.IsValidCompany)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ private async Task ExecuteInvitationInternalAsync(CompanyInvitationData invitati
company.Name,
null,
idpName,
identityProvider.Id,
true
);

Expand All @@ -116,7 +117,9 @@ private async Task ExecuteInvitationInternalAsync(CompanyInvitationData invitati
invitationData.email,
roleDatas,
string.IsNullOrWhiteSpace(invitationData.userName) ? invitationData.email : invitationData.userName,
""
"",
UserStatusId.ACTIVE,
true
)}.ToAsyncEnumerable();

var (companyUserId, _, password, error) = await _userProvisioningService.CreateOwnCompanyIdpUsersAsync(companyNameIdpAliasData, userCreationInfoIdps).SingleAsync().ConfigureAwait(false);
Expand Down
Loading

0 comments on commit aae9911

Please sign in to comment.