Skip to content

Commit

Permalink
Final removal of deprecated ServerSupport ServerSetting property.
Browse files Browse the repository at this point in the history
  • Loading branch information
JosephEShook committed May 12, 2024
1 parent ad548ea commit 5439eb4
Show file tree
Hide file tree
Showing 15 changed files with 2 additions and 1,453 deletions.
10 changes: 0 additions & 10 deletions Udap.Server/Configuration/ServerSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@
namespace Udap.Server.Configuration;
public class ServerSettings
{
// [JsonPropertyName("ServerSupport")]
// [JsonConverter(typeof(JsonStringEnumConverter))]
// public ServerSupport ServerSupport { get; set; }

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

Expand Down Expand Up @@ -56,12 +52,6 @@ public class ServerSettings
}


public enum ServerSupport
{
UDAP = 0,
Hl7SecurityIG = 1
}

public static class ConfigurationExtension
{
public static TOptions GetOption<TOptions>(this IConfiguration configuration, string settingKey)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,7 @@ IEnumerable<Anchor> anchors
)
{
using var activity = Tracing.ValidationActivitySource.StartActivity("UdapDynamicClientRegistrationValidator.Validate");

// _logger.LogDebug($"Start client validation with Server Support Type {_serverSettings.ServerSupport}");



var tokenHandler = new JsonWebTokenHandler();
var jsonWebToken = tokenHandler.ReadJsonWebToken(request.SoftwareStatement);
var jwtHeader = JwtHeader.Base64UrlDeserialize(jsonWebToken.EncodedHeader);
Expand Down Expand Up @@ -452,53 +449,13 @@ IEnumerable<Anchor> anchors
//////////////////////////////

if (client.AllowedGrantTypes.Count != 0 && //Cancel Registration
// _serverSettings.ServerSupport == ServerSupport.Hl7SecurityIG &&
(document.Scope == null || !document.Scope.Any()))
{
return await Task.FromResult(new UdapDynamicClientRegistrationValidationResult(
UdapDynamicClientRegistrationErrors.InvalidClientMetadata,
"scope is required"));
}

// Enrich Scopes: Todo: inject a ScopeEnricher

// TODO: Need a policy engine for various things. UDAP ServerMode allows and empty scope during registration.
// So some kind of policy linked to maybe issued certificate certification and/or community or something
// There are a lot of choices left up to a community. The HL7 ServerMode requires scopes to be sent during registration.
// This doesn't mean the problem is easier it just means we could filter down during registration even if policy
// allowed for a broader list of scopes.
// Below I use ServerSettings from appsettings. This basically says that server is either UDAP or HL7 mode. Well
// sort of. The code is only trying to pass udap.org tests and survive a HL7 connect-a-thon. By putting the logic in
// a policy engine we can have one server UDAP and Hl7 Mode or whatever the policy engine allows.

//
// Also there should be a better way to do this. It will repeat many scope entries per client.
//
// TODO: Remove when we prove we no longer need legacy UDAP server support
// if (_serverSettings.ServerSupport == ServerSupport.UDAP)
// {
// if (string.IsNullOrWhiteSpace(document.Scope))
// {
// IEnumerable<string>? scopes = null;
//
// if (document.GrantTypes != null && document.GrantTypes.Contains(OidcConstants.GrantTypes.ClientCredentials))
// {
// scopes = _serverSettings.DefaultSystemScopes?.FromSpaceSeparatedString();
// }
// else if (document.GrantTypes != null && document.GrantTypes.Contains(OidcConstants.GrantTypes.AuthorizationCode))
// {
// scopes = _serverSettings.DefaultUserScopes?.FromSpaceSeparatedString();
// }
//
// if (scopes != null)
// {
// foreach (var scope in scopes)
// {
// client?.AllowedScopes.Add(scope);
// }
// }
// }
// }
if (document.Scope != null && document.Any())
{
var scopes = document.Scope.Split(' ', StringSplitOptions.RemoveEmptyEntries);
Expand Down
1 change: 0 additions & 1 deletion Udap.Server/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ builder.Services.AddIdentityServer()
var udapServerOptions = builder.Configuration.GetOption<ServerSettings>("ServerSettings");
options.DefaultSystemScopes = udapServerOptions.DefaultSystemScopes;
options.DefaultUserScopes = udapServerOptions.DefaultUserScopes;
options.ServerSupport = udapServerOptions.ServerSupport;
options.ForceStateParamOnAuthorizationCode = udapServerOptions.
ForceStateParamOnAuthorizationCode;
},
Expand Down
11 changes: 0 additions & 11 deletions _tests/Udap.Client.System.Tests/IdServerRegistrationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1336,17 +1336,6 @@ public async Task RegistrationSuccess_authorization_code_FhirLabs_desktop_Test()
}



//
// IDP Server must be running in ServerSupport mode of ServerSupport.UDAP for this to fail and pass the test.
// See part of test where getting Access Token
// var jwtPayload = new JwtPayload(
// result.Issuer,
//
// vs normal
//
// var jwtPayload = new JwtPayload(
// result.ClientId,
//
// If you want Udap.Idp to run in UDAP mode the use "ASPNETCORE_ENVIRONMENT": "Production" to launch. Or
// however you get the serer to pickup appsettings.Production.json
Expand Down
3 changes: 1 addition & 2 deletions _tests/UdapServer.Tests/Hl7RegistrationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@ protected override IHost CreateHost(IHostBuilder builder)

var overrideSettings = new Dictionary<string, string>
{
{ "ConnectionStrings:DefaultConnection", "Data Source=Udap.Idp.db.HL7;" },
{ "ServerSettings:ServerSupport", "Hl7SecurityIG" }
{ "ConnectionStrings:DefaultConnection", "Data Source=Udap.Idp.db.HL7;" }
};

builder.ConfigureHostConfiguration(b => b.AddInMemoryCollection(overrideSettings!));
Expand Down
Loading

0 comments on commit 5439eb4

Please sign in to comment.