Skip to content
This repository was archived by the owner on Mar 4, 2022. It is now read-only.

Commit b61a68b

Browse files
authored
Merge pull request #150 from GetGatekeeper/scim
Add SCIM sync handler
2 parents b39205f + c556c7f commit b61a68b

11 files changed

+1458
-2
lines changed

Client/Pages/Admin/Apps/AdminAppsDetails.razor

+11-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@
3838
<p>Bind password: @appDetailReply.LdapDirectorySetting.Password</p>
3939
break;
4040
case AppDetailReply.DirectorySettingOneofCase.ScimDirectorySetting:
41-
<span>SCIM</span>
41+
<p>Endpoint: @appDetailReply.ScimDirectorySetting.Endpoint</p>
42+
<p><button @onclick="TriggerScimSync">Trigger sync</button></p>
4243
break;
4344
case AppDetailReply.DirectorySettingOneofCase.None:
4445
<span>None configured</span>
@@ -78,6 +79,15 @@
7879
appDetailReply = await AppsClient.GetAppDetailsAsync(request);
7980
}
8081

82+
private async Task TriggerScimSync() {
83+
ScimSyncRequest request = new ScimSyncRequest
84+
{
85+
AppId = Id.ToString(),
86+
};
87+
88+
await AppsClient.TriggerScimSyncAsync(request);
89+
}
90+
8191
private async Task AddGroupToApp()
8292
{
8393
AddGroupToAppRequest request = new AddGroupToAppRequest

Server/AuthServer.Server.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<ItemGroup>
99
<PackageReference Include="Certes" Version="2.3.4" />
1010
<PackageReference Include="Gatekeeper.LdapServerLibrary" Version="0.0.4-alpha" />
11+
<PackageReference Include="Gatekeeper.SCIM.Client" Version="0.0.4-alpha" />
1112
<PackageReference Include="Grpc.AspNetCore" Version="2.34.0" />
1213
<PackageReference Include="Grpc.AspNetCore.Web" Version="2.34.0" />
1314
<PackageReference Include="Hangfire.AspNetCore" Version="1.7.18" />

Server/GRPC/Admin/AppsService.cs

+15-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using AuthServer.Server.Services;
77
using AuthServer.Server.Services.Crypto;
88
using AuthServer.Server.Services.ReverseProxy.Configuration;
9+
using AuthServer.Server.Services.SCIM;
910
using AuthServer.Server.Services.TLS;
1011
using AuthServer.Shared.Admin;
1112
using Google.Protobuf.WellKnownTypes;
@@ -25,20 +26,23 @@ public class AppsService : AuthServer.Shared.Admin.AdminApps.AdminAppsBase
2526
private readonly SecureRandom _secureRandom;
2627
private readonly ConfigurationProvider _configurationProvider;
2728
private readonly MemoryPopulator _memoryPopulator;
29+
private readonly ISyncHandler _syncHandler;
2830

2931
public AppsService(
3032
AuthDbContext authDbContext,
3133
IDataProtectionProvider dataProtectionProvider,
3234
SecureRandom secureRandom,
3335
ConfigurationProvider configurationProvider,
34-
MemoryPopulator memoryPopulator
36+
MemoryPopulator memoryPopulator,
37+
ISyncHandler syncHandler
3538
)
3639
{
3740
_authDbContext = authDbContext;
3841
_ldapSettingsDataProtector = dataProtectionProvider.CreateProtector("LdapSettingsDataProtector");
3942
_secureRandom = secureRandom;
4043
_configurationProvider = configurationProvider;
4144
_memoryPopulator = memoryPopulator;
45+
_syncHandler = syncHandler;
4246
}
4347

4448
public override async Task<AddGroupToAppReply> AddGroupToApp(AddGroupToAppRequest request, ServerCallContext context)
@@ -330,5 +334,15 @@ public override async Task<RemoveGroupFromAppReply> RemoveGroupFromApp(RemoveGro
330334

331335
return new RemoveGroupFromAppReply { Success = true };
332336
}
337+
338+
public override async Task<Empty> TriggerScimSync(ScimSyncRequest request, ServerCallContext context)
339+
{
340+
SCIMAppSettings setting = await _authDbContext
341+
.SCIMAppSettings
342+
.SingleAsync(s => s.AuthAppId == new Guid(request.AppId));
343+
344+
await _syncHandler.FullSyncAsync(setting.Id);
345+
return new Empty();
346+
}
333347
}
334348
}

0 commit comments

Comments
 (0)