Skip to content

Commit

Permalink
Ensured all configuration values are displayed in the settings sectio…
Browse files Browse the repository at this point in the history
…n for the service. (#50)
  • Loading branch information
AndyButland authored Jul 5, 2024
1 parent a531ec8 commit 9119ee0
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,50 @@ public AuthorizedServiceController(
}
}

var settings = new Dictionary<string, string>
{
{ nameof(ServiceDetail.Alias), serviceDetail.Alias },
{ nameof(ServiceDetail.DisplayName), serviceDetail.DisplayName },
{ nameof(ServiceDetail.AuthenticationMethod), serviceDetail.AuthenticationMethod.ToString() },
{ nameof(ServiceDetail.ClientCredentialsProvision), serviceDetail.ClientCredentialsProvision.ToString() },
{ nameof(ServiceDetail.ApiHost), serviceDetail.ApiHost },
{ nameof(ServiceDetail.IdentityHost), serviceDetail.IdentityHost },
{ nameof(ServiceDetail.TokenHost), serviceDetail.TokenHost },
{ nameof(ServiceDetail.CanManuallyProvideApiKey), serviceDetail.CanManuallyProvideApiKey? "Yes" : "No" },
{ nameof(ServiceDetail.CanManuallyProvideToken), serviceDetail.CanManuallyProvideToken ? "Yes" : "No" },
{ nameof(ServiceDetail.RequestAuthorizationPath), serviceDetail.RequestAuthorizationPath },
{ nameof(ServiceDetail.RequestIdentityPath), serviceDetail.RequestIdentityPath },
{ nameof(ServiceDetail.AuthorizationUrlRequiresRedirectUrl), serviceDetail.AuthorizationUrlRequiresRedirectUrl ? "Yes" : "No" },
{ nameof(ServiceDetail.RequestTokenPath), serviceDetail.RequestTokenPath },
{ nameof(ServiceDetail.RequestTokenMethod), serviceDetail.RequestTokenMethod.ToString() },
{ nameof(ServiceDetail.RequestTokenFormat), serviceDetail.RequestTokenFormat is not null ? serviceDetail.RequestTokenFormat.Value.ToString() : string.Empty },
{ nameof(ServiceDetail.JsonSerializer), serviceDetail.JsonSerializer.ToString() },
{ nameof(ServiceDetail.AuthorizationRequestRequiresAuthorizationHeaderWithBasicToken), serviceDetail.AuthorizationRequestRequiresAuthorizationHeaderWithBasicToken ? "Yes" : "No" },
{ nameof(ServiceDetail.ApiKey), new string('*', serviceDetail.ApiKey.Length) },
{ nameof(ServiceDetail.ApiKeyProvision), serviceDetail.ApiKeyProvision is not null ? serviceDetail.ApiKeyProvision.ToString() : string.Empty },
{ nameof(ServiceDetail.ClientId), serviceDetail.ClientId },
{ nameof(ServiceDetail.ClientSecret), new string('*', serviceDetail.ClientSecret.Length) },
{ nameof(ServiceDetail.Scopes), serviceDetail.Scopes },
{ nameof(ServiceDetail.IncludeScopesInAuthorizationRequest), serviceDetail.IncludeScopesInAuthorizationRequest ? "Yes" : "No" },
{ nameof(ServiceDetail.UseProofKeyForCodeExchange), serviceDetail.UseProofKeyForCodeExchange ? "Yes" : "No" },
{ nameof(ServiceDetail.CanExchangeToken), serviceDetail.CanExchangeToken ? "Yes" : "No" },
{ nameof(ServiceDetail.ExchangeTokenProvision) + ":" + nameof(ServiceDetail.ExchangeTokenProvision.TokenHost), serviceDetail.ExchangeTokenProvision?.TokenHost ?? string.Empty },
{ nameof(ServiceDetail.ExchangeTokenProvision) + ":" + nameof(ServiceDetail.ExchangeTokenProvision.RequestTokenPath), serviceDetail.ExchangeTokenProvision?.RequestTokenPath ?? string.Empty },
{ nameof(ServiceDetail.ExchangeTokenProvision) + ":" + nameof(ServiceDetail.ExchangeTokenProvision.TokenGrantType), serviceDetail.ExchangeTokenProvision?.TokenGrantType ?? string.Empty },
{ nameof(ServiceDetail.ExchangeTokenProvision) + ":" + nameof(ServiceDetail.ExchangeTokenProvision.RequestRefreshTokenPath), serviceDetail.ExchangeTokenProvision?.RequestRefreshTokenPath ?? string.Empty },
{ nameof(ServiceDetail.ExchangeTokenProvision) + ":" + nameof(ServiceDetail.ExchangeTokenProvision.RefreshTokenGrantType), serviceDetail.ExchangeTokenProvision?.RefreshTokenGrantType ?? string.Empty },
{ nameof(ServiceDetail.ExchangeTokenProvision) + ":" + nameof(ServiceDetail.ExchangeTokenProvision.ExchangeTokenWhenExpiresWithin), serviceDetail.ExchangeTokenProvision?.ExchangeTokenWhenExpiresWithin.ToString() ?? string.Empty },
{ nameof(ServiceDetail.AccessTokenResponseKey), serviceDetail.AccessTokenResponseKey },
{ nameof(ServiceDetail.RefreshTokenResponseKey), serviceDetail.RefreshTokenResponseKey },
{ nameof(ServiceDetail.ExpiresInResponseKey), serviceDetail.ExpiresInResponseKey },
{
nameof(ServiceDetail.SampleRequest),
!string.IsNullOrEmpty(serviceDetail.SampleRequest)
? serviceDetail.SampleRequest
: string.Empty
}
};

return new AuthorizedServiceDisplay
{
DisplayName = serviceDetail.DisplayName,
Expand All @@ -93,29 +137,7 @@ public AuthorizedServiceController(
AuthorizationUrl = authorizationUrl,
AuthenticationMethod = serviceDetail.AuthenticationMethod.ToString(),
SampleRequest = serviceDetail.SampleRequest,
Settings = new Dictionary<string, string>
{
{ nameof(ServiceDetail.Alias), serviceDetail.Alias },
{ nameof(ServiceDetail.DisplayName), serviceDetail.DisplayName },
{ nameof(ServiceDetail.ApiHost), serviceDetail.ApiHost },
{ nameof(ServiceDetail.AuthenticationMethod), serviceDetail.AuthenticationMethod.ToString() },
{ nameof(ServiceDetail.IdentityHost), serviceDetail.IdentityHost },
{ nameof(ServiceDetail.TokenHost), serviceDetail.TokenHost },
{ nameof(ServiceDetail.RequestIdentityPath), serviceDetail.RequestIdentityPath },
{ nameof(ServiceDetail.RequestTokenPath), serviceDetail.RequestTokenPath },
{ nameof(ServiceDetail.RequestTokenFormat), serviceDetail.RequestTokenFormat is not null ? serviceDetail.RequestTokenFormat.Value.ToString() : string.Empty },
{ nameof(ServiceDetail.ApiKey), serviceDetail.ApiKey },
{ nameof(ServiceDetail.ApiKeyProvision), serviceDetail.ApiKeyProvision is not null ? serviceDetail.ApiKeyProvision.ToString() : string.Empty },
{ nameof(ServiceDetail.ClientId), serviceDetail.ClientId },
{ nameof(ServiceDetail.ClientSecret), new string('*', serviceDetail.ClientSecret.Length) },
{ nameof(ServiceDetail.Scopes), serviceDetail.Scopes },
{
nameof(ServiceDetail.SampleRequest),
!string.IsNullOrEmpty(serviceDetail.SampleRequest)
? serviceDetail.SampleRequest
: string.Empty
}
}
Settings = settings.OrderBy(x => x.Key).ToDictionary(x => x.Key, x => x.Value)
};
}

Expand Down
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
"version": "10.0.0",
"version": "10.0.1",
"assemblyVersion": {
"precision": "build"
},
Expand Down

0 comments on commit 9119ee0

Please sign in to comment.