Skip to content
This repository was archived by the owner on Sep 8, 2025. It is now read-only.

Commit c6c180a

Browse files
authored
Merge branch 'main' into joe/wilson
2 parents 1dc50d8 + 9b017ae commit c6c180a

File tree

17 files changed

+192
-19
lines changed

17 files changed

+192
-19
lines changed

README.md

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,43 @@
1-
# C#/NetStandard OpenID Connect Client Library for native Applications
2-
Supported platforms: netstandard14, desktop .NET, UWP, .NET Core, Xamarin iOS & Android. [Nuget.](https://www.nuget.org/packages/IdentityModel.OidcClient/)
1+
## About IdentityModel.OidcClient
2+
This repository contains several libraries for building OpenID Connect (OIDC) native
3+
clients. The core IdentityModel.OidcClient library is a certified OIDC relying party and
4+
implements [RFC 8252](https://tools.ietf.org/html/rfc8252/), "OAuth 2.0 for native
5+
Applications". The IdentityModel.OidcClient.IdTokenValidator provides validation of Id
6+
Tokens based on the Microsoft JWT handler:
7+
[IdentityModel.OidcClient.IdentityTokenValidator](https://www.nuget.org/packages/IdentityModel.OidcClient.IdentityTokenValidator),
8+
and is distributed as a separate package in order to prevent certain dependency problems.
9+
Finally, IdentityModel.OidcClient.DPoP adds [DPoP](https://datatracker.ietf.org/doc/html/rfc9449)
10+
extensions to IdentityModel.OidcClient for sender-constraining tokens.
311

4-
[Certified](http://openid.net/certification/) OpenID Connect relying party implementation.
12+
13+
## Samples
14+
OidcClient targets .NET Standard, making it suitable for .NET and .NET
15+
Framework. It can be used to build OIDC native clients with a variety of .NET UI tools.
16+
The [samples repository](https://github.com/IdentityModel/IdentityModel.OidcClient.Samples)
17+
shows how to use it in
18+
- .NET MAUI
19+
- Console Applications
20+
- WPF
21+
- WinForms
22+
- Xamarin iOS & Android
23+
- UWP
24+
25+
## Documentation
26+
27+
More documentation is available
28+
[here](https://identitymodel.readthedocs.io/en/latest/native/overview.html).
29+
30+
31+
## Certification
32+
OidcClient is a [certified](http://openid.net/certification/) OpenID Connect
33+
relying party implementation.
534

635
![openid_certified](https://cloud.githubusercontent.com/assets/1454075/7611268/4d19de32-f97b-11e4-895b-31b2455a7ca6.png)
736

8-
See [here](https://identitymodel.readthedocs.io/en/latest/native/overview.html) for documentation and [here](https://github.com/IdentityModel/IdentityModel.OidcClient.Samples) for samples.
37+
38+
## Feedback
39+
40+
IdentityModel.OidcClient is released as open source under the
41+
[Apache 2.0 license](https://github.com/IdentityModel/IdentityModel.OidcClient/blob/main/LICENSE).
42+
Bug reports and contributions are welcome at
43+
[the GitHub repository](https://github.com/IdentityModel/IdentityModel.OidcClient).

clients/ConsoleClientWithBrowser/Program.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Net.Http;
66
using System.Text.Json;
77
using System.Threading.Tasks;
8+
using Microsoft.Extensions.Logging;
89
using Serilog.Sinks.SystemConsole.Themes;
910

1011
namespace ConsoleClientWithBrowser
@@ -54,7 +55,7 @@ private static async Task SignIn()
5455
.WriteTo.Console(outputTemplate: "[{Timestamp:HH:mm:ss} {Level}] {SourceContext}{NewLine}{Message}{NewLine}{Exception}{NewLine}", theme: AnsiConsoleTheme.Code)
5556
.CreateLogger();
5657

57-
options.LoggerFactory.AddSerilog(serilog);
58+
options.LoggerFactory = new LoggerFactory().AddSerilog(serilog);
5859

5960
_oidcClient = new OidcClient(options);
6061
var result = await _oidcClient.LoginAsync(new LoginRequest());

clients/ConsoleClientWithBrowserAndDPoP/Program.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using System.Threading.Tasks;
99
using Serilog.Sinks.SystemConsole.Themes;
1010
using IdentityModel.OidcClient.DPoP;
11+
using Microsoft.Extensions.Logging;
1112

1213
namespace ConsoleClientWithBrowserAndDPoP
1314
{
@@ -57,7 +58,7 @@ private static async Task SignIn()
5758
.WriteTo.Console(outputTemplate: "[{Timestamp:HH:mm:ss} {Level}] {SourceContext}{NewLine}{Message}{NewLine}{Exception}{NewLine}", theme: AnsiConsoleTheme.Code)
5859
.CreateLogger();
5960

60-
options.LoggerFactory.AddSerilog(serilog);
61+
options.LoggerFactory = new LoggerFactory().AddSerilog(serilog);
6162

6263
_oidcClient = new OidcClient(options);
6364

src/DPoP/DPoP.csproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<Description>DPoP extensions for IdentityModel.OidcClient</Description>
1414
<Authors>Dominick Baier;Brock Allen</Authors>
1515
<PackageIcon>icon.jpg</PackageIcon>
16-
16+
<PackageReadmeFile>README.md</PackageReadmeFile>
1717
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
1818
<GenerateDocumentationFile>true</GenerateDocumentationFile>
1919

@@ -39,14 +39,15 @@
3939

4040
<ItemGroup>
4141
<None Include="../../icon.jpg" Pack="true" Visible="false" PackagePath="" />
42+
<None Include="README.md" Pack="true" PackagePath=""/>
4243
</ItemGroup>
4344

4445
<ItemGroup>
4546
<PackageReference Include="IdentityModel" Version="7.0.0-preview.3" />
4647
<PackageReference Include="minver" Version="4.3.0" PrivateAssets="All" />
4748
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.3.1" />
4849

49-
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" />
50+
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
5051
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
5152
</ItemGroup>
5253

src/DPoP/README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
## About IdentityModel.OidcClient
2+
IdentityModel.OidcClient.DPoP adds support for DPoP ([RFC
3+
9449](https://datatracker.ietf.org/doc/html/rfc9449)) to IdentityModel.OidcClient. DPoP
4+
sender-constrains access and refresh tokens to protect them against replay attacks, and is
5+
often used by mobile and other native applications.
6+
7+
## Related Packages
8+
9+
- Library for claims-based identity, OAuth 2.0, and OpenID Connect: [IdentityModel](https://www.nuget.org/packages/IdentityModel)
10+
- RFC8252 compliant and certified OpenID Connect and OAuth 2.0 client library for native applications: [IdentityModel.OidcClient](https://www.nuget.org/packages/IdentityModel.OidcClient)
11+
- Id token validator for IdentityModel.OidcClient based on the Microsoft JWT handler: [IdentityModel.OidcClient.IdentityTokenValidator](https://www.nuget.org/packages/IdentityModel.OidcClient.IdentityTokenValidator)
12+
- Authentication handler for introspection tokens: [IdentityModel.AspNetCore.OAuth2Introspection](https://www.nuget.org/packages/IdentityModel.AspNetCore.OAuth2Introspection)
13+
14+
## Feedback
15+
16+
IdentityModel.OidcClient is released as open source under the
17+
[Apache 2.0 license](https://github.com/IdentityModel/IdentityModel.OidcClient/blob/main/LICENSE).
18+
Bug reports and contributions are welcome at
19+
[the GitHub repository](https://github.com/IdentityModel/IdentityModel.OidcClient).

src/IdentityTokenValidator/IdentityTokenValidator.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<Authors>Dominick Baier;Brock Allen</Authors>
1212
<PackageIcon>icon.jpg</PackageIcon>
1313
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
14+
<PackageReadmeFile>README.md</PackageReadmeFile>
1415
<GenerateDocumentationFile>true</GenerateDocumentationFile>
1516

1617
<!-- Publish the repository URL in the built .nupkg (in the NuSpec <Repository> element) -->
@@ -34,13 +35,14 @@
3435

3536
<ItemGroup>
3637
<None Include="../../icon.jpg" Pack="true" Visible="false" PackagePath="" />
38+
<None Include="README.md" Pack="true" PackagePath=""/>
3739
</ItemGroup>
3840

3941
<ItemGroup>
4042
<PackageReference Include="minver" Version="4.3.0" PrivateAssets="All" />
4143

4244
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.3.1" />
43-
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" />
45+
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
4446
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
4547
</ItemGroup>
4648

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
## About IdentityModel.OidcClient
2+
IdentityModel.OidcClient.IdentityTokenValidator validates ID tokens using Microsoft's
3+
[System.IdentityModel.Tokens.Jwt](https://www.nuget.org/packages/System.IdentityModel.Tokens.Jwt/)
4+
library. It is intended to be used with
5+
[IdentityModel.OidcClient](https://www.nuget.org/packages/IdentityModel.OidcClient/),
6+
which provides an abstraction for validation of ID tokens that this package implements.
7+
Distributing the ID token validator separately allows for greater control of the version
8+
of the Microsoft JWT handler and prevents certain dependency issues.
9+
10+
## Related Packages
11+
12+
- Library for claims-based identity, OAuth 2.0, and OpenID Connect: [IdentityModel](https://www.nuget.org/packages/IdentityModel)
13+
- RFC8252 compliant and certified OpenID Connect and OAuth 2.0 client library for native applications: [IdentityModel.OidcClient](https://www.nuget.org/packages/IdentityModel.OidcClient)
14+
- Id token validator for IdentityModel.OidcClient based on the Microsoft JWT handler: [IdentityModel.OidcClient.IdentityTokenValidator](https://www.nuget.org/packages/IdentityModel.OidcClient.IdentityTokenValidator)
15+
- Authentication handler for introspection tokens: [IdentityModel.AspNetCore.OAuth2Introspection](https://www.nuget.org/packages/IdentityModel.AspNetCore.OAuth2Introspection)
16+
17+
## Feedback
18+
19+
IdentityModel.OidcClient.IdentityTokenValidator is released as open source under the
20+
[Apache 2.0 license](https://github.com/IdentityModel/IdentityModel.OidcClient/blob/main/LICENSE).
21+
Bug reports and contributions are welcome at
22+
[the GitHub repository](https://github.com/IdentityModel/IdentityModel.OidcClient).

src/OidcClient/AuthorizeClient.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ public async Task<AuthorizeResult> AuthorizeAsync(AuthorizeRequest request,
6262
}
6363

6464
result.Error = browserResult.Error ?? browserResult.ResultType.ToString();
65+
result.ErrorDescription = browserResult.ErrorDescription;
6566
return result;
6667
}
6768

src/OidcClient/CryptoHelper.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ public bool ValidateHash(string data, string hashedData, string signatureAlgorit
5656
using (hashAlgorithm)
5757
{
5858
var hash = hashAlgorithm.ComputeHash(Encoding.ASCII.GetBytes(data));
59-
var size = (hashAlgorithm.HashSize / 8) / 2;
59+
var size = hashAlgorithm.HashSize / 8 / 2; // Only take the left half of the data, as per spec for at_hash
6060

61-
byte[] leftPart = new byte[hashAlgorithm.HashSize / size];
62-
Array.Copy(hash, leftPart, hashAlgorithm.HashSize / size);
61+
byte[] leftPart = new byte[size];
62+
Array.Copy(hash, leftPart, size);
6363

6464
var leftPartB64 = Base64Url.Encode(leftPart);
6565
var match = leftPartB64.Equals(hashedData);

src/OidcClient/OidcClient.csproj

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<PackageId>IdentityModel.OidcClient</PackageId>
54
<RootNamespace>IdentityModel.OidcClient</RootNamespace>
65
<AssemblyName>IdentityModel.OidcClient</AssemblyName>
76

87
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
98
<LangVersion>latest</LangVersion>
109

10+
<PackageId>IdentityModel.OidcClient</PackageId>
1111
<PackageTags>OAuth2;OAuth 2.0;OpenID Connect;Security;Identity;IdentityServer</PackageTags>
1212
<Description>RFC8252 compliant and certified OpenID Connect and OAuth 2.0 client library for native applications</Description>
1313
<Authors>Dominick Baier;Brock Allen</Authors>
1414
<PackageIcon>icon.jpg</PackageIcon>
15-
1615
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
16+
<PackageReadmeFile>README.md</PackageReadmeFile>
17+
1718
<GenerateDocumentationFile>true</GenerateDocumentationFile>
1819

1920
<!-- Publish the repository URL in the built .nupkg (in the NuSpec <Repository> element) -->
@@ -37,13 +38,14 @@
3738

3839
<ItemGroup>
3940
<None Include="../../icon.jpg" Pack="true" Visible="false" PackagePath="" />
40-
</ItemGroup>
41+
<None Include="README.md" Pack="true" PackagePath=""/>
42+
</ItemGroup>
4143

4244
<ItemGroup>
4345
<PackageReference Include="IdentityModel" Version="7.0.0-preview.3" />
4446
<PackageReference Include="minver" Version="4.3.0" PrivateAssets="All" />
4547

46-
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" />
48+
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
4749
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
4850
</ItemGroup>
4951

0 commit comments

Comments
 (0)