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

Post CMS Connect-a-thon 5 #583

Merged
merged 109 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
109 commits
Select commit Hold shift + click to select a range
23742f6
Add a certificate for Brett from Optum
JoeShook May 18, 2024
3dabd5e
Merge branch 'develop' of https://github.com/JoeShook/udap-dotnet int…
JoeShook May 18, 2024
02f8959
Remove code that should not be in this repo. It is used by UdapEd, s…
JoeShook May 19, 2024
13ef015
Update BuildTestCerts.cs
JoeShook May 19, 2024
b554c3e
---
dependabot[bot] May 22, 2024
da91434
Make the allow remember consent to default to false.
JoeShook May 22, 2024
f995271
Merge pull request #518 from JoeShook/dependabot/nuget/develop/Swashb…
JoeShook May 22, 2024
1f4b7ab
Bump Microsoft.NET.Test.Sdk from 17.9.0 to 17.10.0
dependabot[bot] May 23, 2024
d3a1df9
Bump Udap.Client, Udap.Common and Udap.Util
dependabot[bot] May 23, 2024
d38f5fc
Bump FluentAssertions.Analyzers from 0.31.0 to 0.32.0
dependabot[bot] May 24, 2024
465c398
Bump xunit from 2.8.0 to 2.8.1
dependabot[bot] May 27, 2024
f75d719
Bump Microsoft.IdentityModel.Tokens from 7.5.2 to 7.6.0
dependabot[bot] May 28, 2024
067938d
Bump Microsoft.EntityFrameworkCore.InMemory and Microsoft.EntityFrame…
dependabot[bot] May 29, 2024
5f6c784
Bump Microsoft.AspNetCore.Mvc.Testing from 8.0.5 to 8.0.6
dependabot[bot] May 29, 2024
c5dff70
Merge pull request #519 from JoeShook/dependabot/nuget/develop/Micros…
JoeShook Jun 4, 2024
e337cca
Merge pull request #520 from JoeShook/dependabot/nuget/develop/multi-…
JoeShook Jun 4, 2024
5a67c78
Merge pull request #521 from JoeShook/dependabot/nuget/develop/Fluent…
JoeShook Jun 4, 2024
926b200
Merge pull request #522 from JoeShook/dependabot/nuget/develop/xunit-…
JoeShook Jun 4, 2024
61e434a
Merge pull request #524 from JoeShook/dependabot/nuget/develop/Micros…
JoeShook Jun 4, 2024
07c9f04
Merge pull request #525 from JoeShook/dependabot/nuget/develop/multi-…
JoeShook Jun 4, 2024
8a0926e
Merge pull request #527 from JoeShook/dependabot/nuget/develop/Micros…
JoeShook Jun 4, 2024
3418e24
Bump xunit.runner.visualstudio from 2.8.0 to 2.8.1
dependabot[bot] Jun 4, 2024
eebe49a
Merge pull request #523 from JoeShook/dependabot/nuget/develop/xunit.…
JoeShook Jun 4, 2024
d160daa
Bump Microsoft.EntityFrameworkCore from 8.0.5 to 8.0.6
dependabot[bot] Jun 5, 2024
73541be
Bump Microsoft.IdentityModel.JsonWebTokens from 7.5.2 to 7.6.0
dependabot[bot] Jun 5, 2024
5d7071b
Bump Microsoft.AspNetCore.DataProtection.Abstractions
dependabot[bot] Jun 5, 2024
3c5bafb
Bump Microsoft.Data.SqlClient from 5.2.0 to 5.2.1
dependabot[bot] Jun 5, 2024
155a648
Bump dotnet-ef from 8.0.5 to 8.0.6
dependabot[bot] Jun 5, 2024
ff0ca8c
Bump MudBlazor from 6.19.1 to 6.20.0
dependabot[bot] Jun 5, 2024
6d84cc7
Bump Microsoft.AspNetCore.Authentication.JwtBearer from 8.0.3 to 8.0.6
dependabot[bot] Jun 5, 2024
079ff51
Merge pull request #535 from JoeShook/dependabot/nuget/develop/MudBla…
JoeShook Jun 12, 2024
4a03f1b
Merge pull request #529 from JoeShook/dependabot/nuget/develop/Micros…
JoeShook Jun 12, 2024
52217d5
Merge pull request #530 from JoeShook/dependabot/nuget/develop/Micros…
JoeShook Jun 12, 2024
af76214
Merge pull request #531 from JoeShook/dependabot/nuget/develop/Micros…
JoeShook Jun 12, 2024
8ad922a
Merge pull request #534 from JoeShook/dependabot/nuget/develop/dotnet…
JoeShook Jun 12, 2024
5c934d6
Merge pull request #533 from JoeShook/dependabot/nuget/develop/Micros…
JoeShook Jun 12, 2024
959205c
Merge pull request #537 from JoeShook/dependabot/nuget/develop/Micros…
JoeShook Jun 12, 2024
c897d93
Bump Microsoft.AspNetCore.DataProtection.EntityFrameworkCore
dependabot[bot] Jun 12, 2024
fab000c
Bump Microsoft.EntityFrameworkCore.Sqlite from 8.0.5 to 8.0.6
dependabot[bot] Jun 12, 2024
74271c3
Merge pull request #539 from JoeShook/dependabot/nuget/develop/Micros…
JoeShook Jun 12, 2024
ee9448e
Merge pull request #540 from JoeShook/dependabot/nuget/develop/Micros…
JoeShook Jun 12, 2024
08873c3
Bump Microsoft.AspNetCore.Authentication.OpenIdConnect
dependabot[bot] Jun 12, 2024
a54740c
Bump System.IdentityModel.Tokens.Jwt from 7.5.2 to 7.6.0
dependabot[bot] Jun 12, 2024
8bf8b55
Bump Microsoft.EntityFrameworkCore.Design from 8.0.5 to 8.0.6
dependabot[bot] Jun 12, 2024
aa07a1c
Bump Microsoft.EntityFrameworkCore.SqlServer from 8.0.5 to 8.0.6
dependabot[bot] Jun 12, 2024
76038dc
Bump MartinCostello.Logging.XUnit from 0.3.0 to 0.4.0
dependabot[bot] Jun 12, 2024
5467007
Bump Duende.IdentityServer.Storage from 6.3.7 to 7.0.5
dependabot[bot] Jun 12, 2024
5ce6c01
Bump Microsoft.Extensions.Http.Polly from 8.0.5 to 8.0.6
dependabot[bot] Jun 12, 2024
2fb5139
Merge pull request #541 from JoeShook/dependabot/nuget/develop/Micros…
JoeShook Jun 12, 2024
0e698c9
Merge pull request #542 from JoeShook/dependabot/nuget/develop/System…
JoeShook Jun 12, 2024
0710449
Merge pull request #543 from JoeShook/dependabot/nuget/develop/Micros…
JoeShook Jun 12, 2024
8040d34
Merge pull request #544 from JoeShook/dependabot/nuget/develop/Micros…
JoeShook Jun 12, 2024
1568e69
Merge pull request #545 from JoeShook/dependabot/nuget/develop/Martin…
JoeShook Jun 12, 2024
3cf2d00
Merge pull request #547 from JoeShook/dependabot/nuget/develop/Micros…
JoeShook Jun 12, 2024
9c51637
Merge pull request #546 from JoeShook/dependabot/nuget/develop/Duende…
JoeShook Jun 12, 2024
12f7ce6
Proxy wip
JoeShook Jun 20, 2024
cfebecd
Merge branch 'develop' of https://github.com/JoeShook/udap-dotnet int…
JoeShook Jun 20, 2024
607f279
Retain some experimental tests.
JoeShook Jun 20, 2024
662ef64
Save some experimetal work on renewing certificates
JoeShook Jun 20, 2024
c5f1dd1
Retain some experimental tests.
JoeShook Jun 20, 2024
2c4d7b9
Package updates
JoeShook Jun 20, 2024
4392c5d
Comment out test. Not meant to run on build server.
JoeShook Jun 20, 2024
18ccf56
Bump Microsoft.IdentityModel.Tokens from 7.6.0 to 7.6.2
dependabot[bot] Jun 21, 2024
aad3407
Fix client examples
JoeShook Jun 23, 2024
37052ab
Merge pull request #560 from JoeShook/dependabot/nuget/develop/Micros…
JoeShook Jun 23, 2024
3dbec04
Bump Microsoft.IdentityModel.Protocols.OpenIdConnect from 7.5.2 to 7.6.2
dependabot[bot] Jun 24, 2024
b339176
Bump System.CommandLine.Hosting and System.CommandLine
dependabot[bot] Jun 25, 2024
9ba958e
Merge pull request #562 from JoeShook/dependabot/nuget/develop/multi-…
JoeShook Jun 28, 2024
330ad14
Merge pull request #561 from JoeShook/dependabot/nuget/develop/Micros…
JoeShook Jun 28, 2024
0d6ff23
Bump Microsoft.VisualStudio.Azure.Containers.Tools.Targets
dependabot[bot] Jul 1, 2024
e78b191
wip Certifications and Endorsements
JoeShook Jul 1, 2024
7400a1b
Merge branch 'develop' of https://github.com/JoeShook/udap-dotnet int…
JoeShook Jul 1, 2024
6e51071
Package updates
JoeShook Jul 1, 2024
edb1b3c
Update CertificationsDocumentTest.cs
JoeShook Jul 1, 2024
d0328c5
Bump Udap.Client, Udap.Common and Udap.Util
dependabot[bot] Jul 2, 2024
54843d8
Merge pull request #566 from JoeShook/dependabot/nuget/develop/multi-…
JoeShook Jul 2, 2024
dc03986
Merge pull request #564 from JoeShook/dependabot/nuget/develop/Micros…
JoeShook Jul 2, 2024
361dee2
WIP: Build Certificates for mTLS and Certifications and Endorsements
JoeShook Jul 5, 2024
e134f86
Merge branch 'develop' of https://github.com/JoeShook/udap-dotnet int…
JoeShook Jul 5, 2024
5f59e93
Trigger build
JoeShook Jul 5, 2024
d52950c
let more tests run in parallel
JoeShook Jul 5, 2024
b80e63a
Bump xunit.runner.visualstudio from 2.8.1 to 2.8.2
dependabot[bot] Jul 9, 2024
eb01118
First cut of a mTLS proxy server to GCP FHIR Server.
JoeShook Jul 9, 2024
ca28bdf
More mTLS cert generation and misc house keeping
JoeShook Jul 10, 2024
076cae0
Merge pull request #568 from JoeShook/dependabot/nuget/develop/xunit.…
JoeShook Jul 12, 2024
43c8178
Package updates
JoeShook Jul 12, 2024
210a869
Update packages
JoeShook Jul 12, 2024
27c4176
Fixup possible race conditions
JoeShook Jul 12, 2024
e11b655
Fixup possible race conditions continued
JoeShook Jul 12, 2024
842ad69
Bump dotnet-ef from 8.0.6 to 8.0.7
dependabot[bot] Jul 12, 2024
ebd2561
Bump Microsoft.IdentityModel.Protocols.OpenIdConnect and Microsoft.Id…
dependabot[bot] Jul 12, 2024
ea3eb56
Update TrustChainValidator.cs
JoeShook Jul 12, 2024
06d5c2b
Bump Microsoft.AspNetCore.Authentication.OpenIdConnect
dependabot[bot] Jul 15, 2024
0c2889d
DiscoveryUrl Parsing fixup
JoeShook Jul 15, 2024
60a6738
Merge pull request #578 from JoeShook/dependabot/nuget/develop/Micros…
JoeShook Jul 15, 2024
be379c1
Merge pull request #577 from JoeShook/dependabot/nuget/develop/multi-…
JoeShook Jul 15, 2024
343d27e
Merge pull request #573 from JoeShook/dependabot/nuget/develop/dotnet…
JoeShook Jul 15, 2024
a6b43f8
Bump Microsoft.AspNetCore.DataProtection.Abstractions
dependabot[bot] Jul 15, 2024
664d92c
Merge pull request #569 from JoeShook/dependabot/nuget/develop/Micros…
JoeShook Jul 15, 2024
701b7ed
Allow the consumer to pass a fully build UDAP well-known url with com…
JoeShook Jul 15, 2024
e9588f1
Merge branch 'develop' of https://github.com/JoeShook/udap-dotnet int…
JoeShook Jul 15, 2024
c1ff521
New tests and fixups to handle Authorization Certificate Rolloer
JoeShook Jul 18, 2024
8e9d669
Rollover continued.
JoeShook Jul 18, 2024
802f5ad
Clean up un-needed package server refs.
JoeShook Jul 18, 2024
4b2d543
Update nuget.config
JoeShook Jul 18, 2024
cb66e29
Return the Azure nuget package source.
JoeShook Jul 19, 2024
5d1fa3a
Return the Azure nuget package source.
JoeShook Jul 19, 2024
c5e7ef2
package updates
JoeShook Jul 19, 2024
20e7c53
Update Directory.Packages.props
JoeShook Jul 19, 2024
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 .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"dotnet-ef": {
"version": "8.0.5",
"version": "8.0.7",
"commands": [
"dotnet-ef"
]
Expand Down
39 changes: 19 additions & 20 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,29 @@
</PropertyGroup>
<ItemGroup>
<!-- https://learn.microsoft.com/en-us/nuget/concepts/package-versioning#version-ranges -->
<PackageVersion Include="Duende.IdentityServer.Storage" Version="6.3.7" />
<PackageVersion Include="Duende.IdentityServer.Storage" Version="7.0.5" />
<PackageVersion Include="Google.Apis.Auth" Version="1.68.0" />
<PackageVersion Include="LazyCache" Version="2.4.0" />
<PackageVersion Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.3" />
<PackageVersion Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.6" />
<PackageVersion Include="AspNetCoreRateLimit" Version="5.0.0" />
<PackageVersion Include="Hl7.Fhir.Specification.R4B" Version="5.8.1" />
<PackageVersion Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="8.0.5" />
<PackageVersion Include="Microsoft.AspNetCore.DataProtection.Abstractions" Version="8.0.5" />
<PackageVersion Include="Microsoft.AspNetCore.DataProtection.EntityFrameworkCore" Version="8.0.5" />
<PackageVersion Include="Hl7.Fhir.Specification.R4B" Version="5.8.2" />
<PackageVersion Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="8.0.7" />
<PackageVersion Include="Microsoft.AspNetCore.DataProtection.Abstractions" Version="8.0.7" />
<PackageVersion Include="Microsoft.AspNetCore.DataProtection.EntityFrameworkCore" Version="8.0.7" />
<PackageVersion Include="Microsoft.Extensions.Hosting.Abstractions" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
<PackageVersion Include="Microsoft.IdentityModel.Protocols.OpenIdConnect" Version="7.5.2" />
<PackageVersion Include="Microsoft.IdentityModel.Tokens" Version="7.5.2" />
<PackageVersion Include="Microsoft.IdentityModel.Protocols.OpenIdConnect" Version="7.6.3" />
<PackageVersion Include="MSTest.TestAdapter" Version="3.1.1" />
<PackageVersion Include="MSTest.TestFramework" Version="3.1.1" />
<PackageVersion Include="IdentityModel" Version="7.0.0" />
<!-- <PackageVersion Include="System.Text.Json" Version="[6.0.7,8.0.3]" /> -->
<PackageVersion Include="AutoMapper" Version="13.0.1" />
<PackageVersion Include="Duende.IdentityServer" Version="7.0.4" />
<PackageVersion Include="Duende.IdentityServer.AspNetIdentity" Version="7.0.4" />
<PackageVersion Include="Duende.IdentityServer.EntityFramework.Storage" Version="7.0.4" />
<PackageVersion Include="Duende.IdentityServer" Version="7.0.5" />
<PackageVersion Include="Duende.IdentityServer.AspNetIdentity" Version="7.0.5" />
<PackageVersion Include="Duende.IdentityServer.EntityFramework.Storage" Version="7.0.5" />
<PackageVersion Include="IdentityModel.AspNetCore.OAuth2Introspection" Version="6.2.0" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="8.0.5" />
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="8.0.7" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Design" Version="[7.0.13,8.0.1]" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.SqlServer" Version="[7.0.13,8.0.0]" />
<PackageVersion Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.20.1" />
Expand All @@ -37,18 +36,18 @@
<PackageVersion Include="Microsoft.Extensions.Configuration.Abstractions" Version="[6.0.0,7.0.1]" />
<PackageVersion Include="Microsoft.Extensions.Options" Version="8.0.2" />
<PackageVersion Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="8.0.0" />
<PackageVersion Include="Microsoft.IdentityModel.JsonWebTokens" Version="7.5.2" />
<PackageVersion Include="OpenTelemetry" Version="1.8.1" />
<PackageVersion Include="OpenTelemetry.Exporter.Console" Version="1.8.1" />
<PackageVersion Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.8.1" />
<PackageVersion Include="OpenTelemetry.Extensions.Hosting" Version="1.8.1" />
<PackageVersion Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.8.1" />
<PackageVersion Include="OpenTelemetry.Instrumentation.Http" Version="1.8.1" />
<PackageVersion Include="Microsoft.IdentityModel.JsonWebTokens" Version="8.0.0" />
<PackageVersion Include="OpenTelemetry" Version="1.9.0" />
<PackageVersion Include="OpenTelemetry.Exporter.Console" Version="1.9.0" />
<PackageVersion Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.9.0" />
<PackageVersion Include="OpenTelemetry.Extensions.Hosting" Version="1.9.0" />
<PackageVersion Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.9.0" />
<PackageVersion Include="OpenTelemetry.Instrumentation.Http" Version="1.9.0" />
<PackageVersion Include="OpenTelemetry.Instrumentation.SqlClient" Version="1.0.0-rc9.14" />
<PackageVersion Include="Serilog.AspNetCore" Version="[6.1.0,7.0.0]" />
<PackageVersion Include="Serilog.Extensions.Logging" Version="[3.1.0,7.0.0]" />
<PackageVersion Include="Portable.BouncyCastle" Version="1.9.0" />
<PackageVersion Include="System.IdentityModel.Tokens.Jwt" Version="7.5.2" />
<PackageVersion Include="System.IdentityModel.Tokens.Jwt" Version="8.0.0" />
<PackageVersion Include="Udap.Metadata.Server" Version="0.3.24" />
<PackageVersion Include="Yarp.ReverseProxy" Version="2.1.0" />
</ItemGroup>
Expand Down
8 changes: 7 additions & 1 deletion Udap.Client/Client/DiscoveryEndpoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,20 @@ public class DiscoveryEndpoint
/// Parses a URL and turns it into authority and discovery endpoint URL.
/// </summary>
/// <param name="input">The input.</param>
/// <param name="path">The path to the discovery document. If not specified this defaults to .well-known/open-id-configuration</param>
/// <param name="path">The path to the discovery document. If not specified this defaults to .well-known/udap</param>
/// <param name="community">Optional community qualifier</param>
/// <returns></returns>
/// <exception cref="System.InvalidOperationException">
/// Malformed URL
/// </exception>
public static DiscoveryEndpoint ParseUrl(string input, string? path = null, string? community = null)
{
if (input.Contains(UdapConstants.Discovery.DiscoveryEndpoint))
{
var i = input.IndexOf(UdapConstants.Discovery.DiscoveryEndpoint, StringComparison.Ordinal);
return new DiscoveryEndpoint(input.Substring(0, i).RemoveTrailingSlash(), input);
}

if (string.IsNullOrEmpty(path))
{
path = UdapConstants.Discovery.DiscoveryEndpoint;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ public static async Task<UdapDiscoveryDocumentResponse> GetUdapDiscoveryDocument
$"Error connecting to {url}: {response.ReasonPhrase}").ConfigureAwait(false);
}

var joe = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
var disco = await ProtocolResponse
.FromHttpResponseAsync<UdapDiscoveryDocumentResponse>(response, request.Policy)
.ConfigureAwait(false);
Expand Down
3 changes: 1 addition & 2 deletions Udap.Client/Client/IUdapClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ namespace Udap.Client.Client;

public interface IUdapClient : IUdapClientEvents
{
//TODO Cancellation Token add...
Task<UdapDiscoveryDocumentResponse> ValidateResource(
string baseUrl,
string? community = null,
Expand All @@ -41,7 +40,7 @@ Task<UdapDiscoveryDocumentResponse> ValidateResource(

/// <summary>
/// Register a TieredClient in the Authorization Server.
/// Currently it is not SAN aware. It picks the first SAN.
/// Currently, it is not SAN aware. It picks the first SAN.
/// To pick a different community the client can add a community query parameter to the .
/// </summary>
/// <param name="redirectUrl"></param>
Expand Down
7 changes: 7 additions & 0 deletions Udap.Client/Client/UdapClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
using Udap.Client.Configuration;
using Udap.Client.Extensions;
using Udap.Common.Certificates;
using Udap.Common.Extensions;
using Udap.Model;
using Udap.Model.Access;
using Udap.Model.Registration;
Expand Down Expand Up @@ -317,6 +318,12 @@ private async Task<UdapDiscoveryDocumentResponse> InternalValidateResource(
UdapServerMetaData = disco.Json?.Deserialize<UdapMetadata>();
_logger.LogDebug(UdapServerMetaData?.SerializeToJson());

if (baseUrl.Contains(UdapConstants.Discovery.DiscoveryEndpoint))
{
var i = baseUrl.IndexOf(UdapConstants.Discovery.DiscoveryEndpoint, StringComparison.Ordinal);
baseUrl = baseUrl.Substring(0, i).RemoveTrailingSlash();
}

if (!await _clientDiscoveryValidator.ValidateJwtToken(UdapServerMetaData!, baseUrl))
{
throw new SecurityTokenInvalidTypeException("Failed JWT Token Validation");
Expand Down
17 changes: 0 additions & 17 deletions Udap.Client/Rest/FhirClientWithUrlProvider.cs

This file was deleted.

15 changes: 0 additions & 15 deletions Udap.Client/Rest/IBaseUrlProvider.cs

This file was deleted.

2 changes: 1 addition & 1 deletion Udap.Client/Udap.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
</ItemGroup>


<ItemGroup >
<ItemGroup>
<PackageReference Include="IdentityModel" />
</ItemGroup>

Expand Down
28 changes: 20 additions & 8 deletions Udap.Common/Certificates/TrustChainValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,21 @@
{
throw new ArgumentNullException(nameof(certificate));
}


// Let's avoid complex state and/or race conditions by making copies of these collections.
X509Certificate2Collection roots = new X509Certificate2Collection(anchorCertificates);
X509Certificate2Collection? intermeds = null;

if (intermediateCertificates != null)
{
intermeds = new X509Certificate2Collection(intermediateCertificates);
}

intermediateCertificates = null;
anchorCertificates = null;

Check warning on line 151 in Udap.Common/Certificates/TrustChainValidator.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 151 in Udap.Common/Certificates/TrustChainValidator.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 151 in Udap.Common/Certificates/TrustChainValidator.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

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

// if there are no anchors we should always fail
if (anchorCertificates.IsNullOrEmpty())
if (roots.IsNullOrEmpty())
{
this.NotifyUntrusted(certificate);
return false;
Expand All @@ -159,19 +171,19 @@
// Again more to test here.
//

var chainBuilder = new X509Chain();
using var chainBuilder = new X509Chain();

if (!anchorCertificates.IsNullOrEmpty())
if (!roots.IsNullOrEmpty())
{
chainPolicy.CustomTrustStore.Clear();
chainPolicy.TrustMode = X509ChainTrustMode.CustomRootTrust;
chainPolicy.CustomTrustStore.AddRange(anchorCertificates);
chainPolicy.CustomTrustStore.AddRange(roots);
}

chainBuilder.ChainPolicy = chainPolicy;
if (intermediateCertificates != null)
if (intermeds != null)
{
chainBuilder.ChainPolicy.ExtraStore.AddRange(intermediateCertificates!);
chainBuilder.ChainPolicy.ExtraStore.AddRange(intermeds!);
}
var result = chainBuilder.Build(certificate);

Expand All @@ -191,7 +203,7 @@
// walk the chain starting at the leaf and see if we hit any issues before the anchor
foreach (var chainElement in chainElements)
{
bool isAnchor = anchorCertificates?.FindByThumbprint(chainElement.Certificate.Thumbprint) != null;
bool isAnchor = roots?.FindByThumbprint(chainElement.Certificate.Thumbprint) != null;

if (this.ChainElementHasProblems(chainElement))
{
Expand Down
27 changes: 27 additions & 0 deletions Udap.Common/Standard/ObjectIdentifiers.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#region (c) 2024 Joseph Shook. All rights reserved.
// /*
// Authors:
// Joseph Shook Joseph.Shook@Surescripts.com
//
// See LICENSE in the project root for license information.
// */
#endregion

namespace Udap.Common.Standard;
public static class ObjectIdentifiers
{
public static class UdapExperimental
{
public static class UdapAccessControl
{
public static class General
{
public const string Create = "1.3.6.1.4.1.12345.1.1";
public const string Read = "1.3.6.1.4.1.12345.1.2";
public const string Update = "1.3.6.1.4.1.12345.1.3";
public const string Delete = "1.3.6.1.4.1.12345.1.4";
public const string Admin = "1.3.6.1.4.1.12345.1.5";
}
}
}
}
20 changes: 14 additions & 6 deletions Udap.Model/Registration/UdapCertificationAndEndorsementDocument.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#endregion

using System;
using System.Collections.Generic;
using System.IdentityModel.Tokens.Jwt;
using System.Text.Json;
using System.Text.Json.Serialization;
Expand Down Expand Up @@ -53,6 +54,13 @@ public UdapCertificationAndEndorsementDocument(string certificationName)
[JsonPropertyName(UdapConstants.CertificationAndEndorsementDocumentValues.Subject)]
public string? Subject { get; set; }

/// <summary>
/// string, registration endpoint URL of Authorization Server (optional, single valued or array).
/// If absent, this certification is intended for all audiences.
/// </summary>
[JsonPropertyName(UdapConstants.CertificationAndEndorsementDocumentValues.Audience)]
public string? Audience { get; set; }

/// <summary>
/// number, expiration time (max 3 years, must not expire after certificate).
/// Expressed in seconds since the "Epoch".
Expand Down Expand Up @@ -117,7 +125,7 @@ public UdapCertificationAndEndorsementDocument(string certificationName)
/// true if this certification represents an endorsement of the Client App by the issuer.
/// </summary>
[JsonPropertyName(UdapConstants.CertificationAndEndorsementDocumentValues.IsEndorsement)]
public bool? IsEndorsement { get; set; }
public bool? IsEndorsement { get; set; } = false;

/// <summary>
/// string (optional)
Expand Down Expand Up @@ -179,7 +187,7 @@ public UdapCertificationAndEndorsementDocument(string certificationName)
/// so that AS operator can contact client app developer
/// </summary>
[JsonPropertyName(UdapConstants.CertificationAndEndorsementDocumentValues.Contacts)]
public string[]? Contacts { get; set; }
public ICollection<string>? Contacts { get; set; }

/// <summary>
/// string, for SMART app launch with EHR launch flow, requires scope includes launch
Expand All @@ -203,27 +211,27 @@ public UdapCertificationAndEndorsementDocument(string certificationName)
/// contain any wildcard symbols, even if the certification includes a wildcard symbol.
/// </summary>
[JsonPropertyName(UdapConstants.CertificationAndEndorsementDocumentValues.RedirectUris)]
public string[]? RedirectUris { get; set; }
public ICollection<string>? RedirectUris { get; set; }

/// <summary>
/// array of strings of the form ip, ip1-ip2, or ip/CIDR (optional); origin IP to connect
/// to token endpoint, e.g. ["198.51.100.0/24", "203.0.113.55"]
/// </summary>
[JsonPropertyName(UdapConstants.CertificationAndEndorsementDocumentValues.IpAllowed)]
public string[]? IpAllowed { get; set; }
public ICollection<string>? IpAllowed { get; set; }

/// <summary>
/// array of strings, as per RFC 7591; e.g. authorization_code, refresh_token,
/// client_credentials (optional)
/// </summary>
[JsonPropertyName(UdapConstants.CertificationAndEndorsementDocumentValues.GrantTypes)]
public string[]? GrantTypes { get; set; }
public ICollection<string>? GrantTypes { get; set; }

/// <summary>
/// array of strings, as per RFC 7591; code (omit for client_credentials) (optional)
/// </summary>
[JsonPropertyName(UdapConstants.CertificationAndEndorsementDocumentValues.ResponseTypes)]
public string[]? ResponseTypes { get; set; }
public ICollection<string>? ResponseTypes { get; set; }

/// <summary>
/// string containing space separate list of permitted scopes, as per RFC 7591; optional
Expand Down
Loading
Loading