Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update TrustChainManager.cs #26

Merged
merged 1 commit into from
May 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Spid.Cie.OIDC.AspNetCore/Services/TrustChainManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
DateTimeOffset expiresOn = opConf.ExpiresOn;

bool opValidated = false;
foreach (var authorityHint in opConf.AuthorityHints)
foreach (var authorityHint in opConf.AuthorityHints ?? new())
{
trustChain.Clear();

Expand Down Expand Up @@ -117,9 +117,9 @@
opConf!.Metadata!.OpenIdProvider.JsonWebKeySet = JsonConvert.DeserializeObject<JsonWebKeySet>(keys);
}
}
else if (!string.IsNullOrWhiteSpace(JObject.Parse(decodedOPJwt)["metadata"]["openid_provider"]["jwks"].ToString()))

Check warning on line 120 in src/Spid.Cie.OIDC.AspNetCore/Services/TrustChainManager.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference argument for parameter 'json' in 'JObject JObject.Parse(string json)'.

Check warning on line 120 in src/Spid.Cie.OIDC.AspNetCore/Services/TrustChainManager.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.

Check warning on line 120 in src/Spid.Cie.OIDC.AspNetCore/Services/TrustChainManager.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.

Check warning on line 120 in src/Spid.Cie.OIDC.AspNetCore/Services/TrustChainManager.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.

Check warning on line 120 in src/Spid.Cie.OIDC.AspNetCore/Services/TrustChainManager.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference argument for parameter 'json' in 'JObject JObject.Parse(string json)'.

Check warning on line 120 in src/Spid.Cie.OIDC.AspNetCore/Services/TrustChainManager.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.

Check warning on line 120 in src/Spid.Cie.OIDC.AspNetCore/Services/TrustChainManager.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.

Check warning on line 120 in src/Spid.Cie.OIDC.AspNetCore/Services/TrustChainManager.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.
{
opConf!.Metadata!.OpenIdProvider.JsonWebKeySet = JsonWebKeySet.Create(JObject.Parse(decodedOPJwt)["metadata"]["openid_provider"]["jwks"].ToString());

Check warning on line 122 in src/Spid.Cie.OIDC.AspNetCore/Services/TrustChainManager.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.

Check warning on line 122 in src/Spid.Cie.OIDC.AspNetCore/Services/TrustChainManager.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.

Check warning on line 122 in src/Spid.Cie.OIDC.AspNetCore/Services/TrustChainManager.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.

Check warning on line 122 in src/Spid.Cie.OIDC.AspNetCore/Services/TrustChainManager.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.

Check warning on line 122 in src/Spid.Cie.OIDC.AspNetCore/Services/TrustChainManager.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.

Check warning on line 122 in src/Spid.Cie.OIDC.AspNetCore/Services/TrustChainManager.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.
}
if (opConf!.Metadata!.OpenIdProvider.JsonWebKeySet is null)
{
Expand Down Expand Up @@ -178,7 +178,7 @@
{
Throw<Exception>.If(string.IsNullOrWhiteSpace(url), "Url parameter is not defined");

var metadataAddress = $"{url.EnsureTrailingSlash()!}{SpidCieConst.EntityConfigurationPath}";

Check warning on line 181 in src/Spid.Cie.OIDC.AspNetCore/Services/TrustChainManager.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference argument for parameter 'url' in 'string StringHelpers.EnsureTrailingSlash(string url)'.

Check warning on line 181 in src/Spid.Cie.OIDC.AspNetCore/Services/TrustChainManager.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference argument for parameter 'url' in 'string StringHelpers.EnsureTrailingSlash(string url)'.
var jwt = await _httpClient.GetStringAsync(metadataAddress);
Throw<Exception>.If(string.IsNullOrWhiteSpace(jwt), $"EntityConfiguration JWT not retrieved from url {metadataAddress}");

Expand All @@ -194,7 +194,7 @@
Throw<Exception>.If(string.IsNullOrWhiteSpace(decodedJwtHeader), $"Invalid EntityConfiguration JWT Header for url {metadataAddress}: {jwt}");

var header = JObject.Parse(decodedJwtHeader);
var kid = (string)header[SpidCieConst.Kid];

Check warning on line 197 in src/Spid.Cie.OIDC.AspNetCore/Services/TrustChainManager.cs

View workflow job for this annotation

GitHub Actions / build

Converting null literal or possible null value to non-nullable type.

Check warning on line 197 in src/Spid.Cie.OIDC.AspNetCore/Services/TrustChainManager.cs

View workflow job for this annotation

GitHub Actions / build

Converting null literal or possible null value to non-nullable type.
Throw<Exception>.If(string.IsNullOrWhiteSpace(kid), $"No Kid specified in the EntityConfiguration JWT Header for url {metadataAddress}: {decodedJwtHeader}");

var key = conf!.JWKS.Keys.FirstOrDefault(k => k.kid.Equals(kid, StringComparison.InvariantCultureIgnoreCase));
Expand Down
Loading