feat: LdapOptions erstellt anstelle statischer (fest codierter) Konfigurationswerte, LdapOptions und Abhängigkeitsinjektionen dafür hinzugefügt
This commit is contained in:
@@ -17,6 +17,7 @@ using HRD.LDAPService.JWT;
|
||||
using HRD.WebApi.DAL.Middleware;
|
||||
using HRD.WebApi.Helpers;
|
||||
using StaffDBServer.SharedControllers;
|
||||
using HRD.LDAPService;
|
||||
|
||||
AppDomain.CurrentDomain.UnhandledException += (object sender, UnhandledExceptionEventArgs unhandledExceptionEventArgs) =>
|
||||
{
|
||||
@@ -56,6 +57,7 @@ try
|
||||
|
||||
builder.Services.AddStaffDBRepositories();
|
||||
builder.Services.AddScoped<WebAppUserHelper>();
|
||||
builder.Services.AddJwtManagerWithLdap(configuration.GetSection("LdapOptions"));
|
||||
|
||||
builder.Services.ConfigureWebApiExtensionsEnd(); // should come last
|
||||
|
||||
|
||||
@@ -18,10 +18,13 @@ namespace StaffDBServer.SharedControllers
|
||||
|
||||
WebAppEmployeeInfoRepository webAppEmployeeInfoRepository;
|
||||
|
||||
public WebAppUserHelper(WebAppUserRepository webAppUserRepository, WebAppEmployeeInfoRepository webAppEmployeeInfoRepository)
|
||||
private readonly JwtManager _jwtManager;
|
||||
|
||||
public WebAppUserHelper(WebAppUserRepository webAppUserRepository, WebAppEmployeeInfoRepository webAppEmployeeInfoRepository, JwtManager jwtManager)
|
||||
{
|
||||
this.webAppUserRepository = webAppUserRepository;
|
||||
this.webAppEmployeeInfoRepository = webAppEmployeeInfoRepository;
|
||||
_jwtManager = jwtManager;
|
||||
}
|
||||
|
||||
public async Task<WebAppUser> CheckLoginWithJWTAsync(StringValues accessToken, string clientVersion)
|
||||
@@ -96,7 +99,7 @@ namespace StaffDBServer.SharedControllers
|
||||
}
|
||||
}
|
||||
|
||||
private static async Task<WebAppUser> DoCheckLoginWithNameAndPasswordAsync(WebAppUser userFromClient, WebAppUserRepository webAppUserRepository, WebAppEmployeeInfoRepository webAppEmployeeInfoRepository)
|
||||
private async Task<WebAppUser> DoCheckLoginWithNameAndPasswordAsync(WebAppUser userFromClient, WebAppUserRepository webAppUserRepository, WebAppEmployeeInfoRepository webAppEmployeeInfoRepository)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -114,7 +117,7 @@ namespace StaffDBServer.SharedControllers
|
||||
}
|
||||
|
||||
LdapUser ldapUser = new LdapUser(userFromClient.LoginName, webAppEmployeeInfo.EmployeeId, userFromClient.Password, webAppEmployeeInfo.DepartmentId, webAppEmployeeInfo.ExtendedDepartmentIdList);
|
||||
if (!JwtManager.GenerateLdapUserWithJwtToken(ldapUser))
|
||||
if (!_jwtManager.GenerateLdapUserWithJwtToken(ldapUser))
|
||||
{
|
||||
if (ldapUser == default)
|
||||
{
|
||||
|
||||
@@ -25,5 +25,17 @@
|
||||
"CustomConfig": {
|
||||
},
|
||||
|
||||
"AllowedHosts": "*"
|
||||
"AllowedHosts": "*",
|
||||
"LdapOptions": {
|
||||
"LDAP_WebAppGroup_Is_Live": false,
|
||||
"LDAP_WINDREAM": "Windream_",
|
||||
"LDAP_DOMAIN": "dhr.local",
|
||||
"LDAP_PATH_EDM": "OU=DMS,OU=Gruppen,OU=DHDEAB,DC=dhr,DC=local",
|
||||
"LDAP_PATH_WEBAPPS": "OU=Web-Apps,OU=Gruppen,OU=DHDEAB,DC=dhr,DC=local",
|
||||
"LDAP_EDMUser_Prefix": "GG_EDMUser_Group",
|
||||
"LDAP_EDMAdmin_Prefix": "GG_EDMAdmin_Group",
|
||||
"LDAP_EDM_Prefix": "GG_EDM",
|
||||
"LDAP_WebAppp_Prefix": "GG_WebApp",
|
||||
"LDAP_Prefix_Test": "__Test"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user