Skip to content

Commit

Permalink
Merge pull request #1 from JonathanVil/main
Browse files Browse the repository at this point in the history
Fix Invalid URI exception on non-unix based systems
  • Loading branch information
clinically-au authored Jun 2, 2024
2 parents a4b3086 + 2ad4672 commit cec5efb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions KindeAuthenticationBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ public static AuthenticationBuilder AddKindeJwtBearerAuthentication(this IServic
kindeAuthenticationOptions(configOptions);

if (string.IsNullOrEmpty(configOptions.Domain))
configOptions.Domain = GetRequiredConfiguration("Kinde:Domain", configuration);
configOptions.Domain = GetRequiredConfiguration("Kinde:Domain", configuration).TrimEnd('/');
if (string.IsNullOrEmpty(configOptions.ClientId))
configOptions.ClientId = GetRequiredConfiguration("Kinde:ClientId", configuration);
if (string.IsNullOrEmpty(configOptions.ClientSecret))
configOptions.ClientSecret = GetRequiredConfiguration("Kinde:ClientSecret", configuration);
if (string.IsNullOrEmpty(configOptions.ManagementApiAudience))
configOptions.ManagementApiAudience = Path.Combine(configOptions.Domain, "api");
configOptions.ManagementApiAudience = $"{configOptions.Domain}/api";
if (string.IsNullOrEmpty(configOptions.JwtAudience))
configOptions.JwtAudience = GetRequiredConfiguration("Kinde:JwtAudience", configuration);

Expand All @@ -65,7 +65,7 @@ public static AuthenticationBuilder AddKindeJwtBearerAuthentication(this IServic
{
var client = new HttpClient();
// TODO: cache this?
var response = client.GetAsync(new Uri(Path.Combine(configOptions.Domain, ".well-known/jwks"))).Result;
var response = client.GetAsync(new Uri($"{configOptions.Domain}/.well-known/jwks")).Result;
var responseString = response.Content.ReadAsStringAsync().Result;
return JwksHelper.LoadKeysFromJson(responseString);
}
Expand Down Expand Up @@ -205,15 +205,15 @@ public static AuthenticationBuilder AddKindeIdentityAuthentication(this IService
kindeAuthenticationOptions(configOptions);

if (string.IsNullOrEmpty(configOptions.Domain))
configOptions.Domain = GetRequiredConfiguration("Kinde:Domain", configuration);
configOptions.Domain = GetRequiredConfiguration("Kinde:Domain", configuration).TrimEnd('/');
if (string.IsNullOrEmpty(configOptions.ClientId))
configOptions.ClientId = GetRequiredConfiguration("Kinde:ClientId", configuration);
if (string.IsNullOrEmpty(configOptions.ClientSecret))
configOptions.ClientSecret = GetRequiredConfiguration("Kinde:ClientSecret", configuration);
if (string.IsNullOrEmpty(configOptions.SignedOutRedirectUri))
configOptions.SignedOutRedirectUri = GetRequiredConfiguration("Kinde:SignedOutRedirectUri", configuration);
if (string.IsNullOrEmpty(configOptions.ManagementApiAudience))
configOptions.ManagementApiAudience = Path.Combine(configOptions.Domain, "api");
configOptions.ManagementApiAudience = $"{configOptions.Domain}/api";

services.AddHttpClient();
services.AddHttpContextAccessor();
Expand Down
2 changes: 1 addition & 1 deletion ManagementApi/KindeManagementApiAuthenticationHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public async Task<string> GetAuthTokenAsync()
content.Headers.Clear();
content.Headers.Add("Content-Type", "application/x-www-form-urlencoded");

var response = await client.PostAsync(Path.Combine(options.Domain, "oauth2/token"), content).ConfigureAwait(false);
var response = await client.PostAsync($"{options.Domain}/oauth2/token", content).ConfigureAwait(false);
if (!response.IsSuccessStatusCode)
{
logger.LogCritical(@"Unable to authenticate with Kinde Management API {StatusCode} {Error}",
Expand Down

0 comments on commit cec5efb

Please sign in to comment.