diff --git a/src/administration/Administration.Service/BusinessLogic/DocumentsBusinessLogic.cs b/src/administration/Administration.Service/BusinessLogic/DocumentsBusinessLogic.cs
index cf32908b8a..ebdd4d233d 100644
--- a/src/administration/Administration.Service/BusinessLogic/DocumentsBusinessLogic.cs
+++ b/src/administration/Administration.Service/BusinessLogic/DocumentsBusinessLogic.cs
@@ -26,6 +26,7 @@
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Repositories;
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities;
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums;
+using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Identities;
namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.BusinessLogic;
@@ -35,22 +36,24 @@ namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.BusinessLog
public class DocumentsBusinessLogic : IDocumentsBusinessLogic
{
private readonly IPortalRepositories _portalRepositories;
+ private readonly IIdentityService _identityService;
private readonly DocumentSettings _settings;
///
/// Creates a new instance
///
- public DocumentsBusinessLogic(IPortalRepositories portalRepositories, IOptions options)
+ public DocumentsBusinessLogic(IPortalRepositories portalRepositories, IIdentityService identityService, IOptions options)
{
_portalRepositories = portalRepositories;
+ _identityService = identityService;
_settings = options.Value;
}
///
- public async Task<(string FileName, byte[] Content, string MediaType)> GetDocumentAsync(Guid documentId, Guid companyId)
+ public async Task<(string FileName, byte[] Content, string MediaType)> GetDocumentAsync(Guid documentId)
{
var documentDetails = await _portalRepositories.GetInstance()
- .GetDocumentDataAndIsCompanyUserAsync(documentId, companyId)
+ .GetDocumentDataAndIsCompanyUserAsync(documentId, _identityService.IdentityData.CompanyId)
.ConfigureAwait(false);
if (documentDetails == default)
{
@@ -84,10 +87,10 @@ public DocumentsBusinessLogic(IPortalRepositories portalRepositories, IOptions
- public async Task DeleteDocumentAsync(Guid documentId, Guid companyUserId)
+ public async Task DeleteDocumentAsync(Guid documentId)
{
var documentRepository = _portalRepositories.GetInstance();
- var details = await documentRepository.GetDocumentDetailsForIdUntrackedAsync(documentId, companyUserId).ConfigureAwait(false);
+ var details = await documentRepository.GetDocumentDetailsForIdUntrackedAsync(documentId, _identityService.IdentityData.UserId).ConfigureAwait(false);
if (details.DocumentId == Guid.Empty)
{
diff --git a/src/administration/Administration.Service/BusinessLogic/IDocumentsBusinessLogic.cs b/src/administration/Administration.Service/BusinessLogic/IDocumentsBusinessLogic.cs
index cefe377cfe..cd90e89744 100644
--- a/src/administration/Administration.Service/BusinessLogic/IDocumentsBusinessLogic.cs
+++ b/src/administration/Administration.Service/BusinessLogic/IDocumentsBusinessLogic.cs
@@ -31,9 +31,8 @@ public interface IDocumentsBusinessLogic
/// Gets the document with the given id
///
/// Id of the document to get
- /// Company of the user
/// Returns the filename and content of the file
- Task<(string FileName, byte[] Content, string MediaType)> GetDocumentAsync(Guid documentId, Guid companyId);
+ Task<(string FileName, byte[] Content, string MediaType)> GetDocumentAsync(Guid documentId);
///
/// Gets the selfdescription document with the given id
@@ -46,9 +45,8 @@ public interface IDocumentsBusinessLogic
/// Deletes the document and the corresponding consent from the persistence layer.
///
/// Id of the document that should be deleted
- ///
/// Returns true if the document and corresponding consent were deleted successfully. Otherwise a specific error is thrown.
- Task DeleteDocumentAsync(Guid documentId, Guid companyUserId);
+ Task DeleteDocumentAsync(Guid documentId);
///
/// Gets the document as json for the seeding data
diff --git a/src/administration/Administration.Service/BusinessLogic/IIdentityProviderBusinessLogic.cs b/src/administration/Administration.Service/BusinessLogic/IIdentityProviderBusinessLogic.cs
index ad7198144a..d80c8a3ca8 100644
--- a/src/administration/Administration.Service/BusinessLogic/IIdentityProviderBusinessLogic.cs
+++ b/src/administration/Administration.Service/BusinessLogic/IIdentityProviderBusinessLogic.cs
@@ -33,12 +33,12 @@ public interface IIdentityProviderBusinessLogic
ValueTask SetOwnCompanyIdentityProviderStatusAsync(Guid identityProviderId, bool enabled);
ValueTask UpdateOwnCompanyIdentityProviderAsync(Guid identityProviderId, IdentityProviderEditableDetails details);
ValueTask DeleteCompanyIdentityProviderAsync(Guid identityProviderId);
- IAsyncEnumerable GetOwnCompanyUsersIdentityProviderDataAsync(IEnumerable identityProviderIds, Guid companyId, bool unlinkedUsersOnly);
- (Stream FileStream, string ContentType, string FileName, Encoding Encoding) GetOwnCompanyUsersIdentityProviderLinkDataStream(IEnumerable identityProviderIds, Guid companyId, bool unlinkedUsersOnly);
- ValueTask UploadOwnCompanyUsersIdentityProviderLinkDataAsync(IFormFile document, Guid companyId, CancellationToken cancellationToken);
- ValueTask CreateOwnCompanyUserIdentityProviderLinkDataAsync(Guid companyUserId, UserIdentityProviderLinkData identityProviderLinkData, Guid companyId);
- ValueTask CreateOrUpdateOwnCompanyUserIdentityProviderLinkDataAsync(Guid companyUserId, Guid identityProviderId, UserLinkData userLinkData, Guid companyId);
- ValueTask GetOwnCompanyUserIdentityProviderLinkDataAsync(Guid companyUserId, Guid identityProviderId, Guid companyId);
- ValueTask DeleteOwnCompanyUserIdentityProviderDataAsync(Guid companyUserId, Guid identityProviderId, Guid companyId);
+ IAsyncEnumerable GetOwnCompanyUsersIdentityProviderDataAsync(IEnumerable identityProviderIds, bool unlinkedUsersOnly);
+ (Stream FileStream, string ContentType, string FileName, Encoding Encoding) GetOwnCompanyUsersIdentityProviderLinkDataStream(IEnumerable identityProviderIds, bool unlinkedUsersOnly);
+ ValueTask UploadOwnCompanyUsersIdentityProviderLinkDataAsync(IFormFile document, CancellationToken cancellationToken);
+ ValueTask CreateOwnCompanyUserIdentityProviderLinkDataAsync(Guid companyUserId, UserIdentityProviderLinkData identityProviderLinkData);
+ ValueTask CreateOrUpdateOwnCompanyUserIdentityProviderLinkDataAsync(Guid companyUserId, Guid identityProviderId, UserLinkData userLinkData);
+ ValueTask GetOwnCompanyUserIdentityProviderLinkDataAsync(Guid companyUserId, Guid identityProviderId);
+ ValueTask DeleteOwnCompanyUserIdentityProviderDataAsync(Guid companyUserId, Guid identityProviderId);
ValueTask GetOwnIdentityProviderWithConnectedCompanies(Guid identityProviderId);
}
diff --git a/src/administration/Administration.Service/BusinessLogic/IServiceAccountBusinessLogic.cs b/src/administration/Administration.Service/BusinessLogic/IServiceAccountBusinessLogic.cs
index 74972bb9df..3e80897454 100644
--- a/src/administration/Administration.Service/BusinessLogic/IServiceAccountBusinessLogic.cs
+++ b/src/administration/Administration.Service/BusinessLogic/IServiceAccountBusinessLogic.cs
@@ -27,11 +27,11 @@ namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.BusinessLog
public interface IServiceAccountBusinessLogic
{
- Task CreateOwnCompanyServiceAccountAsync(ServiceAccountCreationInfo serviceAccountCreationInfos, Guid companyId);
- Task DeleteOwnCompanyServiceAccountAsync(Guid serviceAccountId, Guid companyId);
- Task GetOwnCompanyServiceAccountDetailsAsync(Guid serviceAccountId, Guid companyId);
- Task UpdateOwnCompanyServiceAccountDetailsAsync(Guid serviceAccountId, ServiceAccountEditableDetails serviceAccountDetails, Guid companyId);
- Task ResetOwnCompanyServiceAccountSecretAsync(Guid serviceAccountId, Guid companyId);
- Task> GetOwnCompanyServiceAccountsDataAsync(int page, int size, Guid companyId, string? clientId, bool? isOwner);
- IAsyncEnumerable GetServiceAccountRolesAsync(Guid companyId, string? languageShortName);
+ Task CreateOwnCompanyServiceAccountAsync(ServiceAccountCreationInfo serviceAccountCreationInfos);
+ Task DeleteOwnCompanyServiceAccountAsync(Guid serviceAccountId);
+ Task GetOwnCompanyServiceAccountDetailsAsync(Guid serviceAccountId);
+ Task UpdateOwnCompanyServiceAccountDetailsAsync(Guid serviceAccountId, ServiceAccountEditableDetails serviceAccountDetails);
+ Task ResetOwnCompanyServiceAccountSecretAsync(Guid serviceAccountId);
+ Task> GetOwnCompanyServiceAccountsDataAsync(int page, int size, string? clientId, bool? isOwner);
+ IAsyncEnumerable GetServiceAccountRolesAsync(string? languageShortName);
}
diff --git a/src/administration/Administration.Service/BusinessLogic/ISubscriptionConfigurationBusinessLogic.cs b/src/administration/Administration.Service/BusinessLogic/ISubscriptionConfigurationBusinessLogic.cs
index c2ee708094..a4163be04e 100644
--- a/src/administration/Administration.Service/BusinessLogic/ISubscriptionConfigurationBusinessLogic.cs
+++ b/src/administration/Administration.Service/BusinessLogic/ISubscriptionConfigurationBusinessLogic.cs
@@ -60,12 +60,12 @@ public interface ISubscriptionConfigurationBusinessLogic
///
/// Id of the users company
/// The detail data
- Task GetProviderCompanyDetailsAsync(Guid companyId);
+ Task GetProviderCompanyDetailsAsync();
///
/// Sets service provider company details
///
/// Detail data for the service provider
/// Id of the users company
- Task SetProviderCompanyDetailsAsync(ProviderDetailData data, Guid companyId);
+ Task SetProviderCompanyDetailsAsync(ProviderDetailData data);
}
diff --git a/src/administration/Administration.Service/BusinessLogic/IUserBusinessLogic.cs b/src/administration/Administration.Service/BusinessLogic/IUserBusinessLogic.cs
index cbf8b21a2f..ce4289f661 100644
--- a/src/administration/Administration.Service/BusinessLogic/IUserBusinessLogic.cs
+++ b/src/administration/Administration.Service/BusinessLogic/IUserBusinessLogic.cs
@@ -29,16 +29,16 @@ namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.BusinessLog
///
public interface IUserBusinessLogic
{
- IAsyncEnumerable CreateOwnCompanyUsersAsync(IEnumerable userList, (Guid UserId, Guid CompanyId) identity);
- Task CreateOwnCompanyIdpUserAsync(Guid identityProviderId, UserCreationInfoIdp userCreationInfo, (Guid UserId, Guid CompanyId) identity);
- Task> GetOwnCompanyUserDatasAsync(Guid companyId, int page, int size, GetOwnCompanyUsersFilter filter);
+ IAsyncEnumerable CreateOwnCompanyUsersAsync(IEnumerable userList);
+ Task CreateOwnCompanyIdpUserAsync(Guid identityProviderId, UserCreationInfoIdp userCreationInfo);
+ Task> GetOwnCompanyUserDatasAsync(int page, int size, GetOwnCompanyUsersFilter filter);
[Obsolete("to be replaced by UserRolesBusinessLogic.GetAppRolesAsync. Remove as soon frontend is adjusted")]
IAsyncEnumerable GetClientRolesAsync(Guid appId, string? languageShortName = null);
- Task GetOwnCompanyUserDetailsAsync(Guid userId, Guid companyId);
- Task AddOwnCompanyUsersBusinessPartnerNumbersAsync(Guid userId, IEnumerable businessPartnerNumbers, Guid companyId);
- Task AddOwnCompanyUsersBusinessPartnerNumberAsync(Guid userId, string businessPartnerNumber, Guid companyId);
- Task GetOwnUserDetails(Guid userId);
- Task UpdateOwnUserDetails(Guid companyUserId, OwnCompanyUserEditableDetails ownCompanyUserEditableDetails, Guid userId);
+ Task GetOwnCompanyUserDetailsAsync(Guid userId);
+ Task AddOwnCompanyUsersBusinessPartnerNumbersAsync(Guid userId, IEnumerable businessPartnerNumbers);
+ Task AddOwnCompanyUsersBusinessPartnerNumberAsync(Guid userId, string businessPartnerNumber);
+ Task GetOwnUserDetails();
+ Task UpdateOwnUserDetails(Guid companyUserId, OwnCompanyUserEditableDetails ownCompanyUserEditableDetails);
///
/// Delete User Own Account using userId
@@ -46,9 +46,9 @@ public interface IUserBusinessLogic
///
///
///
- Task DeleteOwnUserAsync(Guid companyUserId, Guid userId);
- IAsyncEnumerable DeleteOwnCompanyUsersAsync(IEnumerable userIds, Guid companyId);
- Task ExecuteOwnCompanyUserPasswordReset(Guid companyUserId, (Guid UserId, Guid CompanyId) identity);
- Task> GetOwnCompanyAppUsersAsync(Guid appId, Guid userId, int page, int size, CompanyUserFilter filter);
- Task DeleteOwnUserBusinessPartnerNumbersAsync(Guid userId, string businessPartnerNumber, (Guid UserId, Guid CompanyId) identity);
+ Task DeleteOwnUserAsync(Guid companyUserId);
+ IAsyncEnumerable DeleteOwnCompanyUsersAsync(IEnumerable userIds);
+ Task ExecuteOwnCompanyUserPasswordReset(Guid companyUserId);
+ Task> GetOwnCompanyAppUsersAsync(Guid appId, int page, int size, CompanyUserFilter filter);
+ Task DeleteOwnUserBusinessPartnerNumbersAsync(Guid userId, string businessPartnerNumber);
}
diff --git a/src/administration/Administration.Service/BusinessLogic/IUserRolesBusinessLogic.cs b/src/administration/Administration.Service/BusinessLogic/IUserRolesBusinessLogic.cs
index 1334043b2b..76f6022206 100644
--- a/src/administration/Administration.Service/BusinessLogic/IUserRolesBusinessLogic.cs
+++ b/src/administration/Administration.Service/BusinessLogic/IUserRolesBusinessLogic.cs
@@ -25,8 +25,8 @@ namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.BusinessLog
public interface IUserRolesBusinessLogic
{
- IAsyncEnumerable GetCoreOfferRoles(Guid companyId, string? languageShortName);
- IAsyncEnumerable GetAppRolesAsync(Guid appId, Guid companyId, string? languageShortName);
+ IAsyncEnumerable GetCoreOfferRoles(string? languageShortName);
+ IAsyncEnumerable GetAppRolesAsync(Guid appId, string? languageShortName);
///
/// Update Role to User
@@ -34,9 +34,8 @@ public interface IUserRolesBusinessLogic
///
///
///
- /// CompanyId of Admin User
/// messages
- Task> ModifyCoreOfferUserRolesAsync(Guid offerId, Guid companyUserId, IEnumerable roles, Guid companyId);
+ Task> ModifyCoreOfferUserRolesAsync(Guid offerId, Guid companyUserId, IEnumerable roles);
///
/// Update Role to User
@@ -44,17 +43,15 @@ public interface IUserRolesBusinessLogic
///
///
///
- /// CompanyId of Admin User
/// messages
- Task> ModifyAppUserRolesAsync(Guid appId, Guid companyUserId, IEnumerable roles, Guid companyId);
+ Task> ModifyAppUserRolesAsync(Guid appId, Guid companyUserId, IEnumerable roles);
///
/// Update Role to User
///
/// app Id
/// User and Role Information like CompanyUser Id and Role Name
- /// CompanyId of Admin User
/// messages
[Obsolete("to be replaced by endpoint UserRolesBusinessLogic.ModifyAppUserRolesAsync. Remove as soon frontend is adjusted")]
- Task> ModifyUserRoleAsync(Guid appId, UserRoleInfo userRoleInfo, Guid companyId);
+ Task> ModifyUserRoleAsync(Guid appId, UserRoleInfo userRoleInfo);
}
diff --git a/src/administration/Administration.Service/BusinessLogic/IUserUploadBusinessLogic.cs b/src/administration/Administration.Service/BusinessLogic/IUserUploadBusinessLogic.cs
index d984353291..95628f3ba7 100644
--- a/src/administration/Administration.Service/BusinessLogic/IUserUploadBusinessLogic.cs
+++ b/src/administration/Administration.Service/BusinessLogic/IUserUploadBusinessLogic.cs
@@ -24,6 +24,6 @@ namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.BusinessLog
public interface IUserUploadBusinessLogic
{
- ValueTask UploadOwnCompanyIdpUsersAsync(Guid identityProviderId, IFormFile document, (Guid UserId, Guid CompanyId) identity, CancellationToken cancellationToken);
- ValueTask UploadOwnCompanySharedIdpUsersAsync(IFormFile document, (Guid UserId, Guid CompanyId) identity, CancellationToken cancellationToken);
+ ValueTask UploadOwnCompanyIdpUsersAsync(Guid identityProviderId, IFormFile document, CancellationToken cancellationToken);
+ ValueTask UploadOwnCompanySharedIdpUsersAsync(IFormFile document, CancellationToken cancellationToken);
}
diff --git a/src/administration/Administration.Service/BusinessLogic/IdentityProviderBusinessLogic.cs b/src/administration/Administration.Service/BusinessLogic/IdentityProviderBusinessLogic.cs
index 6b6440652e..b9f3c6e231 100644
--- a/src/administration/Administration.Service/BusinessLogic/IdentityProviderBusinessLogic.cs
+++ b/src/administration/Administration.Service/BusinessLogic/IdentityProviderBusinessLogic.cs
@@ -138,8 +138,7 @@ private async ValueTask CreateOwnCompanyIdentityProvide
public async ValueTask GetOwnCompanyIdentityProviderAsync(Guid identityProviderId)
{
- var companyId = _identityService.IdentityData.CompanyId;
- var (alias, category, typeId) = await ValidateGetOwnCompanyIdentityProviderArguments(identityProviderId, companyId).ConfigureAwait(false);
+ var (alias, category, typeId) = await ValidateGetOwnCompanyIdentityProviderArguments(identityProviderId).ConfigureAwait(false);
return category switch
{
@@ -149,8 +148,9 @@ public async ValueTask GetOwnCompanyIdentityProviderAsy
};
}
- private async ValueTask<(string Alias, IdentityProviderCategoryId Category, IdentityProviderTypeId TypeId)> ValidateGetOwnCompanyIdentityProviderArguments(Guid identityProviderId, Guid companyId)
+ private async ValueTask<(string Alias, IdentityProviderCategoryId Category, IdentityProviderTypeId TypeId)> ValidateGetOwnCompanyIdentityProviderArguments(Guid identityProviderId)
{
+ var companyId = _identityService.IdentityData.CompanyId;
var (alias, category, isOwnOrOwnerCompany, typeId) = await _portalRepositories.GetInstance().GetOwnCompanyIdentityProviderAliasUntrackedAsync(identityProviderId, companyId).ConfigureAwait(false);
if (!isOwnOrOwnerCompany)
{
@@ -172,8 +172,7 @@ public async ValueTask GetOwnCompanyIdentityProviderAsy
public async ValueTask SetOwnCompanyIdentityProviderStatusAsync(Guid identityProviderId, bool enabled)
{
- var companyId = _identityService.IdentityData.CompanyId;
- var (category, alias, typeId) = await ValidateSetOwnCompanyIdentityProviderStatusArguments(identityProviderId, enabled, companyId).ConfigureAwait(false);
+ var (category, alias, typeId) = await ValidateSetOwnCompanyIdentityProviderStatusArguments(identityProviderId, enabled).ConfigureAwait(false);
switch (category)
{
@@ -191,8 +190,9 @@ public async ValueTask SetOwnCompanyIdentityProviderSta
}
}
- private async ValueTask<(IdentityProviderCategoryId Category, string Alias, IdentityProviderTypeId TypeId)> ValidateSetOwnCompanyIdentityProviderStatusArguments(Guid identityProviderId, bool enabled, Guid companyId)
+ private async ValueTask<(IdentityProviderCategoryId Category, string Alias, IdentityProviderTypeId TypeId)> ValidateSetOwnCompanyIdentityProviderStatusArguments(Guid identityProviderId, bool enabled)
{
+ var companyId = _identityService.IdentityData.CompanyId;
var result = await _portalRepositories.GetInstance().GetOwnCompanyIdentityProviderUpdateDataUntrackedAsync(identityProviderId, companyId, true).ConfigureAwait(false);
if (result == default)
{
@@ -323,7 +323,7 @@ private async ValueTask ValidateOtherActiveIdentityProvider(string? alias,
public async ValueTask DeleteCompanyIdentityProviderAsync(Guid identityProviderId)
{
var companyId = _identityService.IdentityData.CompanyId;
- var (alias, typeId) = await ValidateDeleteOwnCompanyIdentityProviderArguments(identityProviderId, companyId).ConfigureAwait(false);
+ var (alias, typeId) = await ValidateDeleteOwnCompanyIdentityProviderArguments(identityProviderId).ConfigureAwait(false);
_portalRepositories.Remove(new CompanyIdentityProvider(companyId, identityProviderId));
@@ -341,8 +341,9 @@ public async ValueTask DeleteCompanyIdentityProviderAsync(Guid identityProviderI
await _portalRepositories.SaveAsync().ConfigureAwait(false);
}
- private async ValueTask<(string? Alias, IdentityProviderTypeId TypeId)> ValidateDeleteOwnCompanyIdentityProviderArguments(Guid identityProviderId, Guid companyId)
+ private async ValueTask<(string? Alias, IdentityProviderTypeId TypeId)> ValidateDeleteOwnCompanyIdentityProviderArguments(Guid identityProviderId)
{
+ var companyId = _identityService.IdentityData.CompanyId;
var result = await _portalRepositories.GetInstance().GetOwnCompanyIdentityProviderUpdateDataUntrackedAsync(identityProviderId, companyId, true).ConfigureAwait(false);
if (result == default)
{
@@ -470,8 +471,9 @@ private async ValueTask GetIdentityProviderDetailsSaml(
};
}
- public async ValueTask CreateOwnCompanyUserIdentityProviderLinkDataAsync(Guid companyUserId, UserIdentityProviderLinkData identityProviderLinkData, Guid companyId)
+ public async ValueTask CreateOwnCompanyUserIdentityProviderLinkDataAsync(Guid companyUserId, UserIdentityProviderLinkData identityProviderLinkData)
{
+ var companyId = _identityService.IdentityData.CompanyId;
var (userEntityId, alias) = await GetUserAliasDataAsync(companyUserId, identityProviderLinkData.identityProviderId, companyId).ConfigureAwait(false);
try
@@ -495,8 +497,9 @@ await _provisioningManager.AddProviderUserLinkToCentralUserAsync(
identityProviderLinkData.userName);
}
- public async ValueTask CreateOrUpdateOwnCompanyUserIdentityProviderLinkDataAsync(Guid companyUserId, Guid identityProviderId, UserLinkData userLinkData, Guid companyId)
+ public async ValueTask CreateOrUpdateOwnCompanyUserIdentityProviderLinkDataAsync(Guid companyUserId, Guid identityProviderId, UserLinkData userLinkData)
{
+ var companyId = _identityService.IdentityData.CompanyId;
var (userEntityId, alias) = await GetUserAliasDataAsync(companyUserId, identityProviderId, companyId).ConfigureAwait(false);
try
@@ -521,8 +524,9 @@ await _provisioningManager.AddProviderUserLinkToCentralUserAsync(
userLinkData.userName);
}
- public async ValueTask GetOwnCompanyUserIdentityProviderLinkDataAsync(Guid companyUserId, Guid identityProviderId, Guid companyId)
+ public async ValueTask GetOwnCompanyUserIdentityProviderLinkDataAsync(Guid companyUserId, Guid identityProviderId)
{
+ var companyId = _identityService.IdentityData.CompanyId;
var (userEntityId, alias) = await GetUserAliasDataAsync(companyUserId, identityProviderId, companyId).ConfigureAwait(false);
var result = await _provisioningManager.GetProviderUserLinkDataForCentralUserIdAsync(userEntityId).FirstOrDefaultAsync(identityProviderLink => identityProviderLink.Alias == alias).ConfigureAwait(false);
@@ -537,8 +541,9 @@ public async ValueTask GetOwnCompanyUserIdentityPr
result.UserName);
}
- public async ValueTask DeleteOwnCompanyUserIdentityProviderDataAsync(Guid companyUserId, Guid identityProviderId, Guid companyId)
+ public async ValueTask DeleteOwnCompanyUserIdentityProviderDataAsync(Guid companyUserId, Guid identityProviderId)
{
+ var companyId = _identityService.IdentityData.CompanyId;
var (userEntityId, alias) = await GetUserAliasDataAsync(companyUserId, identityProviderId, companyId).ConfigureAwait(false);
try
{
@@ -580,8 +585,9 @@ public async ValueTask GetOwnIden
return new(details.identityProviderId, details.alias, details.identityProviderCategoryId, details.IdentityProviderTypeId, details.displayName, details.redirectUrl, details.enabled, connectedCompanies);
}
- public async IAsyncEnumerable GetOwnCompanyUsersIdentityProviderDataAsync(IEnumerable identityProviderIds, Guid companyId, bool unlinkedUsersOnly)
+ public async IAsyncEnumerable GetOwnCompanyUsersIdentityProviderDataAsync(IEnumerable identityProviderIds, bool unlinkedUsersOnly)
{
+ var companyId = _identityService.IdentityData.CompanyId;
var identityProviderAliasDatas = await GetOwnCompanyUsersIdentityProviderAliasDataInternalAsync(identityProviderIds, companyId).ConfigureAwait(false);
var idPerAlias = identityProviderAliasDatas.ToDictionary(item => item.Alias, item => item.IdentityProviderId);
var aliase = identityProviderAliasDatas.Select(item => item.Alias).ToList();
@@ -607,24 +613,26 @@ public async IAsyncEnumerable GetOwnCompanyUsersIdenti
}
}
- public (Stream FileStream, string ContentType, string FileName, Encoding Encoding) GetOwnCompanyUsersIdentityProviderLinkDataStream(IEnumerable identityProviderIds, Guid companyId, bool unlinkedUsersOnly)
+ public (Stream FileStream, string ContentType, string FileName, Encoding Encoding) GetOwnCompanyUsersIdentityProviderLinkDataStream(IEnumerable identityProviderIds, bool unlinkedUsersOnly)
{
+ var companyId = _identityService.IdentityData.CompanyId;
var csvSettings = _settings.CsvSettings;
return (new AsyncEnumerableStringStream(GetOwnCompanyUsersIdentityProviderDataLines(identityProviderIds, unlinkedUsersOnly, companyId), csvSettings.Encoding), csvSettings.ContentType, csvSettings.FileName, csvSettings.Encoding);
}
- public ValueTask UploadOwnCompanyUsersIdentityProviderLinkDataAsync(IFormFile document, Guid companyId, CancellationToken cancellationToken)
+ public ValueTask UploadOwnCompanyUsersIdentityProviderLinkDataAsync(IFormFile document, CancellationToken cancellationToken)
{
if (!document.ContentType.Equals(_settings.CsvSettings.ContentType, StringComparison.OrdinalIgnoreCase))
{
throw new UnsupportedMediaTypeException($"Only contentType {_settings.CsvSettings.ContentType} files are allowed.");
}
- return UploadOwnCompanyUsersIdentityProviderLinkDataInternalAsync(document, companyId, cancellationToken);
+ return UploadOwnCompanyUsersIdentityProviderLinkDataInternalAsync(document, cancellationToken);
}
- private async ValueTask UploadOwnCompanyUsersIdentityProviderLinkDataInternalAsync(IFormFile document, Guid companyId, CancellationToken cancellationToken)
+ private async ValueTask UploadOwnCompanyUsersIdentityProviderLinkDataInternalAsync(IFormFile document, CancellationToken cancellationToken)
{
var userRepository = _portalRepositories.GetInstance();
+ var companyId = _identityService.IdentityData.CompanyId;
var (sharedIdpAlias, existingAliase) = await GetCompanyAliasDataAsync(companyId).ConfigureAwait(false);
using var stream = document.OpenReadStream();
diff --git a/src/administration/Administration.Service/BusinessLogic/ServiceAccountBusinessLogic.cs b/src/administration/Administration.Service/BusinessLogic/ServiceAccountBusinessLogic.cs
index 4004f04cbc..917b3d3da1 100644
--- a/src/administration/Administration.Service/BusinessLogic/ServiceAccountBusinessLogic.cs
+++ b/src/administration/Administration.Service/BusinessLogic/ServiceAccountBusinessLogic.cs
@@ -26,6 +26,7 @@
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models;
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Repositories;
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums;
+using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Identities;
using Org.Eclipse.TractusX.Portal.Backend.Provisioning.Library;
using Org.Eclipse.TractusX.Portal.Backend.Provisioning.Library.Enums;
using Org.Eclipse.TractusX.Portal.Backend.Provisioning.Library.Models;
@@ -38,21 +39,24 @@ public class ServiceAccountBusinessLogic : IServiceAccountBusinessLogic
private readonly IProvisioningManager _provisioningManager;
private readonly IPortalRepositories _portalRepositories;
private readonly IServiceAccountCreation _serviceAccountCreation;
+ private readonly IIdentityService _identityService;
private readonly ServiceAccountSettings _settings;
public ServiceAccountBusinessLogic(
IProvisioningManager provisioningManager,
IPortalRepositories portalRepositories,
IOptions options,
- IServiceAccountCreation serviceAccountCreation)
+ IServiceAccountCreation serviceAccountCreation,
+ IIdentityService identityService)
{
_provisioningManager = provisioningManager;
_portalRepositories = portalRepositories;
_serviceAccountCreation = serviceAccountCreation;
+ _identityService = identityService;
_settings = options.Value;
}
- public async Task CreateOwnCompanyServiceAccountAsync(ServiceAccountCreationInfo serviceAccountCreationInfos, Guid companyId)
+ public async Task CreateOwnCompanyServiceAccountAsync(ServiceAccountCreationInfo serviceAccountCreationInfos)
{
if (serviceAccountCreationInfos.IamClientAuthMethod != IamClientAuthMethod.SECRET)
{
@@ -63,6 +67,7 @@ public async Task CreateOwnCompanyServiceAccountAsync(Ser
throw new ControllerArgumentException("name must not be empty", "name");
}
+ var companyId = _identityService.IdentityData.CompanyId;
var result = await _portalRepositories.GetInstance().GetBpnAndTechnicalUserRoleIds(companyId, _settings.ClientId).ConfigureAwait(false);
if (result == default)
{
@@ -94,9 +99,10 @@ public async Task CreateOwnCompanyServiceAccountAsync(Ser
serviceAccountData.AuthData.Secret);
}
- public async Task DeleteOwnCompanyServiceAccountAsync(Guid serviceAccountId, Guid companyId)
+ public async Task DeleteOwnCompanyServiceAccountAsync(Guid serviceAccountId)
{
var serviceAccountRepository = _portalRepositories.GetInstance();
+ var companyId = _identityService.IdentityData.CompanyId;
var result = await serviceAccountRepository.GetOwnCompanyServiceAccountWithIamServiceAccountRolesAsync(serviceAccountId, companyId).ConfigureAwait(false);
if (result == default)
{
@@ -139,8 +145,9 @@ public async Task DeleteOwnCompanyServiceAccountAsync(Guid serviceAccountId
return await _portalRepositories.SaveAsync().ConfigureAwait(false);
}
- public async Task GetOwnCompanyServiceAccountDetailsAsync(Guid serviceAccountId, Guid companyId)
+ public async Task GetOwnCompanyServiceAccountDetailsAsync(Guid serviceAccountId)
{
+ var companyId = _identityService.IdentityData.CompanyId;
var result = await _portalRepositories.GetInstance().GetOwnCompanyServiceAccountDetailedDataUntrackedAsync(serviceAccountId, companyId);
if (result == null)
{
@@ -165,8 +172,9 @@ public async Task GetOwnCompanyServiceAccountD
result.SubscriptionId);
}
- public async Task ResetOwnCompanyServiceAccountSecretAsync(Guid serviceAccountId, Guid companyId)
+ public async Task ResetOwnCompanyServiceAccountSecretAsync(Guid serviceAccountId)
{
+ var companyId = _identityService.IdentityData.CompanyId;
var result = await _portalRepositories.GetInstance().GetOwnCompanyServiceAccountDetailedDataUntrackedAsync(serviceAccountId, companyId);
if (result == null)
{
@@ -189,7 +197,7 @@ public async Task ResetOwnCompanyServiceAccountSecretAsyn
result.SubscriptionId);
}
- public async Task UpdateOwnCompanyServiceAccountDetailsAsync(Guid serviceAccountId, ServiceAccountEditableDetails serviceAccountDetails, Guid companyId)
+ public async Task UpdateOwnCompanyServiceAccountDetailsAsync(Guid serviceAccountId, ServiceAccountEditableDetails serviceAccountDetails)
{
if (serviceAccountDetails.IamClientAuthMethod != IamClientAuthMethod.SECRET)
{
@@ -199,6 +207,8 @@ public async Task UpdateOwnCompanyServiceAccountDetailsAs
{
throw new ArgumentException($"serviceAccountId {serviceAccountId} from path does not match the one in body {serviceAccountDetails.ServiceAccountId}", nameof(serviceAccountId));
}
+
+ var companyId = _identityService.IdentityData.CompanyId;
var serviceAccountRepository = _portalRepositories.GetInstance();
var result = await serviceAccountRepository.GetOwnCompanyServiceAccountWithIamClientIdAsync(serviceAccountId, companyId).ConfigureAwait(false);
if (result == null)
@@ -254,13 +264,13 @@ await _provisioningManager.UpdateCentralClientAsync(
result.OfferSubscriptionId);
}
- public Task> GetOwnCompanyServiceAccountsDataAsync(int page, int size, Guid companyId, string? clientId, bool? isOwner) =>
+ public Task> GetOwnCompanyServiceAccountsDataAsync(int page, int size, string? clientId, bool? isOwner) =>
Pagination.CreateResponseAsync(
page,
size,
15,
- _portalRepositories.GetInstance().GetOwnCompanyServiceAccountsUntracked(companyId, clientId, isOwner));
+ _portalRepositories.GetInstance().GetOwnCompanyServiceAccountsUntracked(_identityService.IdentityData.CompanyId, clientId, isOwner));
- IAsyncEnumerable IServiceAccountBusinessLogic.GetServiceAccountRolesAsync(Guid companyId, string? languageShortName) =>
- _portalRepositories.GetInstance().GetServiceAccountRolesAsync(companyId, _settings.ClientId, languageShortName ?? Constants.DefaultLanguage);
+ public IAsyncEnumerable GetServiceAccountRolesAsync(string? languageShortName) =>
+ _portalRepositories.GetInstance().GetServiceAccountRolesAsync(_identityService.IdentityData.CompanyId, _settings.ClientId, languageShortName ?? Constants.DefaultLanguage);
}
diff --git a/src/administration/Administration.Service/BusinessLogic/SubscriptionConfigurationBusinessLogic.cs b/src/administration/Administration.Service/BusinessLogic/SubscriptionConfigurationBusinessLogic.cs
index 049e25c8cd..e349e01f19 100644
--- a/src/administration/Administration.Service/BusinessLogic/SubscriptionConfigurationBusinessLogic.cs
+++ b/src/administration/Administration.Service/BusinessLogic/SubscriptionConfigurationBusinessLogic.cs
@@ -24,6 +24,7 @@
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models;
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Repositories;
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums;
+using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Identities;
using Org.Eclipse.TractusX.Portal.Backend.Processes.OfferSubscription.Library;
using Org.Eclipse.TractusX.Portal.Backend.Processes.OfferSubscription.Library.Extensions;
@@ -33,16 +34,19 @@ public class SubscriptionConfigurationBusinessLogic : ISubscriptionConfiguration
{
private readonly IOfferSubscriptionProcessService _offerSubscriptionProcessService;
private readonly IPortalRepositories _portalRepositories;
+ private readonly IIdentityService _identityService;
- public SubscriptionConfigurationBusinessLogic(IOfferSubscriptionProcessService offerSubscriptionProcessService, IPortalRepositories portalRepositories)
+ public SubscriptionConfigurationBusinessLogic(IOfferSubscriptionProcessService offerSubscriptionProcessService, IPortalRepositories portalRepositories, IIdentityService identityService)
{
_offerSubscriptionProcessService = offerSubscriptionProcessService;
_portalRepositories = portalRepositories;
+ _identityService = identityService;
}
///
- public async Task GetProviderCompanyDetailsAsync(Guid companyId)
+ public async Task GetProviderCompanyDetailsAsync()
{
+ var companyId = _identityService.IdentityData.CompanyId;
var result = await _portalRepositories.GetInstance()
.GetProviderCompanyDetailAsync(CompanyRoleId.SERVICE_PROVIDER, companyId)
.ConfigureAwait(false);
@@ -59,7 +63,7 @@ public async Task GetProviderCompanyDetailsAsync(Guid
}
///
- public Task SetProviderCompanyDetailsAsync(ProviderDetailData data, Guid companyId)
+ public Task SetProviderCompanyDetailsAsync(ProviderDetailData data)
{
data.Url.EnsureValidHttpsUrl(() => nameof(data.Url));
data.CallbackUrl?.EnsureValidHttpsUrl(() => nameof(data.CallbackUrl));
@@ -70,7 +74,7 @@ public Task SetProviderCompanyDetailsAsync(ProviderDetailData data, Guid company
"the maximum allowed length is 100 characters", nameof(data.Url));
}
- return SetOfferProviderCompanyDetailsInternalAsync(data, companyId);
+ return SetOfferProviderCompanyDetailsInternalAsync(data, _identityService.IdentityData.CompanyId);
}
private async Task SetOfferProviderCompanyDetailsInternalAsync(ProviderDetailData data, Guid companyId)
diff --git a/src/administration/Administration.Service/BusinessLogic/UserBusinessLogic.cs b/src/administration/Administration.Service/BusinessLogic/UserBusinessLogic.cs
index 18b9d3fc79..4fe574bad2 100644
--- a/src/administration/Administration.Service/BusinessLogic/UserBusinessLogic.cs
+++ b/src/administration/Administration.Service/BusinessLogic/UserBusinessLogic.cs
@@ -28,6 +28,7 @@
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models;
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Repositories;
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums;
+using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Identities;
using Org.Eclipse.TractusX.Portal.Backend.Provisioning.DBAccess;
using Org.Eclipse.TractusX.Portal.Backend.Provisioning.Library;
using Org.Eclipse.TractusX.Portal.Backend.Provisioning.Library.Models;
@@ -44,6 +45,7 @@ public class UserBusinessLogic : IUserBusinessLogic
private readonly IUserProvisioningService _userProvisioningService;
private readonly IProvisioningDBAccess _provisioningDbAccess;
private readonly IPortalRepositories _portalRepositories;
+ private readonly IIdentityService _identityService;
private readonly IMailingService _mailingService;
private readonly ILogger _logger;
private readonly UserSettings _settings;
@@ -54,6 +56,7 @@ public class UserBusinessLogic : IUserBusinessLogic
/// Provisioning Manager
/// User Provisioning Service
/// Provisioning DBAccess
+ /// Access to the identity
/// Mailing Service
/// logger
/// Settings
@@ -63,6 +66,7 @@ public UserBusinessLogic(
IUserProvisioningService userProvisioningService,
IProvisioningDBAccess provisioningDbAccess,
IPortalRepositories portalRepositories,
+ IIdentityService identityService,
IMailingService mailingService,
ILogger logger,
IOptions settings)
@@ -71,12 +75,13 @@ public UserBusinessLogic(
_userProvisioningService = userProvisioningService;
_provisioningDbAccess = provisioningDbAccess;
_portalRepositories = portalRepositories;
+ _identityService = identityService;
_mailingService = mailingService;
_logger = logger;
_settings = settings.Value;
}
- public IAsyncEnumerable CreateOwnCompanyUsersAsync(IEnumerable userList, (Guid UserId, Guid CompanyId) identity)
+ public IAsyncEnumerable CreateOwnCompanyUsersAsync(IEnumerable userList)
{
var noUserNameAndEmail = userList.Where(user => string.IsNullOrEmpty(user.userName) && string.IsNullOrEmpty(user.eMail));
if (noUserNameAndEmail.Any())
@@ -88,16 +93,16 @@ public IAsyncEnumerable CreateOwnCompanyUsersAsync(IEnumerable user.userName ?? user.eMail))}'");
}
- return CreateOwnCompanyUsersInternalAsync(userList, identity);
+ return CreateOwnCompanyUsersInternalAsync(userList);
}
- private async IAsyncEnumerable CreateOwnCompanyUsersInternalAsync(IEnumerable userList, (Guid UserId, Guid CompanyId) identity)
+ private async IAsyncEnumerable CreateOwnCompanyUsersInternalAsync(IEnumerable userList)
{
- var (companyNameIdpAliasData, nameCreatedBy) = await _userProvisioningService.GetCompanyNameSharedIdpAliasData(identity.UserId).ConfigureAwait(false);
+ var (companyNameIdpAliasData, nameCreatedBy) = await _userProvisioningService.GetCompanyNameSharedIdpAliasData(_identityService.IdentityData.UserId).ConfigureAwait(false);
var distinctRoles = userList.SelectMany(user => user.Roles).Distinct().ToList();
- var roleDatas = await GetOwnCompanyUserRoleData(distinctRoles, identity.CompanyId).ConfigureAwait(false);
+ var roleDatas = await GetOwnCompanyUserRoleData(distinctRoles).ConfigureAwait(false);
var userCreationInfoIdps = userList.Select(user =>
new UserCreationRoleDataIdpInfo(
@@ -148,19 +153,19 @@ private async IAsyncEnumerable CreateOwnCompanyUsersInternalAsync(IEnume
}
}
- private Task> GetOwnCompanyUserRoleData(IEnumerable roles, Guid companyId)
+ private Task> GetOwnCompanyUserRoleData(IEnumerable roles)
{
if (!roles.Any())
{
Task.FromResult(Enumerable.Empty());
}
- return _userProvisioningService.GetOwnCompanyPortalRoleDatas(_settings.Portal.KeycloakClientID, roles, companyId);
+ return _userProvisioningService.GetOwnCompanyPortalRoleDatas(_settings.Portal.KeycloakClientID, roles, _identityService.IdentityData.CompanyId);
}
- public async Task CreateOwnCompanyIdpUserAsync(Guid identityProviderId, UserCreationInfoIdp userCreationInfo, (Guid UserId, Guid CompanyId) identity)
+ public async Task CreateOwnCompanyIdpUserAsync(Guid identityProviderId, UserCreationInfoIdp userCreationInfo)
{
- var (companyNameIdpAliasData, nameCreatedBy) = await _userProvisioningService.GetCompanyNameIdpAliasData(identityProviderId, identity.UserId).ConfigureAwait(false);
+ var (companyNameIdpAliasData, nameCreatedBy) = await _userProvisioningService.GetCompanyNameIdpAliasData(identityProviderId, _identityService.IdentityData.UserId).ConfigureAwait(false);
var displayName = await _userProvisioningService.GetIdentityProviderDisplayName(companyNameIdpAliasData.IdpAlias).ConfigureAwait(false);
if (!userCreationInfo.Roles.Any())
@@ -168,7 +173,7 @@ public async Task CreateOwnCompanyIdpUserAsync(Guid identityProviderId, Us
throw new ControllerArgumentException($"at least one role must be specified", nameof(userCreationInfo.Roles));
}
- var roleDatas = await GetOwnCompanyUserRoleData(userCreationInfo.Roles, identity.CompanyId).ConfigureAwait(false);
+ var roleDatas = await GetOwnCompanyUserRoleData(userCreationInfo.Roles).ConfigureAwait(false);
var result = await _userProvisioningService.CreateOwnCompanyIdpUsersAsync(
companyNameIdpAliasData,
@@ -218,11 +223,10 @@ public async Task CreateOwnCompanyIdpUserAsync(Guid identityProviderId, Us
return result.CompanyUserId;
}
- public Task> GetOwnCompanyUserDatasAsync(Guid companyId, int page, int size, GetOwnCompanyUsersFilter filter)
+ public Task> GetOwnCompanyUserDatasAsync(int page, int size, GetOwnCompanyUsersFilter filter)
{
-
var companyUsers = _portalRepositories.GetInstance().GetOwnCompanyUserQuery(
- companyId,
+ _identityService.IdentityData.CompanyId,
filter.CompanyUserId,
filter.UserEntityId,
filter.FirstName,
@@ -272,8 +276,9 @@ public async IAsyncEnumerable GetClientRolesAsync(Guid appId, strin
}
}
- public async Task GetOwnCompanyUserDetailsAsync(Guid userId, Guid companyId)
+ public async Task GetOwnCompanyUserDetailsAsync(Guid userId)
{
+ var companyId = _identityService.IdentityData.CompanyId;
var details = await _portalRepositories.GetInstance().GetOwnCompanyUserDetailsUntrackedAsync(userId, companyId).ConfigureAwait(false);
if (details == null)
{
@@ -282,12 +287,13 @@ public async Task GetOwnCompanyUserDetailsAsync(Guid userId,
return details;
}
- public async Task AddOwnCompanyUsersBusinessPartnerNumbersAsync(Guid userId, IEnumerable businessPartnerNumbers, Guid companyId)
+ public async Task AddOwnCompanyUsersBusinessPartnerNumbersAsync(Guid userId, IEnumerable businessPartnerNumbers)
{
if (businessPartnerNumbers.Any(businessPartnerNumber => businessPartnerNumber.Length > 20))
{
throw new ControllerArgumentException("businessPartnerNumbers must not exceed 20 characters", nameof(businessPartnerNumbers));
}
+ var companyId = _identityService.IdentityData.CompanyId;
var user = await _portalRepositories.GetInstance().GetOwnCompanyUserWithAssignedBusinessPartnerNumbersUntrackedAsync(userId, companyId).ConfigureAwait(false);
if (user == null || user.UserEntityId == null)
{
@@ -304,11 +310,12 @@ public async Task AddOwnCompanyUsersBusinessPartnerNumbersAsync(Guid userId
return await _portalRepositories.SaveAsync();
}
- public Task AddOwnCompanyUsersBusinessPartnerNumberAsync(Guid userId, string businessPartnerNumber, Guid companyId) =>
- AddOwnCompanyUsersBusinessPartnerNumbersAsync(userId, Enumerable.Repeat(businessPartnerNumber, 1), companyId);
+ public Task AddOwnCompanyUsersBusinessPartnerNumberAsync(Guid userId, string businessPartnerNumber) =>
+ AddOwnCompanyUsersBusinessPartnerNumbersAsync(userId, Enumerable.Repeat(businessPartnerNumber, 1));
- public async Task GetOwnUserDetails(Guid userId)
+ public async Task GetOwnUserDetails()
{
+ var userId = _identityService.IdentityData.UserId;
var userRoleIds = await _portalRepositories.GetInstance()
.GetUserRoleIdsUntrackedAsync(_settings.UserAdminRoles).ToListAsync().ConfigureAwait(false);
var details = await _portalRepositories.GetInstance().GetUserDetailsUntrackedAsync(userId, userRoleIds).ConfigureAwait(false);
@@ -319,8 +326,9 @@ public async Task GetOwnUserDetails(Guid userId)
return details;
}
- public async Task UpdateOwnUserDetails(Guid companyUserId, OwnCompanyUserEditableDetails ownCompanyUserEditableDetails, Guid userId)
+ public async Task UpdateOwnUserDetails(Guid companyUserId, OwnCompanyUserEditableDetails ownCompanyUserEditableDetails)
{
+ var userId = _identityService.IdentityData.UserId;
if (companyUserId != userId)
{
throw new ForbiddenException($"invalid userId {companyUserId} for user {userId}");
@@ -377,8 +385,9 @@ await _provisioningManager.UpdateSharedRealmUserAsync(
};
}
- public async Task DeleteOwnUserAsync(Guid companyUserId, Guid userId)
+ public async Task DeleteOwnUserAsync(Guid companyUserId)
{
+ var userId = _identityService.IdentityData.UserId;
if (companyUserId != userId)
{
throw new ForbiddenException($"companyUser {companyUserId} is not the id of user {userId}");
@@ -393,8 +402,9 @@ public async Task DeleteOwnUserAsync(Guid companyUserId, Guid userId)
return await _portalRepositories.SaveAsync().ConfigureAwait(false);
}
- public async IAsyncEnumerable DeleteOwnCompanyUsersAsync(IEnumerable userIds, Guid companyId)
+ public async IAsyncEnumerable DeleteOwnCompanyUsersAsync(IEnumerable userIds)
{
+ var companyId = _identityService.IdentityData.CompanyId;
var iamIdpAlias = await _portalRepositories.GetInstance().GetSharedIdentityProviderIamAliasDataUntrackedAsync(companyId);
await foreach (var accountData in _portalRepositories.GetInstance().GetCompanyUserAccountDataUntrackedAsync(userIds, companyId).ConfigureAwait(false))
@@ -494,8 +504,9 @@ private async Task CanResetPassword(Guid userId)
return false;
}
- public async Task ExecuteOwnCompanyUserPasswordReset(Guid companyUserId, (Guid UserId, Guid CompanyId) identity)
+ public async Task ExecuteOwnCompanyUserPasswordReset(Guid companyUserId)
{
+ var identity = _identityService.IdentityData;
var idpUserName = await _portalRepositories.GetInstance().GetIdpCategoryIdByUserIdAsync(companyUserId, identity.CompanyId).ConfigureAwait(false);
if (idpUserName != null && !string.IsNullOrWhiteSpace(idpUserName.TargetIamUserId) && !string.IsNullOrWhiteSpace(idpUserName.IdpName))
{
@@ -509,20 +520,21 @@ public async Task ExecuteOwnCompanyUserPasswordReset(Guid companyUserId, (
throw new NotFoundException($"Cannot identify companyId or shared idp : userId {companyUserId} is not associated with admin users company {identity.CompanyId}");
}
- public Task> GetOwnCompanyAppUsersAsync(Guid appId, Guid userId, int page, int size, CompanyUserFilter filter) =>
+ public Task> GetOwnCompanyAppUsersAsync(Guid appId, int page, int size, CompanyUserFilter filter) =>
Pagination.CreateResponseAsync(
page,
size,
15,
_portalRepositories.GetInstance().GetOwnCompanyAppUsersPaginationSourceAsync(
appId,
- userId,
+ _identityService.IdentityData.UserId,
new[] { OfferSubscriptionStatusId.ACTIVE },
new[] { UserStatusId.ACTIVE, UserStatusId.INACTIVE },
filter));
- public async Task DeleteOwnUserBusinessPartnerNumbersAsync(Guid userId, string businessPartnerNumber, (Guid UserId, Guid CompanyId) identity)
+ public async Task DeleteOwnUserBusinessPartnerNumbersAsync(Guid userId, string businessPartnerNumber)
{
+ var identity = _identityService.IdentityData;
var userBusinessPartnerRepository = _portalRepositories.GetInstance();
var userWithBpn = await userBusinessPartnerRepository.GetOwnCompanyUserWithAssignedBusinessPartnerNumbersAsync(userId, identity.CompanyId, businessPartnerNumber).ConfigureAwait(false);
diff --git a/src/administration/Administration.Service/BusinessLogic/UserRolesBusinessLogic.cs b/src/administration/Administration.Service/BusinessLogic/UserRolesBusinessLogic.cs
index ea4d9e4157..0e24a9b480 100644
--- a/src/administration/Administration.Service/BusinessLogic/UserRolesBusinessLogic.cs
+++ b/src/administration/Administration.Service/BusinessLogic/UserRolesBusinessLogic.cs
@@ -28,6 +28,7 @@
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Repositories;
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities;
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums;
+using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Identities;
using Org.Eclipse.TractusX.Portal.Backend.Provisioning.Library;
using System.Text.Json;
@@ -38,26 +39,29 @@ public class UserRolesBusinessLogic : IUserRolesBusinessLogic
private static readonly JsonSerializerOptions _options = new() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase };
private readonly IPortalRepositories _portalRepositories;
private readonly IProvisioningManager _provisioningManager;
+ private readonly IIdentityService _identityService;
private readonly UserSettings _settings;
- public UserRolesBusinessLogic(IPortalRepositories portalRepositories, IProvisioningManager provisioningManager, IOptions options)
+ public UserRolesBusinessLogic(IPortalRepositories portalRepositories, IProvisioningManager provisioningManager, IIdentityService identityService, IOptions options)
{
_portalRepositories = portalRepositories;
_provisioningManager = provisioningManager;
+ _identityService = identityService;
_settings = options.Value;
}
- public IAsyncEnumerable GetCoreOfferRoles(Guid companyId, string? languageShortName) =>
- _portalRepositories.GetInstance().GetCoreOfferRolesAsync(companyId, languageShortName ?? Constants.DefaultLanguage, _settings.Portal.KeycloakClientID)
+ public IAsyncEnumerable GetCoreOfferRoles(string? languageShortName) =>
+ _portalRepositories.GetInstance().GetCoreOfferRolesAsync(_identityService.IdentityData.CompanyId, languageShortName ?? Constants.DefaultLanguage, _settings.Portal.KeycloakClientID)
.PreSortedGroupBy(x => x.OfferId)
.Select(x => new OfferRoleInfos(x.Key, x.Select(s => new OfferRoleInfo(s.RoleId, s.RoleText, s.Description))));
- public IAsyncEnumerable GetAppRolesAsync(Guid appId, Guid companyId, string? languageShortName) =>
+ public IAsyncEnumerable GetAppRolesAsync(Guid appId, string? languageShortName) =>
_portalRepositories.GetInstance()
- .GetAppRolesAsync(appId, companyId, languageShortName ?? Constants.DefaultLanguage);
+ .GetAppRolesAsync(appId, _identityService.IdentityData.CompanyId, languageShortName ?? Constants.DefaultLanguage);
- public Task> ModifyCoreOfferUserRolesAsync(Guid offerId, Guid companyUserId, IEnumerable roles, Guid companyId)
+ public Task> ModifyCoreOfferUserRolesAsync(Guid offerId, Guid companyUserId, IEnumerable roles)
{
+ var companyId = _identityService.IdentityData.CompanyId;
return ModifyUserRolesInternal(
async () =>
{
@@ -92,13 +96,13 @@ public Task> ModifyCoreOfferUserRolesAsync(Guid offe
});
}
- public Task> ModifyAppUserRolesAsync(Guid appId, Guid companyUserId, IEnumerable roles, Guid companyId) =>
+ public Task> ModifyAppUserRolesAsync(Guid appId, Guid companyUserId, IEnumerable roles) =>
ModifyUserRolesInternal(
() => _portalRepositories.GetInstance()
- .GetAppAssignedIamClientUserDataUntrackedAsync(appId, companyUserId, companyId),
+ .GetAppAssignedIamClientUserDataUntrackedAsync(appId, companyUserId, _identityService.IdentityData.CompanyId),
(Guid companyUserId, IEnumerable roles, Guid offerId) => _portalRepositories.GetInstance()
.GetAssignedAndMatchingAppRoles(companyUserId, roles, offerId),
- appId, companyUserId, roles, companyId,
+ appId, companyUserId, roles, _identityService.IdentityData.CompanyId,
data =>
{
var userName = $"{data.firstname} {data.lastname}";
@@ -113,13 +117,13 @@ public Task> ModifyAppUserRolesAsync(Guid appId, Gui
});
[Obsolete("to be replaced by endpoint UserRolesBusinessLogic.ModifyAppUserRolesAsync. Remove as soon frontend is adjusted")]
- public Task> ModifyUserRoleAsync(Guid appId, UserRoleInfo userRoleInfo, Guid companyId) =>
+ public Task> ModifyUserRoleAsync(Guid appId, UserRoleInfo userRoleInfo) =>
ModifyUserRolesInternal(
() => _portalRepositories.GetInstance()
- .GetAppAssignedIamClientUserDataUntrackedAsync(appId, userRoleInfo.CompanyUserId, companyId),
+ .GetAppAssignedIamClientUserDataUntrackedAsync(appId, userRoleInfo.CompanyUserId, _identityService.IdentityData.CompanyId),
(Guid companyUserId, IEnumerable roles, Guid offerId) => _portalRepositories.GetInstance()
.GetAssignedAndMatchingAppRoles(companyUserId, roles, offerId),
- appId, userRoleInfo.CompanyUserId, userRoleInfo.Roles, companyId, null);
+ appId, userRoleInfo.CompanyUserId, userRoleInfo.Roles, _identityService.IdentityData.CompanyId, null);
private async Task> ModifyUserRolesInternal(
Func> getIamUserData,
diff --git a/src/administration/Administration.Service/BusinessLogic/UserUploadBusinessLogic.cs b/src/administration/Administration.Service/BusinessLogic/UserUploadBusinessLogic.cs
index a688e104c7..ef1ab4dfde 100644
--- a/src/administration/Administration.Service/BusinessLogic/UserUploadBusinessLogic.cs
+++ b/src/administration/Administration.Service/BusinessLogic/UserUploadBusinessLogic.cs
@@ -22,9 +22,11 @@
using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Models;
using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling;
using Org.Eclipse.TractusX.Portal.Backend.Framework.IO;
+using Org.Eclipse.TractusX.Portal.Backend.Framework.Web;
using Org.Eclipse.TractusX.Portal.Backend.Mailing.SendMail;
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models;
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums;
+using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Identities;
using Org.Eclipse.TractusX.Portal.Backend.Provisioning.Library.Models;
using Org.Eclipse.TractusX.Portal.Backend.Provisioning.Library.Service;
using System.Runtime.CompilerServices;
@@ -36,33 +38,38 @@ public class UserUploadBusinessLogic : IUserUploadBusinessLogic
private readonly IUserProvisioningService _userProvisioningService;
private readonly IMailingService _mailingService;
private readonly UserSettings _settings;
+ private readonly IIdentityService _identityService;
///
/// Constructor.
///
/// User Provisioning Service
/// Mailing Service
+ /// Access to the identity Service
/// Settings
public UserUploadBusinessLogic(
IUserProvisioningService userProvisioningService,
IMailingService mailingService,
+ IIdentityService identityService,
IOptions settings)
{
_userProvisioningService = userProvisioningService;
_mailingService = mailingService;
+ _identityService = identityService;
_settings = settings.Value;
}
- public ValueTask UploadOwnCompanyIdpUsersAsync(Guid identityProviderId, IFormFile document, (Guid UserId, Guid CompanyId) identity, CancellationToken cancellationToken)
+ public ValueTask UploadOwnCompanyIdpUsersAsync(Guid identityProviderId, IFormFile document, CancellationToken cancellationToken)
{
CsvParser.ValidateContentTypeTextCSV(document.ContentType);
- return UploadOwnCompanyIdpUsersInternalAsync(identityProviderId, document, identity, cancellationToken);
+ return UploadOwnCompanyIdpUsersInternalAsync(identityProviderId, document, cancellationToken);
}
- private async ValueTask UploadOwnCompanyIdpUsersInternalAsync(Guid identityProviderId, IFormFile document, (Guid UserId, Guid CompanyId) identity, CancellationToken cancellationToken)
+ private async ValueTask UploadOwnCompanyIdpUsersInternalAsync(Guid identityProviderId, IFormFile document, CancellationToken cancellationToken)
{
using var stream = document.OpenReadStream();
+ var identity = _identityService.IdentityData;
var (companyNameIdpAliasData, nameCreatedBy) = await _userProvisioningService.GetCompanyNameIdpAliasData(identityProviderId, identity.UserId).ConfigureAwait(false);
var validRoleData = new List();
@@ -182,17 +189,17 @@ private static (string FirstName, string LastName, string Email, string Provider
return (firstName, lastName, email, providerUserName, providerUserId, roles);
}
- public ValueTask UploadOwnCompanySharedIdpUsersAsync(IFormFile document, (Guid UserId, Guid CompanyId) identity, CancellationToken cancellationToken)
+ public ValueTask UploadOwnCompanySharedIdpUsersAsync(IFormFile document, CancellationToken cancellationToken)
{
CsvParser.ValidateContentTypeTextCSV(document.ContentType);
- return UploadOwnCompanySharedIdpUsersInternalAsync(document, identity, cancellationToken);
+ return UploadOwnCompanySharedIdpUsersInternalAsync(document, cancellationToken);
}
- private async ValueTask UploadOwnCompanySharedIdpUsersInternalAsync(IFormFile document,
- (Guid UserId, Guid CompanyId) identity, CancellationToken cancellationToken)
+ private async ValueTask UploadOwnCompanySharedIdpUsersInternalAsync(IFormFile document, CancellationToken cancellationToken)
{
using var stream = document.OpenReadStream();
+ var identity = _identityService.IdentityData;
var (companyNameIdpAliasData, _) = await _userProvisioningService.GetCompanyNameSharedIdpAliasData(identity.UserId).ConfigureAwait(false);
var validRoleData = new List();
diff --git a/src/administration/Administration.Service/Controllers/DocumentsController.cs b/src/administration/Administration.Service/Controllers/DocumentsController.cs
index 9e3c564d90..4cc5c4559b 100644
--- a/src/administration/Administration.Service/Controllers/DocumentsController.cs
+++ b/src/administration/Administration.Service/Controllers/DocumentsController.cs
@@ -24,7 +24,6 @@
using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling.Library;
using Org.Eclipse.TractusX.Portal.Backend.Framework.Models;
using Org.Eclipse.TractusX.Portal.Backend.Framework.PublicInfos;
-using Org.Eclipse.TractusX.Portal.Backend.Keycloak.Authentication;
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models;
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums;
@@ -70,7 +69,7 @@ public DocumentsController(IDocumentsBusinessLogic documentsBusinessLogic)
[ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status503ServiceUnavailable)]
public async Task GetDocumentContentFileAsync([FromRoute] Guid documentId)
{
- var (fileName, content, mediaType) = await this.WithCompanyId(companyId => _businessLogic.GetDocumentAsync(documentId, companyId).ConfigureAwait(false));
+ var (fileName, content, mediaType) = await _businessLogic.GetDocumentAsync(documentId).ConfigureAwait(false);
return File(content, mediaType, fileName);
}
@@ -115,7 +114,7 @@ public async Task GetSelfDescriptionDocumentsAsync([FromRoute] Gui
[ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status403Forbidden)]
[ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status404NotFound)]
public Task DeleteDocumentAsync([FromRoute] Guid documentId) =>
- this.WithUserId(userId => _businessLogic.DeleteDocumentAsync(documentId, userId));
+ _businessLogic.DeleteDocumentAsync(documentId);
///
/// Gets the json the seed data for a specific document
diff --git a/src/administration/Administration.Service/Controllers/IdentityProviderController.cs b/src/administration/Administration.Service/Controllers/IdentityProviderController.cs
index de2208c728..f4e254c41a 100644
--- a/src/administration/Administration.Service/Controllers/IdentityProviderController.cs
+++ b/src/administration/Administration.Service/Controllers/IdentityProviderController.cs
@@ -24,7 +24,6 @@
using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Models;
using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling.Library;
using Org.Eclipse.TractusX.Portal.Backend.Framework.Models;
-using Org.Eclipse.TractusX.Portal.Backend.Keycloak.Authentication;
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums;
using Org.Eclipse.TractusX.Portal.Backend.Provisioning.Library.Enums;
@@ -244,7 +243,7 @@ public async Task DeleteOwnCompanyIdentityProvider([FromRoute]
[ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status400BadRequest)]
[ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status502BadGateway)]
public IAsyncEnumerable GetOwnCompanyUsersIdentityProviderDataAsync([FromQuery] IEnumerable identityProviderIds, [FromQuery] bool unlinkedUsersOnly = false) =>
- this.WithCompanyId(companyId => _businessLogic.GetOwnCompanyUsersIdentityProviderDataAsync(identityProviderIds, companyId, unlinkedUsersOnly));
+ _businessLogic.GetOwnCompanyUsersIdentityProviderDataAsync(identityProviderIds, unlinkedUsersOnly);
///
/// Gets the company users for the identity providers as a file
@@ -267,7 +266,7 @@ public IAsyncEnumerable GetOwnCompanyUsersIdentityProv
[ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status502BadGateway)]
public IActionResult GetOwnCompanyUsersIdentityProviderFileAsync([FromQuery] IEnumerable identityProviderIds, [FromQuery] bool unlinkedUsersOnly = false)
{
- var (stream, contentType, fileName, encoding) = this.WithCompanyId(companyId => _businessLogic.GetOwnCompanyUsersIdentityProviderLinkDataStream(identityProviderIds, companyId, unlinkedUsersOnly));
+ var (stream, contentType, fileName, encoding) = _businessLogic.GetOwnCompanyUsersIdentityProviderLinkDataStream(identityProviderIds, unlinkedUsersOnly);
return File(stream, string.Join("; ", contentType, encoding.WebName), fileName);
}
@@ -296,7 +295,7 @@ public IActionResult GetOwnCompanyUsersIdentityProviderFileAsync([FromQuery] IEn
[ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status415UnsupportedMediaType)]
[ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status502BadGateway)]
public ValueTask UploadOwnCompanyUsersIdentityProviderFileAsync([FromForm(Name = "document")] IFormFile document, CancellationToken cancellationToken) =>
- this.WithCompanyId(companyId => _businessLogic.UploadOwnCompanyUsersIdentityProviderLinkDataAsync(document, companyId, cancellationToken));
+ _businessLogic.UploadOwnCompanyUsersIdentityProviderLinkDataAsync(document, cancellationToken);
///
/// Adds the user to the given identity provider
@@ -328,7 +327,7 @@ public ValueTask UploadOwnCompanyUsersIdentityProvi
[ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status502BadGateway)]
public async ValueTask> AddOwnCompanyUserIdentityProviderDataAsync([FromRoute] Guid companyUserId, [FromBody] UserIdentityProviderLinkData identityProviderLinkData)
{
- var linkData = await this.WithCompanyId(companyId => _businessLogic.CreateOwnCompanyUserIdentityProviderLinkDataAsync(companyUserId, identityProviderLinkData, companyId)).ConfigureAwait(false);
+ var linkData = await _businessLogic.CreateOwnCompanyUserIdentityProviderLinkDataAsync(companyUserId, identityProviderLinkData).ConfigureAwait(false);
return (ActionResult)CreatedAtRoute(
nameof(GetOwnCompanyUserIdentityProviderDataAsync),
new { companyUserId = companyUserId, identityProviderId = linkData.identityProviderId },
@@ -362,7 +361,7 @@ public async ValueTask> AddOwnCompany
[ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status500InternalServerError)]
[ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status502BadGateway)]
public ValueTask CreateOrUpdateOwnCompanyUserIdentityProviderDataAsync([FromRoute] Guid companyUserId, [FromRoute] Guid identityProviderId, [FromBody] UserLinkData userLinkData) =>
- this.WithCompanyId(companyId => _businessLogic.CreateOrUpdateOwnCompanyUserIdentityProviderLinkDataAsync(companyUserId, identityProviderId, userLinkData, companyId));
+ _businessLogic.CreateOrUpdateOwnCompanyUserIdentityProviderLinkDataAsync(companyUserId, identityProviderId, userLinkData);
///
/// Gets the given user for the given identity provider
@@ -390,7 +389,7 @@ public ValueTask CreateOrUpdateOwnCompanyUserIdent
[ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status500InternalServerError)]
[ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status502BadGateway)]
public ValueTask