├── access-token-management ├── perf │ ├── .gitignore │ ├── Perf.DevServer │ │ ├── appsettings.Development.json │ │ ├── Perf.DevServer.v3.ncrunchproject │ │ ├── appsettings.json │ │ └── Program.cs │ ├── Perf.TokenEndpoint │ │ ├── TokenEndpoint.http │ │ ├── appsettings.Development.json │ │ ├── appsettings.json │ │ ├── Properties │ │ │ └── launchSettings.json │ │ └── Perf.TokenEndpoint.csproj │ ├── Perf.K6 │ │ ├── token.ts │ │ ├── package.json │ │ └── package-lock.json │ └── Perf.IdentityServer │ │ ├── Properties │ │ └── launchSettings.json │ │ ├── appsettings.json │ │ └── Perf.IdentityServer.csproj ├── samples │ ├── Web │ │ ├── Views │ │ │ ├── _ViewStart.cshtml │ │ │ ├── Home │ │ │ │ ├── CallApi.cshtml │ │ │ │ └── Index.cshtml │ │ │ ├── _ViewImports.cshtml │ │ │ └── Shared │ │ │ │ └── _ValidationScriptsPartial.cshtml │ │ ├── appsettings.json │ │ ├── wwwroot │ │ │ ├── favicon.ico │ │ │ ├── js │ │ │ │ └── site.js │ │ │ └── lib │ │ │ │ └── jquery-validation-unobtrusive │ │ │ │ └── LICENSE.txt │ │ ├── Web.v3.ncrunchproject │ │ ├── Properties │ │ │ └── launchSettings.json │ │ ├── Web.csproj │ │ └── TypedClient.cs │ ├── WebJarJwt │ │ ├── Views │ │ │ ├── _ViewStart.cshtml │ │ │ ├── Home │ │ │ │ ├── CallApi.cshtml │ │ │ │ ├── Index.cshtml │ │ │ │ └── Secure.cshtml │ │ │ ├── _ViewImports.cshtml │ │ │ └── Shared │ │ │ │ └── _ValidationScriptsPartial.cshtml │ │ ├── wwwroot │ │ │ ├── favicon.ico │ │ │ ├── js │ │ │ │ └── site.js │ │ │ └── lib │ │ │ │ └── jquery-validation-unobtrusive │ │ │ │ └── LICENSE.txt │ │ ├── WebJarJwt.v3.ncrunchproject │ │ ├── Properties │ │ │ └── launchSettings.json │ │ ├── WebJarJwt.csproj │ │ └── TypedClient.cs │ ├── Directory.Build.props │ ├── BlazorServer │ │ ├── wwwroot │ │ │ ├── favicon.ico │ │ │ └── css │ │ │ │ └── open-iconic │ │ │ │ └── font │ │ │ │ └── fonts │ │ │ │ ├── open-iconic.eot │ │ │ │ ├── open-iconic.otf │ │ │ │ ├── open-iconic.ttf │ │ │ │ └── open-iconic.woff │ │ ├── BlazorServer.v3.ncrunchproject │ │ ├── Shared │ │ │ ├── LoginDisplay.razor │ │ │ ├── MainLayout.razor │ │ │ ├── RedirectToLogin.razor │ │ │ └── SurveyPrompt.razor │ │ ├── Properties │ │ │ └── launchSettings.json │ │ ├── Pages │ │ │ ├── Counter.razor │ │ │ ├── FetchRemoteData.razor │ │ │ ├── Index.razor │ │ │ └── Error.cshtml.cs │ │ ├── _Imports.razor │ │ ├── Data │ │ │ └── WeatherForecast.cs │ │ ├── BlazorServer.csproj │ │ ├── Services │ │ │ ├── WeatherForecastService.cs │ │ │ └── RemoteApiService.cs │ │ └── Plumbing │ │ │ └── AccountController.cs │ ├── Worker │ │ ├── Worker.v3.ncrunchproject │ │ ├── TypedClient.cs │ │ └── Worker.csproj │ ├── WorkerDI │ │ ├── WorkerDI.v3.ncrunchproject │ │ ├── TypedClient.cs │ │ └── WorkerDI.csproj │ └── WorkerWithFusionCache │ │ └── WorkerWithFusionCache.csproj ├── test │ ├── Directory.Build.props │ └── AccessTokenManagement.Tests │ │ ├── Usings.cs │ │ ├── AccessTokenManagement.Tests.v3.ncrunchproject │ │ ├── AccessTokenManagement.Tests.net8.0.v3.ncrunchproject │ │ ├── AccessTokenManagement.Tests.net9.0.v3.ncrunchproject │ │ ├── AccessTokenHandler │ │ └── Helpers │ │ │ └── FakeHttpContextAccessor.cs │ │ ├── Framework │ │ ├── MemoryCacheSystemClock.cs │ │ ├── Token.cs │ │ ├── TestDPoPNonceStore.cs │ │ ├── TestOptionsMonitor.cs │ │ └── TestClientAssertionService.cs │ │ ├── Types │ │ └── AccessTokenTypeTests.cs │ │ ├── DPoPExtensionTests.cs │ │ └── TokenRequestCustomizer │ │ └── HttpResponseMessageExtensions.cs ├── .config │ └── dotnet-tools.json └── src │ ├── AccessTokenManagement │ ├── AccessTokenManagement.v3.ncrunchproject │ ├── GlobalAliasses.cs │ ├── ForceTokenRenewal.cs │ ├── Internal │ │ ├── ValidationRule.cs │ │ ├── NoOpClientAssertionService.cs │ │ ├── DuendeAccessTokenSerializationContext.cs │ │ ├── StringValueJsonConverter.cs │ │ └── Crypto.cs │ ├── HybridCacheConstants.cs │ ├── HttpRequestContext.cs │ ├── HttpRequestContextExtensions.cs │ ├── DPoP │ │ ├── IDPoPKeyStore.cs │ │ ├── DPoPNonceContext.cs │ │ ├── IDPoPNonceStoreKeyGenerator.cs │ │ ├── IDPoPNonceStore.cs │ │ ├── Internal │ │ │ ├── DPoPErrors.cs │ │ │ ├── DPoPNonceStoreKeyGenerator.cs │ │ │ └── DefaultDPoPKeyStore.cs │ │ └── IDPoPProofService.cs │ ├── FailedResult.cs │ ├── IClientCredentialsTokenManager.cs │ ├── OTel │ │ └── ActivitySources.cs │ ├── IClientCredentialsCacheKeyGenerator.cs │ ├── IClientCredentialsTokenEndpoint.cs │ ├── ServiceProviderKeys.cs │ └── IClientAssertionService.cs │ ├── AccessTokenManagement.OpenIdConnect │ ├── AccessTokenManagement.OpenIdConnect.v3.ncrunchproject │ ├── GlobalAliasses.cs │ ├── Internal │ │ ├── TokenNames.cs │ │ ├── CircuitServicesAccessor.cs │ │ ├── ServicesAccessorCircuitHandler.cs │ │ ├── HttpContextUserAccessor.cs │ │ └── CircuitServicesServiceCollectionExtensions.cs │ ├── StringExtensions.cs │ ├── IPrincipalAccessor.cs │ ├── UserRefreshToken.cs │ ├── TransformPrincipalAfterRefreshAsync.cs │ ├── IUserTokenRequestConcurrencyControl.cs │ ├── HttpRequestContextExtensions.cs │ ├── OpenIdConnectTokenManagementDefaults.cs │ ├── IOpenIdConnectConfigurationService.cs │ └── UserTokenRequestParameters.cs │ └── Directory.Build.props ├── identity-model ├── samples │ └── HttpClientFactory │ │ ├── wwwroot │ │ ├── js │ │ │ ├── site.min.js │ │ │ └── site.js │ │ ├── favicon.ico │ │ ├── lib │ │ │ ├── bootstrap │ │ │ │ └── dist │ │ │ │ │ ├── fonts │ │ │ │ │ ├── glyphicons-halflings-regular.eot │ │ │ │ │ ├── glyphicons-halflings-regular.ttf │ │ │ │ │ ├── glyphicons-halflings-regular.woff │ │ │ │ │ └── glyphicons-halflings-regular.woff2 │ │ │ │ │ └── js │ │ │ │ │ └── npm.js │ │ │ ├── jquery-validation-unobtrusive │ │ │ │ ├── .bower.json │ │ │ │ └── LICENSE.txt │ │ │ └── jquery │ │ │ │ └── .bower.json │ │ └── css │ │ │ ├── site.min.css │ │ │ └── site.css │ │ ├── Views │ │ ├── Home │ │ │ └── Index.cshtml │ │ ├── _ViewStart.cshtml │ │ ├── _ViewImports.cshtml │ │ └── Shared │ │ │ └── Error.cshtml │ │ ├── HttpClientFactory.v3.ncrunchproject │ │ ├── appsettings.json │ │ ├── appsettings.Development.json │ │ ├── Models │ │ └── ErrorViewModel.cs │ │ ├── HttpClientFactory.csproj │ │ ├── Program.cs │ │ └── Properties │ │ └── launchSettings.json ├── test │ ├── IdentityModel.Tests │ │ ├── documents │ │ │ ├── failure_token_revocation_response.json │ │ │ ├── success_par_response.json │ │ │ ├── success_userinfo_response.json │ │ │ ├── failure_token_response.json │ │ │ ├── success_ciba_response.json │ │ │ ├── failure_device_authorization_response.json │ │ │ ├── success_access_token_response.json │ │ │ ├── failure_registration_response.json │ │ │ ├── success_token_response.json │ │ │ ├── success_device_authorization_response.json │ │ │ ├── success_introspection_response_no_issuer.json │ │ │ ├── success_introspection_response.json │ │ │ ├── legacy_success_introspection_response.json │ │ │ ├── success_userinfo_response.jwt │ │ │ └── success_introspection_response.jwt │ │ ├── GlobalUsings.cs │ │ ├── IdentityModel.Tests.net481.v3.ncrunchproject │ │ ├── HttpClientExtensions │ │ │ └── HttpRequestMethodExtensions.cs │ │ ├── Infrastructure │ │ │ └── FileName.cs │ │ └── Verifications │ │ │ └── PublicApiVerificationTests.cs │ └── Directory.Build.props ├── src │ ├── TrimmableAnalysis │ │ ├── README.md │ │ ├── Program.cs │ │ └── TrimmableAnalysis.csproj │ ├── Directory.Build.props │ └── IdentityModel │ │ ├── Client │ │ ├── Messages │ │ │ ├── JsonWebKeySetRequest.cs │ │ │ ├── TokenRevocationResponse.cs │ │ │ ├── UserInfoRequest.cs │ │ │ ├── DiscoveryDocumentRequest.cs │ │ │ ├── DeviceAuthorizationRequest.cs │ │ │ ├── TokenRequest.cs │ │ │ ├── DeviceTokenRequest.cs │ │ │ ├── ClientMessagesSourceGenerationContext.cs │ │ │ ├── ParameterReplaceBehavior.cs │ │ │ ├── ClientAssertion.cs │ │ │ ├── TokenRevocationRequest.cs │ │ │ ├── ClientCredentialsTokenRequest.cs │ │ │ ├── DynamicClientRegistrationRequest.cs │ │ │ ├── BackchannelAuthenticationTokenRequest.cs │ │ │ └── ResponseErrorType.cs │ │ ├── ResponseFormat.cs │ │ ├── ClientCredentialStyle.cs │ │ ├── IDiscoveryCache.cs │ │ └── BasicAuthenticationHeaderStyle.cs │ │ ├── Validation │ │ └── ITokenIntrospectionJwtResponseValidator.cs │ │ ├── X509.cs │ │ ├── Jwk │ │ ├── JsonWebAlgorithmsKeyTypes.cs │ │ ├── JwkSourceGenerationContext.cs │ │ └── JwkExtensions.cs │ │ └── Internal │ │ └── AsyncLazy.cs └── .config │ └── dotnet-tools.json ├── icon.png ├── key.snk ├── .github ├── PULL_REQUEST_TEMPLATE.md ├── workflow-gen │ ├── Properties │ │ └── launchSettings.json │ └── workflow-gen.csproj ├── ISSUE_TEMPLATE │ └── config.yml └── workflows │ └── codeql.yml ├── ignore-this ├── README.md ├── test │ ├── Directory.Build.props │ └── IgnoreThis.Tests │ │ ├── Usings.cs │ │ ├── Class1.cs │ │ └── IgnoreThis.Tests.csproj ├── .config │ └── dotnet-tools.json └── src │ ├── Directory.Build.props │ └── IgnoreThis │ └── IgnoreThis.csproj ├── global.json ├── introspection ├── test │ ├── Directory.Build.props │ └── AspNetCore.Authentication.OAuth2Introspection.Tests │ │ ├── AssemblyInfo.cs │ │ ├── AspNetCore.Authentication.OAuth2Introspection.Tests.csproj │ │ └── PublicApiVerification.cs ├── .config │ └── dotnet-tools.json └── src │ ├── Directory.Build.props │ └── AspNetCore.Authentication.OAuth2Introspection │ ├── Infrastructure │ ├── ClaimLite.cs │ ├── DuendeIntrospectionSerializationContext.cs │ └── CacheUtils.cs │ ├── ServiceProviderKeys.cs │ ├── Context │ ├── AuthenticationFailedContext.cs │ ├── TokenValidatedContext.cs │ └── SendingRequestContext.cs │ ├── OAuth2IntrospectionDefaults.cs │ └── AspNetCore.Authentication.OAuth2Introspection.csproj ├── identity-model-oidc-client ├── test │ ├── Directory.Build.props │ └── IdentityModel.OidcClient.Tests │ │ ├── IdentityModel.OidcClient.Tests.net6.0.v3.ncrunchproject │ │ ├── IdentityModel.OidcClient.Tests.net8.0.v3.ncrunchproject │ │ ├── IdentityModel.OidcClient.Tests.net9.0.v3.ncrunchproject │ │ ├── DPoP │ │ └── Framework │ │ │ ├── DPoP │ │ │ ├── DPoPMode.cs │ │ │ ├── DPoPOptions.cs │ │ │ └── IReplayCache.cs │ │ │ └── IntegrationTestBase.cs │ │ ├── TestBrowser.cs │ │ └── DPoPExtensionTests.cs ├── clients │ ├── Directory.Build.props │ ├── ManualModeConsoleClient │ │ ├── ManualModeConsoleClient.v3.ncrunchproject │ │ └── ManualModeConsoleClient.csproj │ ├── ConsoleClientWithBrowser │ │ ├── ConsoleClientWithBrowser.v3.ncrunchproject │ │ └── ConsoleClientWithBrowser.csproj │ └── ConsoleClientWithBrowserAndDPoP │ │ ├── ConsoleClientWithBrowserAndDPoP.v3.ncrunchproject │ │ └── ConsoleClientWithBrowserAndDPoP.csproj ├── samples │ ├── Directory.Build.props │ ├── WindowsConsoleSystemBrowser │ │ ├── WindowsConsoleSystemBrowser │ │ │ ├── callback.bat │ │ │ └── WindowsConsoleSystemBrowser.csproj │ │ └── .vscode │ │ │ ├── tasks.json │ │ │ └── launch.json │ ├── Maui │ │ ├── README.md │ │ └── MauiApp1 │ │ │ └── MauiApp1 │ │ │ ├── Resources │ │ │ ├── Images │ │ │ │ └── dotnet_bot.png │ │ │ ├── Fonts │ │ │ │ ├── OpenSans-Regular.ttf │ │ │ │ └── OpenSans-Semibold.ttf │ │ │ ├── AppIcon │ │ │ │ └── appicon.svg │ │ │ └── Raw │ │ │ │ └── AboutAssets.txt │ │ │ ├── Properties │ │ │ └── launchSettings.json │ │ │ ├── Platforms │ │ │ ├── Android │ │ │ │ ├── Resources │ │ │ │ │ └── values │ │ │ │ │ │ └── colors.xml │ │ │ │ ├── MainApplication.cs │ │ │ │ ├── AndroidManifest.xml │ │ │ │ ├── MainActivity.cs │ │ │ │ └── WebAuthenticationCallbackActivity.cs │ │ │ ├── Windows │ │ │ │ ├── App.xaml │ │ │ │ ├── app.manifest │ │ │ │ └── App.xaml.cs │ │ │ ├── Tizen │ │ │ │ ├── Main.cs │ │ │ │ └── tizen-manifest.xml │ │ │ ├── iOS │ │ │ │ ├── AppDelegate.cs │ │ │ │ └── Program.cs │ │ │ └── MacCatalyst │ │ │ │ ├── AppDelegate.cs │ │ │ │ ├── Program.cs │ │ │ │ └── Entitlements.plist │ │ │ ├── AppShell.xaml.cs │ │ │ ├── App.xaml.cs │ │ │ ├── AppShell.xaml │ │ │ └── App.xaml │ ├── WpfWebView2 │ │ ├── WpfWebView2 │ │ │ ├── App.xaml.cs │ │ │ ├── App.xaml │ │ │ ├── WpfWebView2.csproj │ │ │ ├── AssemblyInfo.cs │ │ │ └── MainWindow.xaml │ │ └── README.md │ ├── WinFormsWebView2 │ │ ├── README.md │ │ └── WinFormsWebView2 │ │ │ ├── Properties │ │ │ └── Settings.settings │ │ │ ├── Program.cs │ │ │ └── App.config │ ├── Wpf │ │ └── Wpf │ │ │ ├── App.xaml │ │ │ ├── Wpf.csproj │ │ │ ├── AssemblyInfo.cs │ │ │ └── DataProtector.cs │ ├── HttpSysConsoleClient │ │ └── HttpSysConsoleClient │ │ │ └── HttpSysConsoleClient.csproj │ └── NetCoreConsoleClient │ │ └── src │ │ └── NetCoreConsoleClient │ │ └── NetCoreConsoleClient.csproj ├── .gitignore ├── src │ ├── TrimmableAnalysis │ │ ├── README.md │ │ ├── Program.cs │ │ ├── TrimmableAnalysis.v3.ncrunchproject │ │ └── TrimmableAnalysis.csproj │ ├── IdentityModel.OidcClient │ │ ├── IdentityModel.OidcClient.net6.0.v3.ncrunchproject │ │ ├── IdentityModel.OidcClient.net8.0.v3.ncrunchproject │ │ ├── IdentityModel.OidcClient.netstandard2.0.v3.ncrunchproject │ │ ├── Results │ │ │ ├── AuthorizeResult.cs │ │ │ ├── TokenResponseValidationResult.cs │ │ │ ├── UserInfoResult.cs │ │ │ └── IdentityTokenValidationResult.cs │ │ ├── Browser │ │ │ ├── DisplayMode.cs │ │ │ ├── IBrowser.cs │ │ │ ├── BrowserResultType.cs │ │ │ └── BrowserResult.cs │ │ ├── AuthorizeRequest.cs │ │ ├── AssemblyAttributes.cs │ │ ├── ResponseValidationResult.cs │ │ ├── SourceGenerationContext.cs │ │ ├── IIdentityTokenValidator.cs │ │ ├── Infrastructure │ │ │ ├── LoggingExtensions.cs │ │ │ ├── StringExtensions.cs │ │ │ └── OidcClientOptionsExtensions.cs │ │ └── LogoutResult.cs │ ├── IdentityModel.OidcClient.Extensions │ │ ├── IdentityModel.OidcClient.Extensions.net6.0.v3.ncrunchproject │ │ ├── IdentityModel.OidcClient.Extensions.net8.0.v3.ncrunchproject │ │ ├── IdentityModel.OidcClient.Extensions.netstandard2.0.v3.ncrunchproject │ │ └── DPoP │ │ │ ├── IDPoPProofTokenFactory.cs │ │ │ ├── DPoPProof.cs │ │ │ └── SourceGenerationContext.cs │ └── Directory.Build.props └── .config │ └── dotnet-tools.json ├── .gitattributes ├── foss.v3.ncrunchsolution ├── foss.slnx.v3.ncrunchsolution ├── samples.props ├── foss.sln.DotSettings └── test.props /access-token-management/perf/.gitignore: -------------------------------------------------------------------------------- 1 | keys/ -------------------------------------------------------------------------------- /identity-model/samples/HttpClientFactory/wwwroot/js/site.min.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuendeSoftware/foss/HEAD/icon.png -------------------------------------------------------------------------------- /key.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuendeSoftware/foss/HEAD/key.snk -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | **What issue does this PR address?** 2 | 3 | 4 | -------------------------------------------------------------------------------- /identity-model/samples/HttpClientFactory/Views/Home/Index.cshtml: -------------------------------------------------------------------------------- 1 |

HttpClientFactory sample

-------------------------------------------------------------------------------- /access-token-management/samples/Web/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "_Layout"; 3 | } 4 | -------------------------------------------------------------------------------- /access-token-management/samples/WebJarJwt/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "_Layout"; 3 | } 4 | -------------------------------------------------------------------------------- /identity-model/samples/HttpClientFactory/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "_Layout"; 3 | } 4 | -------------------------------------------------------------------------------- /access-token-management/samples/Web/Views/Home/CallApi.cshtml: -------------------------------------------------------------------------------- 1 |

API Response

2 | 3 |
@ViewBag.Json
-------------------------------------------------------------------------------- /identity-model/test/IdentityModel.Tests/documents/failure_token_revocation_response.json: -------------------------------------------------------------------------------- 1 | { 2 | "error": "error" 3 | } -------------------------------------------------------------------------------- /access-token-management/samples/WebJarJwt/Views/Home/CallApi.cshtml: -------------------------------------------------------------------------------- 1 |

API Response

2 | 3 |
@ViewBag.Json
-------------------------------------------------------------------------------- /ignore-this/README.md: -------------------------------------------------------------------------------- 1 | # Ignore This 2 | 3 | Ignore this package; it's used internally to test our package publishing process. -------------------------------------------------------------------------------- /access-token-management/samples/Web/Views/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using Web 2 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 3 | -------------------------------------------------------------------------------- /access-token-management/samples/Web/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "BaseUrl": "https://demo.duendesoftware.com", 3 | "UseDPoP": true 4 | } 5 | -------------------------------------------------------------------------------- /access-token-management/samples/WebJarJwt/Views/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using WebJarJwt 2 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 3 | -------------------------------------------------------------------------------- /global.json: -------------------------------------------------------------------------------- 1 | { 2 | "sdk": { 3 | "version": "10.0.100", 4 | "rollForward": "latestMajor", 5 | "allowPrerelease": true 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /identity-model/samples/HttpClientFactory/HttpClientFactory.v3.ncrunchproject: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /identity-model/test/Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /ignore-this/test/Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /introspection/test/Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /access-token-management/test/Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /access-token-management/samples/Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /access-token-management/samples/Web/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuendeSoftware/foss/HEAD/access-token-management/samples/Web/wwwroot/favicon.ico -------------------------------------------------------------------------------- /identity-model-oidc-client/test/Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /identity-model-oidc-client/clients/Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /identity-model-oidc-client/samples/Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /identity-model-oidc-client/samples/WindowsConsoleSystemBrowser/WindowsConsoleSystemBrowser/callback.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | dotnet "%~dp0WindowsConsoleSystemBrowser.dll" %* 3 | -------------------------------------------------------------------------------- /access-token-management/samples/WebJarJwt/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuendeSoftware/foss/HEAD/access-token-management/samples/WebJarJwt/wwwroot/favicon.ico -------------------------------------------------------------------------------- /identity-model/samples/HttpClientFactory/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuendeSoftware/foss/HEAD/identity-model/samples/HttpClientFactory/wwwroot/favicon.ico -------------------------------------------------------------------------------- /identity-model/test/IdentityModel.Tests/documents/success_par_response.json: -------------------------------------------------------------------------------- 1 | { 2 | "expires_in": 600, 3 | "request_uri": "urn:ietf:params:oauth:request_uri:123456" 4 | } -------------------------------------------------------------------------------- /identity-model/test/IdentityModel.Tests/documents/success_userinfo_response.json: -------------------------------------------------------------------------------- 1 | { 2 | "sub": "88421113", 3 | "email": "BobSmith@email.com", 4 | "email_verified": true 5 | } -------------------------------------------------------------------------------- /access-token-management/samples/BlazorServer/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuendeSoftware/foss/HEAD/access-token-management/samples/BlazorServer/wwwroot/favicon.ico -------------------------------------------------------------------------------- /identity-model-oidc-client/.gitignore: -------------------------------------------------------------------------------- 1 | # Files we create in some of the clients and samples 2 | # (real implementations would use secure OS storage) 3 | proofkey 4 | refresh_token 5 | -------------------------------------------------------------------------------- /identity-model/test/IdentityModel.Tests/documents/failure_token_response.json: -------------------------------------------------------------------------------- 1 | { 2 | "error": "error", 3 | "error_description": "error_description", 4 | "custom": "custom" 5 | } -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.verified.txt text eol=lf working-tree-encoding=UTF-8 2 | *.verified.xml text eol=lf working-tree-encoding=UTF-8 3 | *.verified.json text eol=lf working-tree-encoding=UTF-8 -------------------------------------------------------------------------------- /identity-model/samples/HttpClientFactory/Views/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using WebApplication1 2 | @using WebApplication1.Models 3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 4 | -------------------------------------------------------------------------------- /identity-model/samples/HttpClientFactory/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Warning" 5 | } 6 | }, 7 | "AllowedHosts": "*" 8 | } 9 | -------------------------------------------------------------------------------- /identity-model-oidc-client/samples/Maui/README.md: -------------------------------------------------------------------------------- 1 | ## .NET MAUI Sample 2 | 3 | This sample shows how to use OidcClient in MAUI to build a cross platform app 4 | for both iOS and Android. 5 | -------------------------------------------------------------------------------- /identity-model/test/IdentityModel.Tests/documents/success_ciba_response.json: -------------------------------------------------------------------------------- 1 | { 2 | "auth_req_id": "1c266114-a1be-4252-8ad1-04986c5b9ac1", 3 | "expires_in": 120, 4 | "interval": 2 5 | } -------------------------------------------------------------------------------- /identity-model/test/IdentityModel.Tests/documents/failure_device_authorization_response.json: -------------------------------------------------------------------------------- 1 | { 2 | "error": "error", 3 | "error_description": "error_description", 4 | "custom": "custom" 5 | } -------------------------------------------------------------------------------- /.github/workflow-gen/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "profiles": { 3 | "workflow-gen": { 4 | "commandName": "Project", 5 | "workingDirectory": "$(ProjectDir)" 6 | } 7 | } 8 | } -------------------------------------------------------------------------------- /identity-model/test/IdentityModel.Tests/documents/success_access_token_response.json: -------------------------------------------------------------------------------- 1 | { 2 | "access_token": "access_token", 3 | "expires_in": 3600, 4 | "token_type": "Bearer", 5 | "custom": "custom" 6 | } -------------------------------------------------------------------------------- /access-token-management/perf/Perf.DevServer/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /access-token-management/perf/Perf.TokenEndpoint/TokenEndpoint.http: -------------------------------------------------------------------------------- 1 | @TokenEndpoint_HostAddress = http://localhost:5237 2 | 3 | GET {{TokenEndpoint_HostAddress}}/weatherforecast/ 4 | Accept: application/json 5 | 6 | ### 7 | -------------------------------------------------------------------------------- /identity-model/src/TrimmableAnalysis/README.md: -------------------------------------------------------------------------------- 1 | This project exists to facilitate analysis of trimmable warnings. 2 | 3 | See https://learn.microsoft.com/en-us/dotnet/core/deploying/trimming/prepare-libraries-for-trimming -------------------------------------------------------------------------------- /access-token-management/perf/Perf.TokenEndpoint/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /identity-model-oidc-client/samples/Maui/MauiApp1/MauiApp1/Resources/Images/dotnet_bot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuendeSoftware/foss/HEAD/identity-model-oidc-client/samples/Maui/MauiApp1/MauiApp1/Resources/Images/dotnet_bot.png -------------------------------------------------------------------------------- /identity-model-oidc-client/src/TrimmableAnalysis/README.md: -------------------------------------------------------------------------------- 1 | This project exists to facilitate analysis of trimmable warnings. 2 | 3 | See https://learn.microsoft.com/en-us/dotnet/core/deploying/trimming/prepare-libraries-for-trimming -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | contact_links: 3 | - name: Support Forum 4 | url: https://github.com/DuendeSoftware/community 5 | about: The place for questions, support and feature requests 6 | -------------------------------------------------------------------------------- /access-token-management/perf/Perf.DevServer/Perf.DevServer.v3.ncrunchproject: -------------------------------------------------------------------------------- 1 | 2 | 3 | True 4 | 5 | -------------------------------------------------------------------------------- /identity-model-oidc-client/samples/Maui/MauiApp1/MauiApp1/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "profiles": { 3 | "Windows Machine": { 4 | "commandName": "MsixPackage", 5 | "nativeDebugging": false 6 | } 7 | } 8 | } -------------------------------------------------------------------------------- /identity-model/test/IdentityModel.Tests/documents/failure_registration_response.json: -------------------------------------------------------------------------------- 1 | { 2 | "error": "invalid_redirect_uri", 3 | "error_description": "One or more redirect_uri values are invalid", 4 | "custom": "custom" 5 | } -------------------------------------------------------------------------------- /identity-model-oidc-client/samples/Maui/MauiApp1/MauiApp1/Resources/Fonts/OpenSans-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuendeSoftware/foss/HEAD/identity-model-oidc-client/samples/Maui/MauiApp1/MauiApp1/Resources/Fonts/OpenSans-Regular.ttf -------------------------------------------------------------------------------- /ignore-this/test/IgnoreThis.Tests/Usings.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | global using Xunit; 5 | -------------------------------------------------------------------------------- /access-token-management/samples/BlazorServer/wwwroot/css/open-iconic/font/fonts/open-iconic.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuendeSoftware/foss/HEAD/access-token-management/samples/BlazorServer/wwwroot/css/open-iconic/font/fonts/open-iconic.eot -------------------------------------------------------------------------------- /access-token-management/samples/BlazorServer/wwwroot/css/open-iconic/font/fonts/open-iconic.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuendeSoftware/foss/HEAD/access-token-management/samples/BlazorServer/wwwroot/css/open-iconic/font/fonts/open-iconic.otf -------------------------------------------------------------------------------- /access-token-management/samples/BlazorServer/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuendeSoftware/foss/HEAD/access-token-management/samples/BlazorServer/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf -------------------------------------------------------------------------------- /access-token-management/samples/BlazorServer/wwwroot/css/open-iconic/font/fonts/open-iconic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuendeSoftware/foss/HEAD/access-token-management/samples/BlazorServer/wwwroot/css/open-iconic/font/fonts/open-iconic.woff -------------------------------------------------------------------------------- /identity-model-oidc-client/samples/Maui/MauiApp1/MauiApp1/Resources/Fonts/OpenSans-Semibold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuendeSoftware/foss/HEAD/identity-model-oidc-client/samples/Maui/MauiApp1/MauiApp1/Resources/Fonts/OpenSans-Semibold.ttf -------------------------------------------------------------------------------- /identity-model/test/IdentityModel.Tests/documents/success_token_response.json: -------------------------------------------------------------------------------- 1 | { 2 | "access_token": "access_token", 3 | "expires_in": 3600, 4 | "token_type": "Bearer", 5 | "refresh_token": "refresh_token", 6 | "custom": "custom" 7 | } -------------------------------------------------------------------------------- /access-token-management/perf/Perf.TokenEndpoint/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | }, 8 | "AllowedHosts": "*" 9 | } 10 | -------------------------------------------------------------------------------- /access-token-management/samples/Web/Web.v3.ncrunchproject: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | LostReference 5 | 6 | 7 | -------------------------------------------------------------------------------- /identity-model/samples/HttpClientFactory/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Debug", 5 | "System": "Information", 6 | "Microsoft": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /access-token-management/samples/Worker/Worker.v3.ncrunchproject: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | LostReference 5 | 6 | 7 | -------------------------------------------------------------------------------- /access-token-management/samples/Web/Views/Shared/_ValidationScriptsPartial.cshtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /access-token-management/samples/WebJarJwt/WebJarJwt.v3.ncrunchproject: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | LostReference 5 | 6 | 7 | -------------------------------------------------------------------------------- /access-token-management/samples/WorkerDI/WorkerDI.v3.ncrunchproject: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | LostReference 5 | 6 | 7 | -------------------------------------------------------------------------------- /identity-model/src/TrimmableAnalysis/Program.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | Console.WriteLine("Hello, World!"); 5 | -------------------------------------------------------------------------------- /access-token-management/perf/Perf.DevServer/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning", 6 | "Aspire.Hosting.Dcp": "Warning" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /access-token-management/samples/BlazorServer/BlazorServer.v3.ncrunchproject: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | LostReference 5 | 6 | 7 | -------------------------------------------------------------------------------- /access-token-management/samples/WebJarJwt/Views/Shared/_ValidationScriptsPartial.cshtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /identity-model/samples/HttpClientFactory/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuendeSoftware/foss/HEAD/identity-model/samples/HttpClientFactory/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /identity-model/samples/HttpClientFactory/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuendeSoftware/foss/HEAD/identity-model/samples/HttpClientFactory/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /identity-model/.config/dotnet-tools.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "isRoot": true, 4 | "tools": { 5 | "NuGetKeyVaultSignTool": { 6 | "version": "3.2.3", 7 | "commands": [ 8 | "NuGetKeyVaultSignTool" 9 | ] 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /identity-model/samples/HttpClientFactory/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuendeSoftware/foss/HEAD/identity-model/samples/HttpClientFactory/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /identity-model/samples/HttpClientFactory/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuendeSoftware/foss/HEAD/identity-model/samples/HttpClientFactory/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff2 -------------------------------------------------------------------------------- /ignore-this/.config/dotnet-tools.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "isRoot": true, 4 | "tools": { 5 | "NuGetKeyVaultSignTool": { 6 | "version": "3.2.3", 7 | "commands": [ 8 | "NuGetKeyVaultSignTool" 9 | ] 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /introspection/.config/dotnet-tools.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "isRoot": true, 4 | "tools": { 5 | "NuGetKeyVaultSignTool": { 6 | "version": "3.2.3", 7 | "commands": [ 8 | "NuGetKeyVaultSignTool" 9 | ] 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /identity-model-oidc-client/src/TrimmableAnalysis/Program.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | Console.WriteLine("Hello, World!"); 5 | -------------------------------------------------------------------------------- /identity-model-oidc-client/src/TrimmableAnalysis/TrimmableAnalysis.v3.ncrunchproject: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | LostReference 5 | 6 | 7 | -------------------------------------------------------------------------------- /access-token-management/.config/dotnet-tools.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "isRoot": true, 4 | "tools": { 5 | "NuGetKeyVaultSignTool": { 6 | "version": "3.2.3", 7 | "commands": [ 8 | "NuGetKeyVaultSignTool" 9 | ] 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /access-token-management/src/AccessTokenManagement/AccessTokenManagement.v3.ncrunchproject: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | LostReference 5 | 6 | 7 | -------------------------------------------------------------------------------- /identity-model-oidc-client/.config/dotnet-tools.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "isRoot": true, 4 | "tools": { 5 | "NuGetKeyVaultSignTool": { 6 | "version": "3.1.6", 7 | "commands": [ 8 | "NuGetKeyVaultSignTool" 9 | ] 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /access-token-management/samples/Web/wwwroot/js/site.js: -------------------------------------------------------------------------------- 1 | // Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification 2 | // for details on configuring this project to bundle and minify static web assets. 3 | 4 | // Write your JavaScript code. 5 | -------------------------------------------------------------------------------- /access-token-management/test/AccessTokenManagement.Tests/Usings.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | global using Shouldly; 5 | global using Xunit; 6 | -------------------------------------------------------------------------------- /identity-model-oidc-client/clients/ManualModeConsoleClient/ManualModeConsoleClient.v3.ncrunchproject: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | LostReference 5 | 6 | 7 | -------------------------------------------------------------------------------- /introspection/test/AspNetCore.Authentication.OAuth2Introspection.Tests/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | [assembly: CaptureConsole] 5 | -------------------------------------------------------------------------------- /identity-model-oidc-client/clients/ConsoleClientWithBrowser/ConsoleClientWithBrowser.v3.ncrunchproject: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | LostReference 5 | 6 | 7 | -------------------------------------------------------------------------------- /identity-model-oidc-client/src/IdentityModel.OidcClient/IdentityModel.OidcClient.net6.0.v3.ncrunchproject: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | LostReference 5 | 6 | 7 | -------------------------------------------------------------------------------- /identity-model-oidc-client/src/IdentityModel.OidcClient/IdentityModel.OidcClient.net8.0.v3.ncrunchproject: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | LostReference 5 | 6 | 7 | -------------------------------------------------------------------------------- /identity-model/samples/HttpClientFactory/wwwroot/js/site.js: -------------------------------------------------------------------------------- 1 | // Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification 2 | // for details on configuring this project to bundle and minify static web assets. 3 | 4 | // Write your JavaScript code. 5 | -------------------------------------------------------------------------------- /identity-model/test/IdentityModel.Tests/GlobalUsings.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | global using System.Net; 5 | global using System.Net.Http; 6 | -------------------------------------------------------------------------------- /access-token-management/samples/WebJarJwt/wwwroot/js/site.js: -------------------------------------------------------------------------------- 1 | // Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification 2 | // for details on configuring this project to bundle and minify static web assets. 3 | 4 | // Write your JavaScript code. 5 | -------------------------------------------------------------------------------- /access-token-management/src/AccessTokenManagement/GlobalAliasses.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | global using CT = System.Threading.CancellationToken; 5 | 6 | -------------------------------------------------------------------------------- /identity-model-oidc-client/samples/WpfWebView2/WpfWebView2/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | namespace WpfWebView2 4 | { 5 | /// 6 | /// Interaction logic for App.xaml 7 | /// 8 | public partial class App : Application 9 | { 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /identity-model-oidc-client/src/IdentityModel.OidcClient/IdentityModel.OidcClient.netstandard2.0.v3.ncrunchproject: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | LostReference 5 | 6 | 7 | -------------------------------------------------------------------------------- /access-token-management/perf/Perf.K6/token.ts: -------------------------------------------------------------------------------- 1 | import http from "k6/http"; 2 | 3 | export const options = { 4 | vus: 10, 5 | duration: '30s', 6 | }; 7 | 8 | 9 | export default function() { 10 | let res = http.get("https://localhost:7270/token"); 11 | console.log(res.status); 12 | } -------------------------------------------------------------------------------- /access-token-management/src/AccessTokenManagement.OpenIdConnect/AccessTokenManagement.OpenIdConnect.v3.ncrunchproject: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | LostReference 5 | 6 | 7 | -------------------------------------------------------------------------------- /identity-model-oidc-client/clients/ConsoleClientWithBrowserAndDPoP/ConsoleClientWithBrowserAndDPoP.v3.ncrunchproject: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | LostReference 5 | 6 | 7 | -------------------------------------------------------------------------------- /identity-model-oidc-client/test/IdentityModel.OidcClient.Tests/IdentityModel.OidcClient.Tests.net6.0.v3.ncrunchproject: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | LostReference 5 | 6 | 7 | -------------------------------------------------------------------------------- /foss.v3.ncrunchsolution: -------------------------------------------------------------------------------- 1 | 2 | 3 | True 4 | True 5 | True 6 | True 7 | 8 | -------------------------------------------------------------------------------- /access-token-management/src/AccessTokenManagement.OpenIdConnect/GlobalAliasses.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | global using CT = System.Threading.CancellationToken; 5 | 6 | -------------------------------------------------------------------------------- /foss.slnx.v3.ncrunchsolution: -------------------------------------------------------------------------------- 1 | 2 | 3 | True 4 | True 5 | True 6 | True 7 | 8 | -------------------------------------------------------------------------------- /identity-model-oidc-client/src/IdentityModel.OidcClient.Extensions/IdentityModel.OidcClient.Extensions.net6.0.v3.ncrunchproject: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | LostReference 5 | 6 | 7 | -------------------------------------------------------------------------------- /identity-model-oidc-client/src/IdentityModel.OidcClient.Extensions/IdentityModel.OidcClient.Extensions.net8.0.v3.ncrunchproject: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | LostReference 5 | 6 | 7 | -------------------------------------------------------------------------------- /identity-model-oidc-client/samples/Maui/MauiApp1/MauiApp1/Resources/AppIcon/appicon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /identity-model-oidc-client/src/IdentityModel.OidcClient.Extensions/IdentityModel.OidcClient.Extensions.netstandard2.0.v3.ncrunchproject: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | LostReference 5 | 6 | 7 | -------------------------------------------------------------------------------- /ignore-this/src/Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | it- 8 | 0.1 9 | 10 | 11 | -------------------------------------------------------------------------------- /identity-model-oidc-client/samples/Maui/MauiApp1/MauiApp1/Platforms/Android/Resources/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #512BD4 4 | #2B0B98 5 | #2B0B98 6 | -------------------------------------------------------------------------------- /identity-model/src/Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | im- 8 | 7.0 9 | 10 | 11 | -------------------------------------------------------------------------------- /identity-model-oidc-client/samples/WpfWebView2/README.md: -------------------------------------------------------------------------------- 1 | ## WPF WebView2 Sample 2 | This sample shows how to use Duende.IdentityModel.OidcClient to build a windows desktop 3 | application in WPF. It uses [manual 4 | mode](https://docs.duendesoftware.com/foss/identitymodel.oidcclient/manual/) with an 5 | embedded WebView2 based browser. 6 | -------------------------------------------------------------------------------- /introspection/src/Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | intro- 8 | 6.3 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /access-token-management/test/AccessTokenManagement.Tests/AccessTokenManagement.Tests.v3.ncrunchproject: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | AspNetTestHostCompatibility 5 | LostReference 6 | 7 | 8 | -------------------------------------------------------------------------------- /identity-model-oidc-client/src/Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | imoc- 8 | 6.0 9 | 10 | 11 | -------------------------------------------------------------------------------- /identity-model/samples/HttpClientFactory/wwwroot/css/site.min.css: -------------------------------------------------------------------------------- 1 | body{padding-top:50px;padding-bottom:20px}.body-content{padding-left:15px;padding-right:15px}.carousel-caption p{font-size:20px;line-height:1.4}.carousel-inner .item img[src$=".svg"]{width:100%}#qrCode{margin:15px}@media screen and (max-width:767px){.carousel-caption{display:none}} -------------------------------------------------------------------------------- /access-token-management/samples/BlazorServer/Shared/LoginDisplay.razor: -------------------------------------------------------------------------------- 1 | 2 | 3 | Hello, @context.User.Identity!.Name 4 | Log out 5 | 6 | 7 | Log in 8 | 9 | -------------------------------------------------------------------------------- /access-token-management/test/AccessTokenManagement.Tests/AccessTokenManagement.Tests.net8.0.v3.ncrunchproject: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | AspNetTestHostCompatibility 5 | LostReference 6 | 7 | 8 | -------------------------------------------------------------------------------- /access-token-management/test/AccessTokenManagement.Tests/AccessTokenManagement.Tests.net9.0.v3.ncrunchproject: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | AspNetTestHostCompatibility 5 | LostReference 6 | 7 | 8 | -------------------------------------------------------------------------------- /identity-model-oidc-client/samples/WinFormsWebView2/README.md: -------------------------------------------------------------------------------- 1 | ## WinForms WebView2 Sample 2 | This sample shows how to use Duende.IdentityModel.OidcClient to build a windows desktop 3 | application with WinForms. It uses [manual 4 | mode](https://docs.duendesoftware.com/foss/identitymodel.oidcclient/manual/) with an embedded 5 | WebView2 based browser. 6 | -------------------------------------------------------------------------------- /access-token-management/samples/Web/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "profiles": { 3 | "Web": { 4 | "commandName": "Project", 5 | "launchBrowser": true, 6 | "applicationUrl": "https://localhost:5002", 7 | "environmentVariables": { 8 | "ASPNETCORE_ENVIRONMENT": "Development" 9 | } 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /access-token-management/src/AccessTokenManagement/ForceTokenRenewal.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | namespace Duende.AccessTokenManagement; 5 | 6 | public readonly record struct ForceTokenRenewal(bool Value); 7 | -------------------------------------------------------------------------------- /ignore-this/test/IgnoreThis.Tests/Class1.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | namespace Duende.IgnoreThis; 5 | 6 | public class Class1 7 | { 8 | [Fact] 9 | public void Test1() 10 | { } 11 | } 12 | -------------------------------------------------------------------------------- /identity-model-oidc-client/samples/WinFormsWebView2/WinFormsWebView2/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /identity-model-oidc-client/test/IdentityModel.OidcClient.Tests/IdentityModel.OidcClient.Tests.net8.0.v3.ncrunchproject: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | LostReference 5 | AspNetTestHostCompatibility 6 | 7 | 8 | -------------------------------------------------------------------------------- /identity-model-oidc-client/test/IdentityModel.OidcClient.Tests/IdentityModel.OidcClient.Tests.net9.0.v3.ncrunchproject: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | AspNetTestHostCompatibility 5 | LostReference 6 | 7 | 8 | -------------------------------------------------------------------------------- /access-token-management/perf/Perf.IdentityServer/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "profiles": { 3 | "SelfHost": { 4 | "commandName": "Project", 5 | "launchBrowser": true, 6 | "environmentVariables": { 7 | "ASPNETCORE_ENVIRONMENT": "Development" 8 | }, 9 | "applicationUrl": "https://localhost:5001" 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /access-token-management/samples/WebJarJwt/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "profiles": { 3 | "WebJarJwt": { 4 | "commandName": "Project", 5 | "launchBrowser": true, 6 | "environmentVariables": { 7 | "ASPNETCORE_ENVIRONMENT": "Development" 8 | }, 9 | "applicationUrl": "https://localhost:44302" 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /access-token-management/src/AccessTokenManagement/Internal/ValidationRule.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | namespace Duende.AccessTokenManagement.Internal; 5 | 6 | internal delegate bool ValidationRule(T value, out string message); 7 | -------------------------------------------------------------------------------- /identity-model-oidc-client/samples/Wpf/Wpf/App.xaml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /identity-model/test/IdentityModel.Tests/IdentityModel.Tests.net481.v3.ncrunchproject: -------------------------------------------------------------------------------- 1 | 2 | 3 | True 4 | 5 | CopyReferencedAssembliesToWorkspaceIsOn 6 | 7 | 8 | -------------------------------------------------------------------------------- /identity-model/test/IdentityModel.Tests/documents/success_device_authorization_response.json: -------------------------------------------------------------------------------- 1 | { 2 | "device_code": "GMMhmHCXhWEzkobqIHGG_EnNYYsAkukHspeYUk9E8", 3 | "user_code": "WDJB-MJHT", 4 | "verification_uri": "https://www.example.com/device", 5 | "verification_uri_complete": "https://www.example.com/device?user_code=WDJB-MJHT", 6 | "expires_in": 1800, 7 | "interval": 10 8 | } -------------------------------------------------------------------------------- /ignore-this/test/IgnoreThis.Tests/IgnoreThis.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net8.0;net10.0 4 | Duende.IgnoreThis 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /identity-model-oidc-client/samples/Maui/MauiApp1/MauiApp1/Platforms/Windows/App.xaml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /access-token-management/samples/WebJarJwt/Views/Home/Index.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Home Page"; 3 | } 4 | 5 |

Call API as Client

6 | 7 | Extension method 8 | | 9 | HTTP client factory 10 | | 11 | HTTP client factory (typed) 12 | 13 | 14 | -------------------------------------------------------------------------------- /access-token-management/perf/Perf.K6/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "perf.k6", 3 | "version": "1.0.0", 4 | "main": "index.js", 5 | "scripts": { 6 | "test": "echo \"Error: no test specified\" && exit 1" 7 | }, 8 | "keywords": [], 9 | "author": "", 10 | "license": "ISC", 11 | "type": "commonjs", 12 | "description": "", 13 | "devDependencies": { 14 | "@types/k6": "^0.57.1" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /access-token-management/samples/BlazorServer/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "profiles": { 3 | "BlazorServer": { 4 | "commandName": "Project", 5 | "dotnetRunMessages": true, 6 | "launchBrowser": true, 7 | "applicationUrl": "https://localhost:7242", 8 | "environmentVariables": { 9 | "ASPNETCORE_ENVIRONMENT": "Development" 10 | } 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /identity-model-oidc-client/samples/Maui/MauiApp1/MauiApp1/AppShell.xaml.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | namespace MauiApp1; 5 | 6 | public partial class AppShell : Shell 7 | { 8 | public AppShell() 9 | { 10 | InitializeComponent(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /samples.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | $(NoWarn);1591;NU1507 5 | latest 6 | false 7 | true 8 | enable 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /identity-model-oidc-client/src/IdentityModel.OidcClient.Extensions/DPoP/IDPoPProofTokenFactory.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | namespace Duende.IdentityModel.OidcClient.DPoP; 5 | 6 | public interface IDPoPProofTokenFactory 7 | { 8 | DPoPProof CreateProofToken(DPoPProofRequest request); 9 | } 10 | -------------------------------------------------------------------------------- /identity-model/src/IdentityModel/Client/Messages/JsonWebKeySetRequest.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | namespace Duende.IdentityModel.Client; 5 | 6 | /// 7 | /// Request for JSON web key set document 8 | /// 9 | public class JsonWebKeySetRequest : ProtocolRequest 10 | { } 11 | -------------------------------------------------------------------------------- /identity-model/test/IdentityModel.Tests/documents/success_introspection_response_no_issuer.json: -------------------------------------------------------------------------------- 1 | { 2 | "aud": [ "https://idsvr/resources", "api1" ], 3 | "nbf": 1475824871, 4 | "exp": 1475828471, 5 | "client_id": "client", 6 | "sub": "1", 7 | "auth_time": 1475824871, 8 | "idp": "local", 9 | "amr": "password", 10 | "active": true, 11 | "scope": "api1 api2", 12 | "realm_access": { "roles": [ "my_authorization" ] } 13 | } 14 | -------------------------------------------------------------------------------- /access-token-management/perf/Perf.IdentityServer/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Serilog": { 3 | "MinimumLevel": { 4 | "Default": "Debug", 5 | "Override": { 6 | "Microsoft": "Warning", 7 | "Microsoft.Hosting.Lifetime": "Information", 8 | "Microsoft.AspNetCore.Authentication": "Debug", 9 | "System": "Warning" 10 | } 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /identity-model/samples/HttpClientFactory/Models/ErrorViewModel.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | namespace WebApplication1.Models; 5 | 6 | public class ErrorViewModel 7 | { 8 | public string RequestId { get; set; } 9 | 10 | public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); 11 | } 12 | -------------------------------------------------------------------------------- /access-token-management/samples/BlazorServer/Pages/Counter.razor: -------------------------------------------------------------------------------- 1 | @page "/counter" 2 | 3 | Counter 4 | 5 |

Counter

6 | 7 |

Current count: @currentCount

8 | 9 | 10 | 11 | @code { 12 | private int currentCount = 0; 13 | 14 | private void IncrementCount() 15 | { 16 | currentCount++; 17 | } 18 | 19 | } -------------------------------------------------------------------------------- /identity-model-oidc-client/samples/Maui/MauiApp1/MauiApp1/App.xaml.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | namespace MauiApp1; 5 | 6 | public partial class App : Application 7 | { 8 | public App() 9 | { 10 | InitializeComponent(); 11 | 12 | MainPage = new AppShell(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /access-token-management/src/Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | atm- 8 | 3.0 9 | OAuth 2.0;OpenID Connect;Security;BFF;IdentityServer;ASP.NET Core;SPA;Blazor;Token Management 10 | 11 | 12 | -------------------------------------------------------------------------------- /identity-model-oidc-client/samples/WpfWebView2/WpfWebView2/App.xaml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /identity-model/test/IdentityModel.Tests/documents/success_introspection_response.json: -------------------------------------------------------------------------------- 1 | { 2 | "aud": [ "https://idsvr/resources", "api1" ], 3 | "iss": "https://idsvr", 4 | "nbf": 1475824871, 5 | "exp": 1475828471, 6 | "client_id": "client", 7 | "sub": "1", 8 | "auth_time": 1475824871, 9 | "idp": "local", 10 | "amr": "password", 11 | "active": true, 12 | "scope": "api1 api2", 13 | "realm_access": { "roles": [ "my_authorization" ] } 14 | } 15 | -------------------------------------------------------------------------------- /identity-model-oidc-client/samples/Maui/MauiApp1/MauiApp1/Platforms/Tizen/Main.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Maui; 2 | using Microsoft.Maui.Hosting; 3 | using System; 4 | 5 | namespace MauiApp1; 6 | 7 | internal class Program : MauiApplication 8 | { 9 | protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); 10 | 11 | static void Main(string[] args) 12 | { 13 | var app = new Program(); 14 | app.Run(args); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /access-token-management/samples/BlazorServer/Shared/MainLayout.razor: -------------------------------------------------------------------------------- 1 | @inherits LayoutComponentBase 2 | 3 | BlazorServer 4 | 5 |
6 | 9 | 10 |
11 |
12 | 13 |
14 | 15 |
16 | @Body 17 |
18 |
19 |
-------------------------------------------------------------------------------- /identity-model-oidc-client/src/IdentityModel.OidcClient/Results/AuthorizeResult.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | namespace Duende.IdentityModel.OidcClient.Results; 5 | 6 | internal class AuthorizeResult : Result 7 | { 8 | public virtual string Data { get; set; } 9 | public virtual AuthorizeState State { get; set; } 10 | } 11 | -------------------------------------------------------------------------------- /identity-model/test/IdentityModel.Tests/documents/legacy_success_introspection_response.json: -------------------------------------------------------------------------------- 1 | { 2 | "aud": [ "https://idsvr/resources", "api1" ], 3 | "iss": "https://idsvr", 4 | "nbf": 1475824871, 5 | "exp": 1475828471, 6 | "client_id": "client", 7 | "sub": "1", 8 | "auth_time": 1475824871, 9 | "idp": "local", 10 | "amr": "password", 11 | "active": true, 12 | "scope": [ "api1", "api2" ], 13 | "realm_access": { "roles": [ "my_authorization" ] } 14 | } 15 | -------------------------------------------------------------------------------- /identity-model/samples/HttpClientFactory/HttpClientFactory.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net10.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /identity-model/test/IdentityModel.Tests/documents/success_userinfo_response.jwt: -------------------------------------------------------------------------------- 1 | eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwczovL2lkZW50aXR5LmV4YW1wbGUuY29tIiwiYXVkIjoiaHR0cHM6Ly9hcHAuZXhhbXBsZS5jb20iLCJzdWIiOiIyNDgyODk3NjEwMDEiLCJuYW1lIjoiSmFuZSBEb2UiLCJnaXZlbl9uYW1lIjoiSmFuZSIsImZhbWlseV9uYW1lIjoiRG9lIiwicHJlZmVycmVkX3VzZXJuYW1lIjoiai5kb2UiLCJlbWFpbCI6ImphbmVkb2VAZXhhbXBsZS5jb20iLCJwaWN0dXJlIjoiaHR0cDovL2V4YW1wbGUuY29tL2phbmVkb2UvbWUuanBnIn0.WmamfT6SSfVrJ6iBqPprRvbjKlQpd_8OcjLSbKbfMTQ -------------------------------------------------------------------------------- /identity-model-oidc-client/samples/Maui/MauiApp1/MauiApp1/Platforms/iOS/AppDelegate.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | using Foundation; 5 | 6 | namespace MauiApp1; 7 | [Register("AppDelegate")] 8 | public class AppDelegate : MauiUIApplicationDelegate 9 | { 10 | protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); 11 | } 12 | -------------------------------------------------------------------------------- /foss.sln.DotSettings: -------------------------------------------------------------------------------- 1 | 2 | True 3 | True -------------------------------------------------------------------------------- /identity-model-oidc-client/samples/Maui/MauiApp1/MauiApp1/Platforms/MacCatalyst/AppDelegate.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | using Foundation; 5 | 6 | namespace MauiApp1; 7 | [Register("AppDelegate")] 8 | public class AppDelegate : MauiUIApplicationDelegate 9 | { 10 | protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); 11 | } 12 | -------------------------------------------------------------------------------- /identity-model/src/IdentityModel/Client/Messages/TokenRevocationResponse.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | namespace Duende.IdentityModel.Client; 5 | 6 | /// 7 | /// Models an OAuth 2.0 token revocation response 8 | /// 9 | /// 10 | public class TokenRevocationResponse : ProtocolResponse 11 | { } 12 | -------------------------------------------------------------------------------- /access-token-management/samples/Worker/TypedClient.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | namespace WorkerService; 5 | 6 | public class TypedClient 7 | { 8 | private readonly HttpClient _client; 9 | 10 | public TypedClient(HttpClient client) => _client = client; 11 | 12 | public async Task CallApi() => await _client.GetStringAsync("test"); 13 | } 14 | -------------------------------------------------------------------------------- /access-token-management/samples/WorkerDI/TypedClient.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | namespace WorkerService; 5 | 6 | public class TypedClient 7 | { 8 | private readonly HttpClient _client; 9 | 10 | public TypedClient(HttpClient client) => _client = client; 11 | 12 | public async Task CallApi() => await _client.GetStringAsync("test"); 13 | } 14 | -------------------------------------------------------------------------------- /identity-model-oidc-client/samples/HttpSysConsoleClient/HttpSysConsoleClient/HttpSysConsoleClient.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net9.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /identity-model-oidc-client/clients/ManualModeConsoleClient/ManualModeConsoleClient.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net10.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /identity-model-oidc-client/samples/WpfWebView2/WpfWebView2/WpfWebView2.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | WinExe 5 | net9.0-windows 6 | true 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /access-token-management/samples/Web/Web.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net10.0 5 | enable 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /access-token-management/test/AccessTokenManagement.Tests/AccessTokenHandler/Helpers/FakeHttpContextAccessor.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | using Microsoft.AspNetCore.Http; 5 | 6 | namespace Duende.AccessTokenManagement.AccessTokenHandler.Helpers; 7 | 8 | internal class FakeHttpContextAccessor : IHttpContextAccessor 9 | { 10 | public HttpContext? HttpContext { get; set; } 11 | } 12 | -------------------------------------------------------------------------------- /access-token-management/test/AccessTokenManagement.Tests/Framework/MemoryCacheSystemClock.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | using Microsoft.Extensions.Internal; 5 | 6 | namespace Duende.AccessTokenManagement.Framework; 7 | 8 | internal class MemoryCacheSystemClock(TimeProvider timeProvider) : ISystemClock 9 | { 10 | public DateTimeOffset UtcNow => timeProvider.GetUtcNow(); 11 | } 12 | -------------------------------------------------------------------------------- /access-token-management/src/AccessTokenManagement.OpenIdConnect/Internal/TokenNames.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | namespace Duende.AccessTokenManagement.OpenIdConnect.Internal; 5 | 6 | record TokenNames( 7 | string Token, 8 | string TokenType, 9 | string DPoPKey, 10 | string Expires, 11 | string RefreshToken, 12 | string IdentityToken, 13 | string ClientId); 14 | -------------------------------------------------------------------------------- /access-token-management/test/AccessTokenManagement.Tests/Framework/Token.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | namespace Duende.AccessTokenManagement.Framework; 5 | 6 | public record Token 7 | { 8 | public string? access_token { get; init; } 9 | public string? token_type { get; init; } 10 | public string? scope { get; init; } 11 | public int? expires_in { get; init; } 12 | } 13 | -------------------------------------------------------------------------------- /access-token-management/samples/BlazorServer/_Imports.razor: -------------------------------------------------------------------------------- 1 | @using System.Net.Http 2 | @using Microsoft.AspNetCore.Authorization 3 | @using Microsoft.AspNetCore.Components.Authorization 4 | @using Microsoft.AspNetCore.Components.Forms 5 | @using Microsoft.AspNetCore.Components.Routing 6 | @using Microsoft.AspNetCore.Components.Web 7 | @using Microsoft.AspNetCore.Components.Web.Virtualization 8 | @using Microsoft.JSInterop 9 | @using BlazorServer 10 | @using BlazorServer.Shared 11 | @using static Microsoft.AspNetCore.Components.Web.RenderMode -------------------------------------------------------------------------------- /access-token-management/samples/WebJarJwt/WebJarJwt.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net10.0 5 | enable 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /introspection/src/AspNetCore.Authentication.OAuth2Introspection/Infrastructure/ClaimLite.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | #pragma warning disable 1591 5 | 6 | namespace Duende.AspNetCore.Authentication.OAuth2Introspection.Infrastructure; 7 | 8 | public class ClaimLite 9 | { 10 | public required string Type { get; init; } 11 | 12 | public required string Value { get; init; } 13 | } 14 | -------------------------------------------------------------------------------- /access-token-management/samples/BlazorServer/Data/WeatherForecast.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | namespace BlazorServer.Services; 5 | 6 | public class WeatherForecast 7 | { 8 | public DateTime Date { get; set; } 9 | 10 | public int TemperatureC { get; set; } 11 | 12 | public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); 13 | 14 | public string? Summary { get; set; } 15 | } 16 | -------------------------------------------------------------------------------- /identity-model-oidc-client/samples/Wpf/Wpf/Wpf.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | WinExe 5 | net9.0-windows 6 | true 7 | enable 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /ignore-this/src/IgnoreThis/IgnoreThis.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net8.0;net10.0 4 | enable 5 | true 6 | Duende.IgnoreThis 7 | $(PackageId) 8 | $(PackageId) 9 | Automatic access token management for OAuth client credential flows 10 | 11 | 12 | -------------------------------------------------------------------------------- /identity-model-oidc-client/samples/Maui/MauiApp1/MauiApp1/AppShell.xaml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /identity-model-oidc-client/src/IdentityModel.OidcClient.Extensions/DPoP/DPoPProof.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | namespace Duende.IdentityModel.OidcClient.DPoP; 5 | 6 | /// 7 | /// Models a DPoP proof token 8 | /// 9 | public class DPoPProof 10 | { 11 | /// 12 | /// The proof token 13 | /// 14 | public string ProofToken { get; set; } = default!; 15 | } 16 | -------------------------------------------------------------------------------- /introspection/src/AspNetCore.Authentication.OAuth2Introspection/Infrastructure/DuendeIntrospectionSerializationContext.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | using System.Text.Json.Serialization; 5 | 6 | namespace Duende.AspNetCore.Authentication.OAuth2Introspection.Infrastructure; 7 | 8 | [JsonSerializable(typeof(IEnumerable))] 9 | internal partial class DuendeIntrospectionSerializationContext : JsonSerializerContext; 10 | -------------------------------------------------------------------------------- /access-token-management/samples/BlazorServer/Shared/RedirectToLogin.razor: -------------------------------------------------------------------------------- 1 | @inject NavigationManager Navigation 2 | 3 | @code { 4 | // Using the async method prevents NavigationExceptions, even though this method is synchronous 5 | #pragma warning disable CS1998 6 | protected override async Task OnInitializedAsync() 7 | { 8 | var returnUrl = Uri.EscapeDataString("/" + Navigation.ToBaseRelativePath(Navigation.Uri)); 9 | Navigation.NavigateTo($"account/login?returnUrl={returnUrl}", forceLoad: true); 10 | } 11 | #pragma warning restore CS1998 12 | } -------------------------------------------------------------------------------- /access-token-management/samples/WorkerDI/WorkerDI.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net10.0 4 | enable 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /access-token-management/src/AccessTokenManagement/HybridCacheConstants.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | namespace Duende.AccessTokenManagement; 5 | 6 | public static class HybridCacheConstants 7 | { 8 | /// 9 | /// This is one of the tags that's added to all cache entries created by the access token management library. 10 | /// 11 | public const string CacheTag = "Duende.AccessTokenManagement"; 12 | } 13 | -------------------------------------------------------------------------------- /identity-model-oidc-client/samples/WindowsConsoleSystemBrowser/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "build", 6 | "type": "process", 7 | "command": "dotnet", 8 | "args": [ 9 | "build", 10 | "${workspaceFolder}/WindowsConsoleSystemBrowser", 11 | "/property:GenerateFullPaths=true", 12 | "/consoleloggerparameters:NoSummary" 13 | ], 14 | "problemMatcher": "$msCompile" 15 | }, 16 | ] 17 | } -------------------------------------------------------------------------------- /identity-model-oidc-client/src/IdentityModel.OidcClient/Browser/DisplayMode.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | namespace Duende.IdentityModel.OidcClient.Browser; 5 | 6 | /// 7 | /// Browser display mode 8 | /// 9 | public enum DisplayMode 10 | { 11 | /// 12 | /// visible 13 | /// 14 | Visible, 15 | /// 16 | /// hidden 17 | /// 18 | Hidden 19 | } 20 | -------------------------------------------------------------------------------- /identity-model-oidc-client/samples/WinFormsWebView2/WinFormsWebView2/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows.Forms; 3 | 4 | namespace WinFormsWebView2 5 | { 6 | static class Program 7 | { 8 | /// 9 | /// The main entry point for the application. 10 | /// 11 | [STAThread] 12 | static void Main() 13 | { 14 | Application.EnableVisualStyles(); 15 | Application.SetCompatibleTextRenderingDefault(false); 16 | Application.Run(new Form1()); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /access-token-management/perf/Perf.IdentityServer/Perf.IdentityServer.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net10.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /access-token-management/test/AccessTokenManagement.Tests/Types/AccessTokenTypeTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | namespace Duende.AccessTokenManagement.Types; 5 | 6 | public class AccessTokenTypeTests 7 | { 8 | [Fact] 9 | public void Can_change_to_scheme() 10 | { 11 | var type = AccessTokenType.Parse("dpop"); 12 | var sceme1 = Scheme.Parse("dpop"); 13 | 14 | var scheme = type.ToScheme(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /identity-model/samples/HttpClientFactory/wwwroot/lib/bootstrap/dist/js/npm.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated via the `commonjs` Grunt task. You can require() this file in a CommonJS environment. 2 | require('../../js/transition.js') 3 | require('../../js/alert.js') 4 | require('../../js/button.js') 5 | require('../../js/carousel.js') 6 | require('../../js/collapse.js') 7 | require('../../js/dropdown.js') 8 | require('../../js/modal.js') 9 | require('../../js/tooltip.js') 10 | require('../../js/popover.js') 11 | require('../../js/scrollspy.js') 12 | require('../../js/tab.js') 13 | require('../../js/affix.js') -------------------------------------------------------------------------------- /access-token-management/src/AccessTokenManagement.OpenIdConnect/StringExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | using System.Diagnostics; 5 | using System.Diagnostics.CodeAnalysis; 6 | 7 | namespace Duende.AccessTokenManagement.OpenIdConnect; 8 | 9 | internal static class StringExtensions 10 | { 11 | [DebuggerStepThrough] 12 | public static bool IsMissing([NotNullWhen(false)] this string? value) => string.IsNullOrWhiteSpace(value); 13 | 14 | 15 | } 16 | -------------------------------------------------------------------------------- /identity-model/samples/HttpClientFactory/wwwroot/lib/jquery-validation-unobtrusive/.bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jquery-validation-unobtrusive", 3 | "homepage": "https://github.com/aspnet/jquery-validation-unobtrusive", 4 | "version": "3.2.9", 5 | "_release": "3.2.9", 6 | "_resolution": { 7 | "type": "version", 8 | "tag": "v3.2.9", 9 | "commit": "a91f5401898e125f10771c5f5f0909d8c4c82396" 10 | }, 11 | "_source": "https://github.com/aspnet/jquery-validation-unobtrusive.git", 12 | "_target": "^3.2.9", 13 | "_originalSource": "jquery-validation-unobtrusive", 14 | "_direct": true 15 | } -------------------------------------------------------------------------------- /identity-model-oidc-client/test/IdentityModel.OidcClient.Tests/DPoP/Framework/DPoP/DPoPMode.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | namespace Duende.IdentityModel.OidcClient.DPoP.Framework.DPoP; 5 | 6 | public enum DPoPMode 7 | { 8 | /// 9 | /// Only DPoP tokens will be accepted 10 | /// 11 | DPoPOnly, 12 | /// 13 | /// Both DPoP and Bearer tokens will be accepted 14 | /// 15 | DPoPAndBearer 16 | } 17 | -------------------------------------------------------------------------------- /identity-model/src/IdentityModel/Client/Messages/UserInfoRequest.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | namespace Duende.IdentityModel.Client; 5 | 6 | /// 7 | /// Request for OIDC userinfo 8 | /// 9 | public class UserInfoRequest : ProtocolRequest 10 | { 11 | /// 12 | /// Gets or sets the token. 13 | /// 14 | /// 15 | /// The token. 16 | /// 17 | public string? Token { get; set; } 18 | } 19 | -------------------------------------------------------------------------------- /identity-model/test/IdentityModel.Tests/HttpClientExtensions/HttpRequestMethodExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | namespace Duende.IdentityModel.HttpClientExtensions; 5 | 6 | internal static class HttpRequestMethodExtensions 7 | { 8 | public static IDictionary GetProperties(this HttpRequestMessage requestMessage) => 9 | #if NETFRAMEWORK 10 | requestMessage.Properties; 11 | #else 12 | requestMessage.Options; 13 | #endif 14 | 15 | } 16 | -------------------------------------------------------------------------------- /identity-model-oidc-client/src/IdentityModel.OidcClient/AuthorizeRequest.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | using Duende.IdentityModel.Client; 5 | using Duende.IdentityModel.OidcClient.Browser; 6 | 7 | namespace Duende.IdentityModel.OidcClient; 8 | 9 | class AuthorizeRequest 10 | { 11 | public DisplayMode DisplayMode { get; set; } = DisplayMode.Visible; 12 | public int Timeout { get; set; } = 300; 13 | 14 | public Parameters ExtraParameters = new Parameters(); 15 | } 16 | -------------------------------------------------------------------------------- /identity-model/src/IdentityModel/Validation/ITokenIntrospectionJwtResponseValidator.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | namespace Duende.IdentityModel.Validation; 5 | 6 | public interface ITokenIntrospectionJwtResponseValidator 7 | { 8 | /// 9 | /// Perform additional validation on the introspection response. 10 | /// 11 | /// The raw token introspection response. 12 | void Validate(string rawJwtResponse); 13 | } 14 | -------------------------------------------------------------------------------- /identity-model/src/IdentityModel/X509.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | using System.Security.Cryptography.X509Certificates; 5 | 6 | #pragma warning disable 1591 7 | 8 | namespace Duende.IdentityModel; 9 | 10 | public static class X509 11 | { 12 | public static X509CertificatesLocation CurrentUser => new X509CertificatesLocation(StoreLocation.CurrentUser); 13 | public static X509CertificatesLocation LocalMachine => new X509CertificatesLocation(StoreLocation.LocalMachine); 14 | } 15 | -------------------------------------------------------------------------------- /introspection/src/AspNetCore.Authentication.OAuth2Introspection/ServiceProviderKeys.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | namespace Duende.AspNetCore.Authentication.OAuth2Introspection; 5 | 6 | public static class ServiceProviderKeys 7 | { 8 | /// 9 | /// Key for the introspection cache. Use this to inject a different cache implementation into the introspection handler. 10 | /// 11 | public const string IntrospectionCache = "IntrospectionCache"; 12 | } 13 | -------------------------------------------------------------------------------- /access-token-management/samples/BlazorServer/Shared/SurveyPrompt.razor: -------------------------------------------------------------------------------- 1 |
2 | 3 | @Title 4 | 5 | 6 | Please take our 7 | brief survey 8 | 9 | and tell us what you think. 10 |
11 | 12 | @code { 13 | // Demonstrates how a parent component can supply parameters 14 | [Parameter] 15 | public string? Title { get; set; } 16 | 17 | } -------------------------------------------------------------------------------- /identity-model/samples/HttpClientFactory/Program.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | using Microsoft.AspNetCore; 5 | using Microsoft.AspNetCore.Hosting; 6 | 7 | namespace WebApplication1; 8 | 9 | public class Program 10 | { 11 | public static void Main(string[] args) => CreateWebHostBuilder(args).Build().Run(); 12 | 13 | public static IWebHostBuilder CreateWebHostBuilder(string[] args) => 14 | WebHost.CreateDefaultBuilder(args) 15 | .UseStartup(); 16 | } 17 | -------------------------------------------------------------------------------- /.github/workflow-gen/workflow-gen.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net10.0 6 | workflow_gen 7 | enable 8 | enable 9 | false 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /identity-model/test/IdentityModel.Tests/Infrastructure/FileName.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | using System.Runtime.CompilerServices; 5 | 6 | namespace Duende.IdentityModel.Infrastructure; 7 | 8 | internal static class FileName 9 | { 10 | public static string Create(string name) => Path.Combine(UnitTestsPath(), "documents", name); 11 | 12 | private static string UnitTestsPath([CallerFilePath] string path = "") => Path.GetFullPath(Path.Combine(Path.GetDirectoryName(path), "..")); 13 | } 14 | -------------------------------------------------------------------------------- /access-token-management/src/AccessTokenManagement.OpenIdConnect/IPrincipalAccessor.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | using System.Security.Claims; 5 | 6 | namespace Duende.AccessTokenManagement.OpenIdConnect; 7 | 8 | /// 9 | /// Service that retrieves the current principal. 10 | /// 11 | public interface IUserAccessor 12 | { 13 | /// 14 | /// Gets the current user. 15 | /// 16 | Task GetCurrentUserAsync(CT ct = default); 17 | } 18 | -------------------------------------------------------------------------------- /access-token-management/src/AccessTokenManagement/HttpRequestContext.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | namespace Duende.AccessTokenManagement; 5 | 6 | /// 7 | /// Represents a slim version of an HTTP request 8 | /// 9 | public record struct HttpRequestContext 10 | { 11 | public required string Method { get; init; } 12 | public required Uri? RequestUri { get; init; } 13 | public required IEnumerable>> Headers { get; init; } 14 | } 15 | -------------------------------------------------------------------------------- /identity-model/src/IdentityModel/Client/ResponseFormat.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | namespace Duende.IdentityModel.Client; 5 | 6 | /// 7 | /// Specifies the format of the token introspection response. 8 | /// 9 | public enum ResponseFormat 10 | { 11 | /// 12 | /// Plain JSON introspection response (default). 13 | /// 14 | Json, 15 | 16 | /// 17 | /// JWT introspection response. 18 | /// 19 | Jwt 20 | } 21 | -------------------------------------------------------------------------------- /access-token-management/src/AccessTokenManagement/HttpRequestContextExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | namespace Duende.AccessTokenManagement; 5 | 6 | internal static class HttpRequestContextExtensions 7 | { 8 | public static HttpRequestContext ToHttpRequestContext(this HttpRequestMessage request) => 9 | new() 10 | { 11 | Method = request.Method.Method, 12 | RequestUri = request.RequestUri, 13 | Headers = request.Headers 14 | }; 15 | } 16 | -------------------------------------------------------------------------------- /identity-model-oidc-client/samples/Maui/MauiApp1/MauiApp1/Platforms/Android/MainApplication.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | using Android.App; 5 | using Android.Runtime; 6 | 7 | namespace MauiApp1; 8 | [Application] 9 | public class MainApplication : MauiApplication 10 | { 11 | public MainApplication(IntPtr handle, JniHandleOwnership ownership) 12 | : base(handle, ownership) 13 | { 14 | } 15 | 16 | protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); 17 | } 18 | -------------------------------------------------------------------------------- /identity-model-oidc-client/samples/WinFormsWebView2/WinFormsWebView2/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /identity-model/src/IdentityModel/Client/ClientCredentialStyle.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | namespace Duende.IdentityModel.Client; 5 | 6 | /// 7 | /// Specifies how the client will transmit client ID and secret 8 | /// 9 | public enum ClientCredentialStyle 10 | { 11 | /// 12 | /// HTTP basic authentication 13 | /// 14 | AuthorizationHeader, 15 | 16 | /// 17 | /// Post values in body 18 | /// 19 | PostBody 20 | }; 21 | -------------------------------------------------------------------------------- /access-token-management/src/AccessTokenManagement/DPoP/IDPoPKeyStore.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | namespace Duende.AccessTokenManagement.DPoP; 5 | 6 | /// 7 | /// Service to access DPoP keys 8 | /// 9 | public interface IDPoPKeyStore 10 | { 11 | /// 12 | /// Gets the DPoP key for the client, or null if none available for the client 13 | /// 14 | Task GetKeyAsync(ClientCredentialsClientName clientName, 15 | CT ct = default); 16 | } 17 | -------------------------------------------------------------------------------- /access-token-management/src/AccessTokenManagement/FailedResult.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | namespace Duende.AccessTokenManagement; 5 | 6 | public sealed record FailedResult(string Error, string? ErrorDescription = null) : TokenResult 7 | { 8 | public override string ToString() 9 | { 10 | var description = string.IsNullOrEmpty(ErrorDescription) ? string.Empty : $" with description {ErrorDescription}"; 11 | return $"Failed to retrieve access token due to {Error}{description}."; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /identity-model-oidc-client/samples/Maui/MauiApp1/MauiApp1/Platforms/Android/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /identity-model/src/IdentityModel/Client/Messages/DiscoveryDocumentRequest.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | namespace Duende.IdentityModel.Client; 5 | 6 | /// 7 | /// Request for OpenID Connect discovery document 8 | /// 9 | public class DiscoveryDocumentRequest : ProtocolRequest 10 | { 11 | /// 12 | /// Gets or sets the policy. 13 | /// 14 | /// 15 | /// The policy. 16 | /// 17 | public DiscoveryPolicy Policy { get; set; } = new(); 18 | } 19 | -------------------------------------------------------------------------------- /identity-model/src/IdentityModel/Client/Messages/DeviceAuthorizationRequest.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | namespace Duende.IdentityModel.Client; 5 | 6 | /// 7 | /// Request for device authorization 8 | /// 9 | public class DeviceAuthorizationRequest : ProtocolRequest 10 | { 11 | /// 12 | /// Space separated list of the requested scopes (optional). 13 | /// 14 | /// 15 | /// The scope. 16 | /// 17 | public string? Scope { get; set; } 18 | } 19 | -------------------------------------------------------------------------------- /identity-model-oidc-client/samples/Maui/MauiApp1/MauiApp1/Platforms/iOS/Program.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | using ObjCRuntime; 5 | using UIKit; 6 | 7 | namespace MauiApp1; 8 | public class Program 9 | { 10 | // This is the main entry point of the application. 11 | static void Main(string[] args) 12 | { 13 | // if you want to use a different Application Delegate class from "AppDelegate" 14 | // you can specify it here. 15 | UIApplication.Main(args, null, typeof(AppDelegate)); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /identity-model/src/IdentityModel/Client/Messages/TokenRequest.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | namespace Duende.IdentityModel.Client; 5 | 6 | /// 7 | /// Request for token 8 | /// 9 | /// 10 | public class TokenRequest : ProtocolRequest 11 | { 12 | /// 13 | /// Gets or sets the type of the grant. 14 | /// 15 | /// 16 | /// The type of the grant. 17 | /// 18 | public string GrantType { get; set; } = default!; 19 | } 20 | -------------------------------------------------------------------------------- /identity-model-oidc-client/samples/Maui/MauiApp1/MauiApp1/Platforms/MacCatalyst/Program.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | using ObjCRuntime; 5 | using UIKit; 6 | 7 | namespace MauiApp1; 8 | public class Program 9 | { 10 | // This is the main entry point of the application. 11 | static void Main(string[] args) 12 | { 13 | // if you want to use a different Application Delegate class from "AppDelegate" 14 | // you can specify it here. 15 | UIApplication.Main(args, null, typeof(AppDelegate)); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /identity-model-oidc-client/samples/Wpf/Wpf/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | [assembly: ThemeInfo( 4 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located 5 | //(used if a resource is not found in the page, 6 | // or application resource dictionaries) 7 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located 8 | //(used if a resource is not found in the page, 9 | // app, or any theme specific resource dictionaries) 10 | )] 11 | -------------------------------------------------------------------------------- /identity-model-oidc-client/src/IdentityModel.OidcClient/AssemblyAttributes.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | using System.Runtime.CompilerServices; 5 | 6 | [assembly: InternalsVisibleTo("IdentityModel.OidcClient.Tests, PublicKey = 00240000048000009400000006020000002400005253413100040000010001002f25809ad9fde9869a3ae4558b897c8a23458393921395b9439e03d6a52afadbf6ff65ef1049cd2ee4ca5501976ad45b453dc3780b8fa7eb39bae755163ef92d53403a0da484b79d24de1bb759eedceb1e13416c734d9c48b226fcd26c18e0a525b68cdba9f2395502d7df5a6d45c2478edd52752511e2924ea209f83aaa23a1")] 7 | -------------------------------------------------------------------------------- /identity-model-oidc-client/samples/Maui/MauiApp1/MauiApp1/Platforms/Android/MainActivity.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | using Android.App; 5 | using Android.Content.PM; 6 | using Android.OS; 7 | 8 | namespace MauiApp1; 9 | [Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)] 10 | public class MainActivity : MauiAppCompatActivity 11 | { 12 | } 13 | -------------------------------------------------------------------------------- /access-token-management/src/AccessTokenManagement.OpenIdConnect/UserRefreshToken.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | 5 | using Duende.AccessTokenManagement.DPoP; 6 | 7 | namespace Duende.AccessTokenManagement.OpenIdConnect; 8 | 9 | /// 10 | /// A record that captures the information to refresh an access token for a user. 11 | /// 12 | /// Minimally, you need a refresh token. If you use dpop, you'll also need the dpop proof key 13 | /// 14 | public sealed record UserRefreshToken(RefreshToken RefreshToken, DPoPProofKey? DPoPProofKey); 15 | -------------------------------------------------------------------------------- /identity-model-oidc-client/samples/WpfWebView2/WpfWebView2/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | [assembly: ThemeInfo( 4 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located 5 | //(used if a resource is not found in the page, 6 | // or application resource dictionaries) 7 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located 8 | //(used if a resource is not found in the page, 9 | // app, or any theme specific resource dictionaries) 10 | )] 11 | -------------------------------------------------------------------------------- /access-token-management/samples/Web/wwwroot/lib/jquery-validation-unobtrusive/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) .NET Foundation. All rights reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use 4 | these files except in compliance with the License. You may obtain a copy of the 5 | License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software distributed 10 | under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 11 | CONDITIONS OF ANY KIND, either express or implied. See the License for the 12 | specific language governing permissions and limitations under the License. 13 | -------------------------------------------------------------------------------- /identity-model-oidc-client/src/IdentityModel.OidcClient/Results/TokenResponseValidationResult.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | namespace Duende.IdentityModel.OidcClient.Results; 5 | 6 | internal class TokenResponseValidationResult : Result 7 | { 8 | public TokenResponseValidationResult(string error) => Error = error; 9 | 10 | public TokenResponseValidationResult(IdentityTokenValidationResult result) => IdentityTokenValidationResult = result; 11 | 12 | public virtual IdentityTokenValidationResult IdentityTokenValidationResult { get; set; } 13 | } 14 | -------------------------------------------------------------------------------- /identity-model/src/IdentityModel/Jwk/JsonWebAlgorithmsKeyTypes.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | namespace Duende.IdentityModel.Jwk; 5 | 6 | /// 7 | /// Constants for JsonWebAlgorithms "kty" Key Type (sec 6.1) 8 | /// http://tools.ietf.org/html/rfc7518#section-6.1 9 | /// 10 | public static class JsonWebAlgorithmsKeyTypes 11 | { 12 | #pragma warning disable 1591 13 | public const string EllipticCurve = "EC"; 14 | public const string RSA = "RSA"; 15 | public const string Octet = "oct"; 16 | #pragma warning restore 1591 17 | } 18 | -------------------------------------------------------------------------------- /access-token-management/samples/WebJarJwt/wwwroot/lib/jquery-validation-unobtrusive/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) .NET Foundation. All rights reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use 4 | these files except in compliance with the License. You may obtain a copy of the 5 | License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software distributed 10 | under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 11 | CONDITIONS OF ANY KIND, either express or implied. See the License for the 12 | specific language governing permissions and limitations under the License. 13 | -------------------------------------------------------------------------------- /identity-model/samples/HttpClientFactory/wwwroot/lib/jquery-validation-unobtrusive/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) .NET Foundation. All rights reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use 4 | these files except in compliance with the License. You may obtain a copy of the 5 | License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software distributed 10 | under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 11 | CONDITIONS OF ANY KIND, either express or implied. See the License for the 12 | specific language governing permissions and limitations under the License. 13 | -------------------------------------------------------------------------------- /access-token-management/perf/Perf.K6/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "perf.k6", 3 | "version": "1.0.0", 4 | "lockfileVersion": 3, 5 | "requires": true, 6 | "packages": { 7 | "": { 8 | "name": "perf.k6", 9 | "version": "1.0.0", 10 | "license": "ISC", 11 | "devDependencies": { 12 | "@types/k6": "^0.57.1" 13 | } 14 | }, 15 | "node_modules/@types/k6": { 16 | "version": "0.57.1", 17 | "resolved": "https://registry.npmjs.org/@types/k6/-/k6-0.57.1.tgz", 18 | "integrity": "sha512-S/p2RQAYUBXyYROkR2fgeON/LaxJ0YR+KIlnPQW/TOeLBXD7tX4RfDSWaIecuDTWKblmc6UwANyP0e5QDZPhMw==", 19 | "dev": true, 20 | "license": "MIT" 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /access-token-management/src/AccessTokenManagement/DPoP/DPoPNonceContext.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | namespace Duende.AccessTokenManagement.DPoP; 5 | 6 | /// 7 | /// The context for a DPoP nonce. 8 | /// 9 | public sealed record DPoPNonceContext 10 | { 11 | /// 12 | /// The HTTP URL of the request 13 | /// 14 | public required Uri Url { get; set; } 15 | 16 | /// 17 | /// The HTTP method of the request 18 | /// 19 | public required HttpMethod Method { get; set; } 20 | } 21 | -------------------------------------------------------------------------------- /access-token-management/src/AccessTokenManagement/DPoP/IDPoPNonceStoreKeyGenerator.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | namespace Duende.AccessTokenManagement.DPoP; 5 | 6 | /// 7 | /// The logic to generate a key to store a DPoP nonce in the Cache 8 | /// 9 | public interface IDPoPNonceStoreKeyGenerator 10 | { 11 | /// 12 | /// Method to generate a cache key for a DPoP nonce 13 | /// 14 | /// 15 | /// 16 | string GenerateKey(DPoPNonceContext context); 17 | } 18 | -------------------------------------------------------------------------------- /identity-model-oidc-client/samples/WindowsConsoleSystemBrowser/WindowsConsoleSystemBrowser/WindowsConsoleSystemBrowser.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net9.0-windows 6 | enable 7 | enable 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | PreserveNewest 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /access-token-management/samples/BlazorServer/Pages/FetchRemoteData.razor: -------------------------------------------------------------------------------- 1 | @page "/fetchremotedata" 2 | 3 | Remote API 4 | 5 | @attribute [Authorize] 6 | 7 | @using BlazorServer.Services 8 | @inject RemoteApiService Service 9 | 10 |

Remote API

11 | 12 |

This component demonstrates fetching data from a remote API.

13 | 14 | @if (data == null) 15 | { 16 |

17 | Loading... 18 |

19 | } 20 | else 21 | { 22 |
23 |         @data
24 |     
25 | } 26 | 27 | @code { 28 | private string? data = null; 29 | 30 | protected override async Task OnInitializedAsync() 31 | { 32 | data = await Service.GetData(); 33 | } 34 | } -------------------------------------------------------------------------------- /access-token-management/src/AccessTokenManagement.OpenIdConnect/TransformPrincipalAfterRefreshAsync.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | using System.Security.Claims; 5 | 6 | namespace Duende.AccessTokenManagement.OpenIdConnect; 7 | 8 | /// 9 | /// Allows transforming the principal before re-issuing the authentication session 10 | /// 11 | /// 12 | /// 13 | /// 14 | 15 | public delegate Task TransformPrincipalAfterRefreshAsync(ClaimsPrincipal principal, CT ct); 16 | -------------------------------------------------------------------------------- /identity-model/samples/HttpClientFactory/wwwroot/lib/jquery/.bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jquery", 3 | "main": "dist/jquery.js", 4 | "license": "MIT", 5 | "ignore": [ 6 | "package.json" 7 | ], 8 | "keywords": [ 9 | "jquery", 10 | "javascript", 11 | "browser", 12 | "library" 13 | ], 14 | "homepage": "https://github.com/jquery/jquery-dist", 15 | "version": "3.3.1", 16 | "_release": "3.3.1", 17 | "_resolution": { 18 | "type": "version", 19 | "tag": "3.3.1", 20 | "commit": "9e8ec3d10fad04748176144f108d7355662ae75e" 21 | }, 22 | "_source": "https://github.com/jquery/jquery-dist.git", 23 | "_target": "^3.3.1", 24 | "_originalSource": "jquery", 25 | "_direct": true 26 | } -------------------------------------------------------------------------------- /identity-model/src/IdentityModel/Client/Messages/DeviceTokenRequest.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | namespace Duende.IdentityModel.Client; 5 | 6 | /// 7 | /// Request for token using urn:ietf:params:oauth:grant-type:device_code 8 | /// 9 | /// 10 | public class DeviceTokenRequest : TokenRequest 11 | { 12 | /// 13 | /// Gets or sets the device code. 14 | /// 15 | /// 16 | /// The scope. 17 | /// 18 | public string DeviceCode { get; set; } = default!; 19 | } 20 | -------------------------------------------------------------------------------- /access-token-management/samples/BlazorServer/BlazorServer.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net10.0 5 | enable 6 | enable 7 | aspnet-BlazorServer-AF0F1063-736A-4F96-BAF4-B06CE5D44F0D 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /access-token-management/src/AccessTokenManagement/IClientCredentialsTokenManager.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | namespace Duende.AccessTokenManagement; 5 | 6 | public interface IClientCredentialsTokenManager 7 | { 8 | Task> GetAccessTokenAsync( 9 | ClientCredentialsClientName clientName, 10 | TokenRequestParameters? parameters = null, 11 | CT ct = default); 12 | 13 | Task DeleteAccessTokenAsync(ClientCredentialsClientName clientName, 14 | TokenRequestParameters? parameters = null, 15 | CT ct = default); 16 | } 17 | -------------------------------------------------------------------------------- /access-token-management/test/AccessTokenManagement.Tests/Framework/TestDPoPNonceStore.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | using Duende.AccessTokenManagement.DPoP; 5 | 6 | namespace Duende.AccessTokenManagement.Framework; 7 | 8 | public class TestDPoPNonceStore : IDPoPNonceStore 9 | { 10 | public Task GetNonceAsync(DPoPNonceContext context, CancellationToken cancellationToken = default) 11 | => Task.FromResult(null); 12 | 13 | public Task StoreNonceAsync(DPoPNonceContext context, DPoPNonce nonce, CancellationToken cancellationToken = default) => Task.CompletedTask; 14 | } 15 | -------------------------------------------------------------------------------- /access-token-management/src/AccessTokenManagement/DPoP/IDPoPNonceStore.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | namespace Duende.AccessTokenManagement.DPoP; 5 | 6 | /// 7 | /// Service to keep track of DPoP nonces 8 | /// 9 | public interface IDPoPNonceStore 10 | { 11 | /// 12 | /// Gets the nonce 13 | /// 14 | Task GetNonceAsync(DPoPNonceContext context, CT ct = default); 15 | 16 | /// 17 | /// Stores the nonce 18 | /// 19 | Task StoreNonceAsync(DPoPNonceContext context, DPoPNonce nonce, CT ct = default); 20 | } 21 | -------------------------------------------------------------------------------- /identity-model-oidc-client/src/IdentityModel.OidcClient/Results/UserInfoResult.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | using System.Security.Claims; 5 | 6 | namespace Duende.IdentityModel.OidcClient.Results; 7 | 8 | /// 9 | /// The result of a userinfo request. 10 | /// 11 | /// 12 | public class UserInfoResult : Result 13 | { 14 | /// 15 | /// Gets or sets the claims. 16 | /// 17 | /// 18 | /// The claims. 19 | /// 20 | public virtual IEnumerable Claims { get; internal set; } 21 | } 22 | -------------------------------------------------------------------------------- /access-token-management/samples/Web/Views/Home/Index.cshtml: -------------------------------------------------------------------------------- 1 | @using Microsoft.AspNetCore.Mvc.TagHelpers 2 | @using Microsoft.Extensions.Options 3 | @inject IOptions Options 4 | @{ 5 | ViewData["Title"] = "Home Page"; 6 | } 7 | 8 |

Call API as Client

9 | 10 | @if (!Options.Value.UseDPoP) 11 | { 12 | Extension method 13 | @("|") 14 | } 15 | HTTP client factory 16 | @("|") 17 | HTTP client factory (typed) 18 | @("|") 19 | Use resource indicator 20 | -------------------------------------------------------------------------------- /identity-model-oidc-client/clients/ConsoleClientWithBrowser/ConsoleClientWithBrowser.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net10.0 5 | Exe 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /identity-model-oidc-client/samples/Maui/MauiApp1/MauiApp1/App.xaml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /identity-model/src/IdentityModel/Jwk/JwkSourceGenerationContext.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | using System.Text.Json.Serialization; 5 | 6 | namespace Duende.IdentityModel.Jwk; 7 | 8 | [JsonSourceGenerationOptions( 9 | WriteIndented = false, 10 | PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase, 11 | GenerationMode = JsonSourceGenerationMode.Metadata, 12 | DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull)] 13 | [JsonSerializable(typeof(JsonWebKey))] 14 | [JsonSerializable(typeof(JsonWebKeySet))] 15 | internal partial class JwkSourceGenerationContext : JsonSerializerContext 16 | { 17 | } 18 | -------------------------------------------------------------------------------- /access-token-management/src/AccessTokenManagement/OTel/ActivitySources.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | using System.Diagnostics; 5 | 6 | namespace Duende.AccessTokenManagement.OTel; 7 | 8 | public static class ActivitySources 9 | { 10 | 11 | public static ActivitySource Main = new(ActivitySourceNames.Main); 12 | } 13 | 14 | public static class ActivitySourceNames 15 | { 16 | public static readonly string Main = typeof(ActivitySources).Assembly.GetName().Name!; 17 | } 18 | 19 | public static class ActivityNames 20 | { 21 | public const string AcquiringToken = "Duende.AccessTokenManagement.AcquiringToken"; 22 | } 23 | -------------------------------------------------------------------------------- /access-token-management/test/AccessTokenManagement.Tests/Framework/TestOptionsMonitor.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | using Microsoft.Extensions.Options; 5 | 6 | namespace Duende.AccessTokenManagement.Framework; 7 | 8 | public class TestOptionsMonitor(TOptions? currentValue = null) : IOptionsMonitor 9 | where TOptions : class, new() 10 | { 11 | public TOptions CurrentValue { get; set; } = currentValue ?? new(); 12 | 13 | public TOptions Get(string? name) => CurrentValue; 14 | 15 | public IDisposable? OnChange(Action listener) => throw new NotImplementedException(); 16 | } 17 | -------------------------------------------------------------------------------- /identity-model-oidc-client/clients/ConsoleClientWithBrowserAndDPoP/ConsoleClientWithBrowserAndDPoP.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net9.0 5 | Exe 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /identity-model-oidc-client/samples/Maui/MauiApp1/MauiApp1/Resources/Raw/AboutAssets.txt: -------------------------------------------------------------------------------- 1 | Any raw assets you want to be deployed with your application can be placed in 2 | this directory (and child directories). Deployment of the asset to your application 3 | is automatically handled by the following `MauiAsset` Build Action within your `.csproj`. 4 | 5 | 6 | 7 | These files will be deployed with you package and will be accessible using Essentials: 8 | 9 | async Task LoadMauiAsset() 10 | { 11 | using var stream = await FileSystem.OpenAppPackageFileAsync("AboutAssets.txt"); 12 | using var reader = new StreamReader(stream); 13 | 14 | var contents = reader.ReadToEnd(); 15 | } 16 | -------------------------------------------------------------------------------- /identity-model/src/TrimmableAnalysis/TrimmableAnalysis.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net8.0;net9.0;net10.0 6 | enable 7 | true 8 | false 9 | true 10 | $(NoWarn);NU1507 11 | false 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /identity-model/src/IdentityModel/Client/Messages/ClientMessagesSourceGenerationContext.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | using System.Text.Json.Serialization; 5 | 6 | namespace Duende.IdentityModel.Client; 7 | 8 | [JsonSourceGenerationOptions( 9 | WriteIndented = false, 10 | PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase, 11 | GenerationMode = JsonSourceGenerationMode.Metadata, 12 | DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull)] 13 | [JsonSerializable(typeof(DynamicClientRegistrationDocument))] 14 | internal partial class ClientMessagesSourceGenerationContext : JsonSerializerContext 15 | { 16 | } 17 | -------------------------------------------------------------------------------- /access-token-management/perf/Perf.TokenEndpoint/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json.schemastore.org/launchsettings.json", 3 | "profiles": { 4 | "http": { 5 | "commandName": "Project", 6 | "dotnetRunMessages": true, 7 | "launchBrowser": false, 8 | "applicationUrl": "http://localhost:5237", 9 | "environmentVariables": { 10 | "ASPNETCORE_ENVIRONMENT": "Development" 11 | } 12 | }, 13 | "https": { 14 | "commandName": "Project", 15 | "dotnetRunMessages": true, 16 | "launchBrowser": false, 17 | "applicationUrl": "https://localhost:7270;http://localhost:5237", 18 | "environmentVariables": { 19 | "ASPNETCORE_ENVIRONMENT": "Development" 20 | } 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /identity-model-oidc-client/src/IdentityModel.OidcClient/Browser/IBrowser.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | namespace Duende.IdentityModel.OidcClient.Browser; 5 | 6 | /// 7 | /// Models a browser 8 | /// 9 | public interface IBrowser 10 | { 11 | /// 12 | /// Invokes the browser. 13 | /// 14 | /// The options. 15 | /// A token that can be used to cancel the request 16 | /// 17 | Task InvokeAsync(BrowserOptions options, CancellationToken cancellationToken = default); 18 | } 19 | -------------------------------------------------------------------------------- /identity-model/src/IdentityModel/Client/Messages/ParameterReplaceBehavior.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | namespace Duende.IdentityModel.Client; 5 | 6 | /// 7 | /// Specifies how parameter in the collection get replaced (or not). 8 | /// 9 | public enum ParameterReplaceBehavior 10 | { 11 | /// 12 | /// Allow multiple 13 | /// 14 | None, 15 | 16 | /// 17 | /// Replace a single parameter with the same key 18 | /// 19 | Single, 20 | 21 | /// 22 | /// Replace all parameters with same key 23 | /// 24 | All 25 | } 26 | -------------------------------------------------------------------------------- /access-token-management/src/AccessTokenManagement.OpenIdConnect/IUserTokenRequestConcurrencyControl.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | 5 | 6 | namespace Duende.AccessTokenManagement.OpenIdConnect; 7 | 8 | /// 9 | /// Service to provide synchronization to token endpoint requests 10 | /// 11 | public interface IUserTokenRequestConcurrencyControl 12 | { 13 | /// 14 | /// Method to perform synchronization of work. 15 | /// 16 | public Task> ExecuteWithConcurrencyControlAsync(UserRefreshToken key, Func>> tokenRetriever, CT ct = default); 17 | } 18 | -------------------------------------------------------------------------------- /identity-model-oidc-client/samples/NetCoreConsoleClient/src/NetCoreConsoleClient/NetCoreConsoleClient.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net9.0 5 | NetCoreConsoleClient 6 | Exe 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /identity-model-oidc-client/src/IdentityModel.OidcClient/ResponseValidationResult.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | using System.Security.Claims; 5 | using Duende.IdentityModel.Client; 6 | 7 | namespace Duende.IdentityModel.OidcClient; 8 | 9 | internal class ResponseValidationResult : Result 10 | { 11 | public ResponseValidationResult() 12 | { 13 | 14 | } 15 | 16 | public ResponseValidationResult(string error) => Error = error; 17 | 18 | public virtual AuthorizeResponse AuthorizeResponse { get; set; } 19 | public virtual TokenResponse TokenResponse { get; set; } 20 | public virtual ClaimsPrincipal User { get; set; } 21 | } 22 | -------------------------------------------------------------------------------- /introspection/test/AspNetCore.Authentication.OAuth2Introspection.Tests/AspNetCore.Authentication.OAuth2Introspection.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0;net9.0;net10.0 5 | Duende.AspNetCore.Authentication.OAuth2Introspection 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /access-token-management/src/AccessTokenManagement/DPoP/Internal/DPoPErrors.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | using Duende.IdentityModel; 5 | 6 | namespace Duende.AccessTokenManagement.DPoP; 7 | 8 | internal static class DPoPErrors 9 | { 10 | private static readonly string[] DpopErrors = 11 | [ 12 | OidcConstants.TokenErrors.UseDPoPNonce, 13 | OidcConstants.TokenErrors.InvalidDPoPProof 14 | ]; 15 | 16 | public static bool IsDPoPError(string? message) 17 | { 18 | if (message == null) 19 | { 20 | return false; 21 | } 22 | 23 | return DpopErrors.Contains(message); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /identity-model-oidc-client/test/IdentityModel.OidcClient.Tests/TestBrowser.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | using Duende.IdentityModel.OidcClient.Browser; 5 | 6 | namespace Duende.IdentityModel.OidcClient; 7 | 8 | public class TestBrowser : IBrowser 9 | { 10 | private readonly Func> _browserResultFactory; 11 | 12 | public TestBrowser(Func> browserResultFactory) => _browserResultFactory = browserResultFactory; 13 | 14 | public Task InvokeAsync(BrowserOptions options, CancellationToken cancellationToken) => 15 | _browserResultFactory(options); 16 | } 17 | -------------------------------------------------------------------------------- /access-token-management/src/AccessTokenManagement.OpenIdConnect/Internal/CircuitServicesAccessor.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | namespace Duende.AccessTokenManagement.OpenIdConnect.Internal; 5 | 6 | /// 7 | /// Provides access to scoped blazor services from non-blazor DI scopes, such as 8 | /// scopes created using IHttpClientFactory. 9 | /// 10 | internal class CircuitServicesAccessor 11 | { 12 | static readonly AsyncLocal BlazorServices = new(); 13 | 14 | internal IServiceProvider? Services 15 | { 16 | get => BlazorServices.Value; 17 | set => BlazorServices.Value = value!; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /identity-model-oidc-client/samples/Maui/MauiApp1/MauiApp1/Platforms/MacCatalyst/Entitlements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | com.apple.security.app-sandbox 8 | 9 | 10 | com.apple.security.network.client 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /access-token-management/src/AccessTokenManagement/Internal/NoOpClientAssertionService.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | using Duende.IdentityModel.Client; 5 | 6 | namespace Duende.AccessTokenManagement.Internal; 7 | 8 | /// 9 | /// By default, we don't do client assertions. 10 | /// 11 | internal class NoOpClientAssertionService : IClientAssertionService 12 | { 13 | /// 14 | public Task GetClientAssertionAsync(ClientCredentialsClientName? clientName = null, 15 | TokenRequestParameters? parameters = null, 16 | CT ct = default) => 17 | Task.FromResult(null); 18 | } 19 | -------------------------------------------------------------------------------- /introspection/src/AspNetCore.Authentication.OAuth2Introspection/Infrastructure/CacheUtils.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | namespace Duende.AspNetCore.Authentication.OAuth2Introspection.Infrastructure; 5 | 6 | /// 7 | /// Defines some common cache utilities 8 | /// 9 | public static class CacheUtils 10 | { 11 | /// 12 | /// Generates a cache key based opon input from OAuth2IntrospectionOptions and the token. 13 | /// 14 | /// 15 | public static Func CacheKeyFromToken() => (options, token) => $"{options.CacheKeyPrefix}{token.Sha256()}"; 16 | } 17 | -------------------------------------------------------------------------------- /identity-model-oidc-client/samples/WindowsConsoleSystemBrowser/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": "Debug", 9 | "type": "coreclr", 10 | "request": "launch", 11 | "preLaunchTask": "build", 12 | "program": "${workspaceFolder}/WindowsConsoleSystemBrowser/bin/Debug/net8.0-windows/WindowsConsoleSystemBrowser.dll", 13 | "args": [], 14 | "cwd": "${workspaceFolder}/WindowsConsoleSystemBrowser", 15 | "console": "externalTerminal" 16 | } 17 | ] 18 | } -------------------------------------------------------------------------------- /identity-model-oidc-client/test/IdentityModel.OidcClient.Tests/DPoP/Framework/DPoP/DPoPOptions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | namespace Duende.IdentityModel.OidcClient.DPoP.Framework.DPoP; 5 | 6 | public class DPoPOptions 7 | { 8 | public DPoPMode Mode { get; set; } = DPoPMode.DPoPOnly; 9 | 10 | public TimeSpan ProofTokenValidityDuration { get; set; } = TimeSpan.FromSeconds(1); 11 | public TimeSpan ClientClockSkew { get; set; } = TimeSpan.FromMinutes(0); 12 | public TimeSpan ServerClockSkew { get; set; } = TimeSpan.FromMinutes(5); 13 | 14 | public bool ValidateIat { get; set; } = true; 15 | public bool ValidateNonce { get; set; } = false; 16 | } 17 | -------------------------------------------------------------------------------- /access-token-management/samples/Web/TypedClient.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | namespace Web; 5 | 6 | public abstract class TypedClient 7 | { 8 | private readonly HttpClient _client; 9 | 10 | public TypedClient(HttpClient client) => _client = client; 11 | 12 | public virtual async Task CallApi() => await _client.GetStringAsync("test"); 13 | } 14 | 15 | public class TypedUserClient : TypedClient 16 | { 17 | public TypedUserClient(HttpClient client) : base(client) 18 | { 19 | } 20 | } 21 | 22 | public class TypedClientClient : TypedClient 23 | { 24 | public TypedClientClient(HttpClient client) : base(client) 25 | { 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /access-token-management/samples/WorkerWithFusionCache/WorkerWithFusionCache.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net9.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /identity-model/samples/HttpClientFactory/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:51892", 7 | "sslPort": 44301 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | } 17 | }, 18 | "WebApplication1": { 19 | "commandName": "Project", 20 | "launchBrowser": true, 21 | "applicationUrl": "https://localhost:5001;http://localhost:5000", 22 | "environmentVariables": { 23 | "ASPNETCORE_ENVIRONMENT": "Development" 24 | } 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /access-token-management/perf/Perf.DevServer/Program.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | using Microsoft.Extensions.Hosting; 5 | 6 | var builder = DistributedApplication.CreateBuilder(args); 7 | 8 | var cache = builder.AddRedis("cache") 9 | .WithRedisCommander(); 10 | 11 | var idServer = builder.AddProject(Services.IdentityServer.ToString()); 12 | 13 | var tokenEndpoint = builder.AddProject(Services.TokenEndpoint.ToString()) 14 | .WithReplicas(3) 15 | .WithReference(cache); 16 | ; 17 | 18 | idServer.WithReference(tokenEndpoint); 19 | tokenEndpoint.WithReference(idServer); 20 | 21 | 22 | 23 | builder.Build().Run(); 24 | -------------------------------------------------------------------------------- /access-token-management/samples/WebJarJwt/TypedClient.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | namespace WebJarJwt; 5 | 6 | public abstract class TypedClient 7 | { 8 | private readonly HttpClient _client; 9 | 10 | public TypedClient(HttpClient client) => _client = client; 11 | 12 | public virtual async Task CallApi() => await _client.GetStringAsync("test"); 13 | } 14 | 15 | public class TypedUserClient : TypedClient 16 | { 17 | public TypedUserClient(HttpClient client) : base(client) 18 | { 19 | } 20 | } 21 | 22 | public class TypedClientClient : TypedClient 23 | { 24 | public TypedClientClient(HttpClient client) : base(client) 25 | { 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /access-token-management/src/AccessTokenManagement/Internal/DuendeAccessTokenSerializationContext.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | using System.Text.Json.Serialization; 5 | 6 | namespace Duende.AccessTokenManagement.Internal; 7 | 8 | /// 9 | /// Serialization context used by the DPoP proof service and the client credential token cache. 10 | /// 11 | [JsonSerializable(typeof(HttpMethod))] 12 | [JsonSerializable(typeof(Uri))] 13 | [JsonSerializable(typeof(long))] 14 | [JsonSerializable(typeof(Dictionary))] 15 | [JsonSerializable(typeof(ClientCredentialsToken))] 16 | internal partial class DuendeAccessTokenSerializationContext : JsonSerializerContext; 17 | -------------------------------------------------------------------------------- /identity-model-oidc-client/src/IdentityModel.OidcClient/Results/IdentityTokenValidationResult.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | using System.Security.Claims; 5 | 6 | namespace Duende.IdentityModel.OidcClient.Results; 7 | 8 | /// 9 | /// Identity token validation result 10 | /// 11 | public class IdentityTokenValidationResult : Result 12 | { 13 | /// 14 | /// The user represented by the identity token 15 | /// 16 | public ClaimsPrincipal User { get; set; } 17 | 18 | /// 19 | /// The signature algorithm of the identity token 20 | /// 21 | public string SignatureAlgorithm { get; set; } 22 | } 23 | -------------------------------------------------------------------------------- /identity-model/src/IdentityModel/Client/Messages/ClientAssertion.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | namespace Duende.IdentityModel.Client; 5 | 6 | /// 7 | /// Models a client assertion 8 | /// 9 | public class ClientAssertion 10 | { 11 | /// 12 | /// Gets or sets the assertion type. 13 | /// 14 | /// 15 | /// The type. 16 | /// 17 | public string Type { get; set; } = default!; 18 | 19 | /// 20 | /// Gets or sets the assertion value. 21 | /// 22 | /// 23 | /// The value. 24 | /// 25 | public string Value { get; set; } = default!; 26 | } 27 | -------------------------------------------------------------------------------- /access-token-management/src/AccessTokenManagement.OpenIdConnect/HttpRequestContextExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | using Microsoft.AspNetCore.Http; 5 | using Microsoft.AspNetCore.Http.Extensions; 6 | 7 | namespace Duende.AccessTokenManagement.OpenIdConnect; 8 | 9 | internal static class HttpRequestContextExtensions 10 | { 11 | public static HttpRequestContext ToHttpRequestContext(this HttpRequest request) => 12 | new() 13 | { 14 | Method = request.Method, 15 | RequestUri = new Uri(request.GetEncodedUrl()), 16 | Headers = request.Headers.Select(h => new KeyValuePair>(h.Key, h.Value)) 17 | }; 18 | } 19 | -------------------------------------------------------------------------------- /identity-model/test/IdentityModel.Tests/Verifications/PublicApiVerificationTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | #if NET8_0 5 | using PublicApiGenerator; 6 | namespace Duende.IdentityModel.Verifications; 7 | 8 | public class PublicApiVerificationTests 9 | { 10 | 11 | [Fact] 12 | public async Task VerifyPublicApi() 13 | { 14 | var apiGeneratorOptions = new ApiGeneratorOptions 15 | { 16 | IncludeAssemblyAttributes = false 17 | }; 18 | var publicApi = typeof(JwtClaimTypes).Assembly.GeneratePublicApi(apiGeneratorOptions); 19 | var settings = new VerifySettings(); 20 | await Verify(publicApi, settings); 21 | } 22 | } 23 | #endif 24 | -------------------------------------------------------------------------------- /identity-model-oidc-client/src/IdentityModel.OidcClient.Extensions/DPoP/SourceGenerationContext.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | using System.Text.Json.Serialization; 5 | using Microsoft.IdentityModel.Tokens; 6 | 7 | namespace Duende.IdentityModel.OidcClient.DPoP; 8 | 9 | [JsonSourceGenerationOptions( 10 | WriteIndented = false, 11 | PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase, 12 | GenerationMode = JsonSourceGenerationMode.Metadata, 13 | DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull)] 14 | [JsonSerializable(typeof(JsonWebKey))] 15 | [JsonSerializable(typeof(DPoPProofPayload))] 16 | internal partial class SourceGenerationContext : JsonSerializerContext 17 | { 18 | } 19 | -------------------------------------------------------------------------------- /introspection/test/AspNetCore.Authentication.OAuth2Introspection.Tests/PublicApiVerification.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | using PublicApiGenerator; 5 | 6 | namespace Duende.AspNetCore.Authentication.OAuth2Introspection; 7 | 8 | public class PublicApiVerification 9 | { 10 | [Fact] 11 | public async Task VerifyPublicApi() 12 | { 13 | var apiGeneratorOptions = new ApiGeneratorOptions 14 | { 15 | IncludeAssemblyAttributes = false 16 | }; 17 | var publicApi = typeof(OAuth2IntrospectionHandler).Assembly.GeneratePublicApi(apiGeneratorOptions); 18 | var settings = new VerifySettings(); 19 | await Verify(publicApi, settings); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /access-token-management/samples/Worker/Worker.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net10.0 4 | enable 5 | true 6 | true 7 | true 8 | true 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /identity-model-oidc-client/samples/Maui/MauiApp1/MauiApp1/Platforms/Android/WebAuthenticationCallbackActivity.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | using Android.App; 5 | using Android.Content.PM; 6 | 7 | namespace YourNameSpace; 8 | 9 | [Activity(NoHistory = true, LaunchMode = LaunchMode.SingleTop, Exported = true)] 10 | [IntentFilter(new[] { Android.Content.Intent.ActionView }, 11 | Categories = new[] { Android.Content.Intent.CategoryDefault, Android.Content.Intent.CategoryBrowsable }, 12 | DataScheme = CALLBACK_SCHEME)] 13 | public class WebAuthenticationCallbackActivity : Microsoft.Maui.Authentication.WebAuthenticatorCallbackActivity 14 | { 15 | const string CALLBACK_SCHEME = "myapp"; 16 | 17 | } -------------------------------------------------------------------------------- /identity-model-oidc-client/samples/Maui/MauiApp1/MauiApp1/Platforms/Windows/app.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 11 | true/PM 12 | PerMonitorV2, PerMonitor 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /access-token-management/src/AccessTokenManagement/DPoP/IDPoPProofService.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | namespace Duende.AccessTokenManagement.DPoP; 5 | 6 | /// 7 | /// Service to create DPoP proof tokens 8 | /// 9 | public interface IDPoPProofService 10 | { 11 | /// 12 | /// Serializes a requested model into a . 13 | /// 14 | Task CreateProofTokenAsync(DPoPProofRequest request, 15 | CT ct = default); 16 | 17 | /// 18 | /// Computes the thumbprint of the JSON web key. 19 | /// 20 | DPoPProofThumbprint? GetProofKeyThumbprint(DPoPProofKey dpopProofKey); 21 | } 22 | -------------------------------------------------------------------------------- /identity-model-oidc-client/samples/Maui/MauiApp1/MauiApp1/Platforms/Tizen/tizen-manifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | maui-appicon-placeholder 7 | 8 | 9 | 10 | 11 | http://tizen.org/privilege/internet 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /identity-model-oidc-client/src/IdentityModel.OidcClient/Browser/BrowserResultType.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | namespace Duende.IdentityModel.OidcClient.Browser; 5 | 6 | /// 7 | /// Possible browser results. 8 | /// 9 | public enum BrowserResultType 10 | { 11 | /// 12 | /// success 13 | /// 14 | Success, 15 | /// 16 | /// HTTP error 17 | /// 18 | HttpError, 19 | /// 20 | /// user cancel 21 | /// 22 | UserCancel, 23 | /// 24 | /// timeout 25 | /// 26 | Timeout, 27 | /// 28 | /// unknown error 29 | /// 30 | UnknownError 31 | } 32 | -------------------------------------------------------------------------------- /identity-model-oidc-client/samples/Wpf/Wpf/DataProtector.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Security.Cryptography; 3 | using System.Text; 4 | 5 | namespace Wpf 6 | { 7 | internal static class DataProtector 8 | { 9 | internal static string Protect(string plainText) 10 | { 11 | byte[] encryptedData = ProtectedData.Protect(Encoding.UTF8.GetBytes(plainText), null, DataProtectionScope.CurrentUser); 12 | return Convert.ToBase64String(encryptedData); 13 | } 14 | 15 | internal static string Unprotect(string encryptedText) 16 | { 17 | var encryptedData = Convert.FromBase64String(encryptedText); 18 | var decryptedData = ProtectedData.Unprotect(encryptedData, null, DataProtectionScope.CurrentUser); 19 | return Encoding.UTF8.GetString(decryptedData); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /identity-model-oidc-client/src/IdentityModel.OidcClient/SourceGenerationContext.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | using System.Text.Json; 5 | using System.Text.Json.Serialization; 6 | 7 | namespace Duende.IdentityModel.OidcClient; 8 | 9 | [JsonSourceGenerationOptions( 10 | WriteIndented = false, 11 | PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase, 12 | GenerationMode = JsonSourceGenerationMode.Metadata, 13 | DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull)] 14 | [JsonSerializable(typeof(AuthorizeState))] 15 | [JsonSerializable(typeof(Dictionary))] 16 | [JsonSerializable(typeof(OidcClientOptions))] 17 | internal partial class SourceGenerationContext : JsonSerializerContext 18 | { 19 | } 20 | -------------------------------------------------------------------------------- /access-token-management/samples/BlazorServer/Pages/Index.razor: -------------------------------------------------------------------------------- 1 | @page "/" 2 | @using System.Security.Claims 3 | @inject AuthenticationStateProvider AuthenticationStateProvider 4 | 5 | Index 6 | 7 |

Hello, world!

8 | 9 | @if (User?.Identity?.IsAuthenticated == true) 10 | { 11 |

Welcome, @User.Identity.Name!

12 | } 13 | else 14 | { 15 |

Welcome to our app!

16 |

You are not authenticated.

17 |

Please log in to continue.

18 | } 19 | 20 | 21 | 22 | @code { 23 | private ClaimsPrincipal? User { get; set; } 24 | 25 | protected override async Task OnInitializedAsync() 26 | { 27 | var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); 28 | User = authState.User; 29 | } 30 | } -------------------------------------------------------------------------------- /access-token-management/samples/BlazorServer/Services/WeatherForecastService.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | namespace BlazorServer.Services; 5 | 6 | public class WeatherForecastService 7 | { 8 | private static readonly string[] Summaries = new[] 9 | { 10 | "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" 11 | }; 12 | 13 | public Task GetForecastAsync(DateTime startDate) => Task.FromResult(Enumerable.Range(1, 5).Select(index => new WeatherForecast 14 | { 15 | Date = startDate.AddDays(index), 16 | TemperatureC = Random.Shared.Next(-20, 55), 17 | Summary = Summaries[Random.Shared.Next(Summaries.Length)] 18 | }).ToArray()); 19 | } 20 | -------------------------------------------------------------------------------- /introspection/src/AspNetCore.Authentication.OAuth2Introspection/Context/AuthenticationFailedContext.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | using Microsoft.AspNetCore.Authentication; 5 | using Microsoft.AspNetCore.Http; 6 | 7 | namespace Duende.AspNetCore.Authentication.OAuth2Introspection.Context; 8 | 9 | /// 10 | /// Context for the AuthenticationFailed event 11 | /// 12 | public class AuthenticationFailedContext(HttpContext context, 13 | AuthenticationScheme scheme, 14 | OAuth2IntrospectionOptions options, 15 | string error) 16 | : ResultContext(context, scheme, options) 17 | { 18 | /// 19 | /// The error 20 | /// 21 | public string Error => error; 22 | } 23 | -------------------------------------------------------------------------------- /.github/workflows/codeql.yml: -------------------------------------------------------------------------------- 1 | name: codeql 2 | 3 | on: 4 | schedule: 5 | - cron: '38 15 * * 0' 6 | 7 | jobs: 8 | analyze: 9 | name: Analyze 10 | runs-on: ubuntu-latest 11 | permissions: 12 | actions: read 13 | contents: read 14 | security-events: write 15 | 16 | steps: 17 | - name: Checkout repository 18 | uses: actions/checkout@v4 19 | 20 | - name: Initialize CodeQL 21 | uses: github/codeql-action/init@ea9e4e37992a54ee68a9622e985e60c8e8f12d9f # 3.27.4 22 | with: 23 | languages: csharp 24 | 25 | - name: Auto build 26 | uses: github/codeql-action/autobuild@ea9e4e37992a54ee68a9622e985e60c8e8f12d9f # 3.27.4 27 | 28 | - name: Perform CodeQL analysis 29 | uses: github/codeql-action/analyze@ea9e4e37992a54ee68a9622e985e60c8e8f12d9f # 3.27.4 30 | with: 31 | category: "/language:csharp" 32 | -------------------------------------------------------------------------------- /access-token-management/src/AccessTokenManagement/IClientCredentialsCacheKeyGenerator.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | namespace Duende.AccessTokenManagement; 5 | 6 | /// 7 | /// The logic to generate a cache key. 8 | /// 9 | public interface IClientCredentialsCacheKeyGenerator 10 | { 11 | /// 12 | /// Method to generate a cache key for a client credentials token request 13 | /// 14 | /// The name of the client 15 | /// The parameters 16 | /// 17 | ClientCredentialsCacheKey GenerateKey( 18 | ClientCredentialsClientName clientName, 19 | TokenRequestParameters? parameters = null); 20 | } 21 | -------------------------------------------------------------------------------- /access-token-management/samples/BlazorServer/Services/RemoteApiService.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | using System.Text.Json; 5 | 6 | namespace BlazorServer.Services; 7 | 8 | public class RemoteApiService 9 | { 10 | private readonly HttpClient _client; 11 | 12 | public RemoteApiService(IHttpClientFactory factory) => _client = factory.CreateClient("demoApiClient"); 13 | 14 | private record Claim(string type, object value); 15 | 16 | public async Task GetData() 17 | { 18 | var response = await _client.GetStringAsync("test"); 19 | var json = JsonSerializer.Deserialize>(response); 20 | return JsonSerializer.Serialize(json, new JsonSerializerOptions { WriteIndented = true }); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /identity-model-oidc-client/samples/WpfWebView2/WpfWebView2/MainWindow.xaml: -------------------------------------------------------------------------------- 1 | 9 | 10 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /identity-model-oidc-client/src/IdentityModel.OidcClient/Browser/BrowserResult.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | namespace Duende.IdentityModel.OidcClient.Browser; 5 | 6 | /// 7 | /// The result from a browser login. 8 | /// 9 | /// 10 | public class BrowserResult : Result 11 | { 12 | /// 13 | /// Gets or sets the type of the result. 14 | /// 15 | /// 16 | /// The type of the result. 17 | /// 18 | public BrowserResultType ResultType { get; set; } 19 | 20 | /// 21 | /// Gets or sets the response. 22 | /// 23 | /// 24 | /// The response. 25 | /// 26 | public string Response { get; set; } 27 | } 28 | -------------------------------------------------------------------------------- /access-token-management/perf/Perf.TokenEndpoint/Perf.TokenEndpoint.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net10.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /access-token-management/src/AccessTokenManagement.OpenIdConnect/OpenIdConnectTokenManagementDefaults.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | namespace Duende.AccessTokenManagement.OpenIdConnect; 5 | 6 | /// 7 | /// Default values 8 | /// 9 | public static class OpenIdConnectTokenManagementDefaults 10 | { 11 | /// 12 | /// Prefix to use for registering scheme based client credentials client in options system on the fly 13 | /// 14 | public const string ClientCredentialsClientNamePrefix = "Duende.TokenManagement.SchemeBasedClient:"; 15 | 16 | public static ClientCredentialsClientName ToClientName(this Scheme scheme) => 17 | ClientCredentialsClientName.Parse(ClientCredentialsClientNamePrefix + scheme); 18 | } 19 | -------------------------------------------------------------------------------- /introspection/src/AspNetCore.Authentication.OAuth2Introspection/OAuth2IntrospectionDefaults.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | namespace Duende.AspNetCore.Authentication.OAuth2Introspection; 5 | 6 | /// 7 | /// Defaults for OAuth 2.0 introspection authentication 8 | /// 9 | public class OAuth2IntrospectionDefaults 10 | { 11 | /// 12 | /// The default authentication scheme. 13 | /// 14 | public const string AuthenticationScheme = "Bearer"; 15 | 16 | /// 17 | /// The name of the HttpClient that will be resolved from the HttpClientFactory 18 | /// 19 | public const string BackChannelHttpClientName = "IdentityModel.AspNetCore.OAuth2Introspection.BackChannelHttpClientName"; 20 | } 21 | -------------------------------------------------------------------------------- /identity-model-oidc-client/test/IdentityModel.OidcClient.Tests/DPoPExtensionTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | using Duende.IdentityModel.OidcClient.DPoP; 5 | 6 | namespace Duende.IdentityModel.OidcClient; 7 | 8 | public class DPoPExtensionTests 9 | { 10 | [Theory] 11 | [InlineData("DPoP-Nonce")] 12 | [InlineData("dpop-nonce")] 13 | [InlineData("DPOP-NONCE")] 14 | public void GetDPoPNonceIsCaseInsensitive(string headerName) 15 | { 16 | var expected = "expected-server-nonce"; 17 | var message = new HttpResponseMessage() 18 | { 19 | Headers = 20 | { 21 | { headerName, expected } 22 | } 23 | }; 24 | message.GetDPoPNonce().ShouldBe(expected); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /introspection/src/AspNetCore.Authentication.OAuth2Introspection/Context/TokenValidatedContext.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | using Microsoft.AspNetCore.Authentication; 5 | using Microsoft.AspNetCore.Http; 6 | 7 | namespace Duende.AspNetCore.Authentication.OAuth2Introspection.Context; 8 | 9 | /// 10 | /// Context for the TokenValidated event 11 | /// 12 | public class TokenValidatedContext( 13 | HttpContext context, 14 | AuthenticationScheme scheme, 15 | OAuth2IntrospectionOptions options, 16 | string securityToken) 17 | : ResultContext(context, scheme, options) 18 | { 19 | /// 20 | /// The security token 21 | /// 22 | public string SecurityToken => securityToken; 23 | } 24 | -------------------------------------------------------------------------------- /identity-model-oidc-client/src/IdentityModel.OidcClient/IIdentityTokenValidator.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | using Duende.IdentityModel.OidcClient.Results; 5 | 6 | namespace Duende.IdentityModel.OidcClient; 7 | 8 | /// 9 | /// Models pluggable identity token validation 10 | /// 11 | public interface IIdentityTokenValidator 12 | { 13 | /// 14 | /// Validates an identity token 15 | /// 16 | /// 17 | /// 18 | /// 19 | /// 20 | Task ValidateAsync(string identityToken, OidcClientOptions options, CancellationToken cancellationToken = default); 21 | } 22 | -------------------------------------------------------------------------------- /identity-model-oidc-client/src/IdentityModel.OidcClient/Infrastructure/LoggingExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | using System.Diagnostics; 5 | using System.Security.Claims; 6 | using Microsoft.Extensions.Logging; 7 | 8 | namespace Duende.IdentityModel.OidcClient.Infrastructure; 9 | 10 | internal static class LoggingExtensions 11 | { 12 | [DebuggerStepThrough] 13 | public static void LogClaims(this ILogger logger, IEnumerable claims) 14 | { 15 | foreach (var claim in claims) 16 | { 17 | logger.LogDebug($"Claim: {claim.Type}: {claim.Value}"); 18 | } 19 | } 20 | 21 | [DebuggerStepThrough] 22 | public static void LogClaims(this ILogger logger, ClaimsPrincipal user) => logger.LogClaims(user.Claims); 23 | } 24 | -------------------------------------------------------------------------------- /identity-model/src/IdentityModel/Client/Messages/TokenRevocationRequest.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | namespace Duende.IdentityModel.Client; 5 | 6 | /// 7 | /// Request for OAuth token revocation 8 | /// 9 | /// 10 | public class TokenRevocationRequest : ProtocolRequest 11 | { 12 | /// 13 | /// Gets or sets the token. 14 | /// 15 | /// 16 | /// The token. 17 | /// 18 | public string Token { get; set; } = default!; 19 | 20 | /// 21 | /// Gets or sets the token type hint. 22 | /// 23 | /// 24 | /// The token type hint. 25 | /// 26 | public string TokenTypeHint { get; set; } = default!; 27 | } 28 | -------------------------------------------------------------------------------- /access-token-management/samples/BlazorServer/Pages/Error.cshtml.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | using System.Diagnostics; 5 | using Microsoft.AspNetCore.Mvc; 6 | using Microsoft.AspNetCore.Mvc.RazorPages; 7 | 8 | namespace BlazorServer.Pages; 9 | 10 | [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] 11 | [IgnoreAntiforgeryToken] 12 | public class ErrorModel : PageModel 13 | { 14 | public string? RequestId { get; set; } 15 | 16 | public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); 17 | 18 | private readonly ILogger _logger; 19 | 20 | public ErrorModel(ILogger logger) => _logger = logger; 21 | 22 | public void OnGet() => RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier; 23 | } 24 | -------------------------------------------------------------------------------- /access-token-management/src/AccessTokenManagement/DPoP/Internal/DPoPNonceStoreKeyGenerator.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | using Microsoft.Extensions.Options; 5 | 6 | namespace Duende.AccessTokenManagement.DPoP.Internal; 7 | 8 | /// 9 | /// The logic to generate a key to store a DPoP nonce in the cache. Defaults to 10 | /// + URL + Method. 11 | /// 12 | /// 13 | internal class DPoPNonceStoreKeyGenerator(IOptions options) 14 | : IDPoPNonceStoreKeyGenerator 15 | { 16 | public string GenerateKey(DPoPNonceContext context) => 17 | $"{options.Value.NonceStoreKeyPrefix}:{context.Url}:{context.Method}"; 18 | } 19 | -------------------------------------------------------------------------------- /identity-model-oidc-client/src/IdentityModel.OidcClient/Infrastructure/StringExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | using System.Diagnostics; 5 | 6 | namespace Duende.IdentityModel.OidcClient.Infrastructure; 7 | 8 | internal static class StringExtensions 9 | { 10 | [DebuggerStepThrough] 11 | public static string EnsureTrailingSlash(this string input) 12 | { 13 | if (!input.EndsWith("/")) 14 | { 15 | return input + "/"; 16 | } 17 | 18 | return input; 19 | } 20 | 21 | [DebuggerStepThrough] 22 | public static bool IsMissing(this string value) => string.IsNullOrWhiteSpace(value); 23 | 24 | [DebuggerStepThrough] 25 | public static bool IsPresent(this string value) => !string.IsNullOrWhiteSpace(value); 26 | } 27 | -------------------------------------------------------------------------------- /identity-model/src/IdentityModel/Client/IDiscoveryCache.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | namespace Duende.IdentityModel.Client; 5 | 6 | /// 7 | /// Interface for discovery cache 8 | /// 9 | public interface IDiscoveryCache 10 | { 11 | /// 12 | /// Gets or sets the duration of the cache. 13 | /// 14 | /// 15 | /// The duration of the cache. 16 | /// 17 | TimeSpan CacheDuration { get; set; } 18 | 19 | /// 20 | /// Retrieves the discovery document 21 | /// 22 | /// 23 | Task GetAsync(); 24 | 25 | /// 26 | /// Forces a refresh on the next get. 27 | /// 28 | void Refresh(); 29 | } 30 | -------------------------------------------------------------------------------- /identity-model/src/IdentityModel/Jwk/JwkExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | using System.Buffers.Text; 5 | using System.Text; 6 | using System.Text.Json; 7 | 8 | namespace Duende.IdentityModel.Jwk; 9 | 10 | /// 11 | /// Extensions for JsonWebKey 12 | /// 13 | public static class JsonWebKeyExtensions 14 | { 15 | /// 16 | /// Converts a JSON web key to a URL safe string. 17 | /// 18 | /// The key. 19 | /// 20 | public static string ToJwkString(this JsonWebKey key) 21 | { 22 | var json = JsonSerializer.Serialize(key, JwkSourceGenerationContext.Default.JsonWebKey); 23 | return Base64Url.EncodeToString(Encoding.UTF8.GetBytes(json)); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /access-token-management/src/AccessTokenManagement/IClientCredentialsTokenEndpoint.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | namespace Duende.AccessTokenManagement; 5 | 6 | /// 7 | /// Abstraction for token endpoint operations 8 | /// 9 | public interface IClientCredentialsTokenEndpoint 10 | { 11 | /// 12 | /// Requests a client credentials access token. 13 | /// 14 | /// 15 | /// 16 | /// 17 | /// 18 | Task> RequestAccessTokenAsync( 19 | ClientCredentialsClientName clientName, 20 | TokenRequestParameters? parameters = null, 21 | CT ct = default); 22 | } 23 | -------------------------------------------------------------------------------- /access-token-management/src/AccessTokenManagement.OpenIdConnect/IOpenIdConnectConfigurationService.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | 5 | 6 | namespace Duende.AccessTokenManagement.OpenIdConnect; 7 | 8 | /// 9 | /// Service to extract necessary configuration from an OIDC handler 10 | /// 11 | public interface IOpenIdConnectConfigurationService 12 | { 13 | /// 14 | /// Reads the configuration from either the default challenge scheme or a named scheme 15 | /// 16 | /// 17 | /// 18 | /// 19 | public Task GetOpenIdConnectConfigurationAsync( 20 | Scheme? schemeName = null, 21 | CT ct = default); 22 | } 23 | -------------------------------------------------------------------------------- /access-token-management/src/AccessTokenManagement.OpenIdConnect/Internal/ServicesAccessorCircuitHandler.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | using Microsoft.AspNetCore.Components.Server.Circuits; 5 | 6 | namespace Duende.AccessTokenManagement.OpenIdConnect.Internal; 7 | 8 | internal class ServicesAccessorCircuitHandler( 9 | IServiceProvider services, 10 | CircuitServicesAccessor servicesAccessor) 11 | : CircuitHandler 12 | { 13 | public override Func CreateInboundActivityHandler( 14 | Func next) => 15 | async context => 16 | { 17 | servicesAccessor.Services = services; 18 | await next(context); 19 | servicesAccessor.Services = null; 20 | }; 21 | } 22 | -------------------------------------------------------------------------------- /identity-model-oidc-client/src/TrimmableAnalysis/TrimmableAnalysis.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net8.0;net10.0 6 | enable 7 | true 8 | false 9 | true 10 | false 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /access-token-management/src/AccessTokenManagement/Internal/StringValueJsonConverter.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | using System.Text.Json; 5 | using System.Text.Json.Serialization; 6 | 7 | namespace Duende.AccessTokenManagement.Internal; 8 | 9 | internal class StringValueJsonConverter : JsonConverter where TSelf : struct, IStronglyTypedValue 10 | { 11 | public override TSelf Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) 12 | { 13 | var value = reader.GetString(); 14 | return value == null 15 | ? default 16 | : TSelf.Parse(value); 17 | } 18 | 19 | public override void Write(Utf8JsonWriter writer, TSelf value, JsonSerializerOptions options) => writer.WriteStringValue(value.ToString()); 20 | } 21 | -------------------------------------------------------------------------------- /access-token-management/test/AccessTokenManagement.Tests/DPoPExtensionTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | using Duende.AccessTokenManagement.DPoP; 5 | 6 | namespace Duende.AccessTokenManagement; 7 | 8 | public class DPoPExtensionTests 9 | { 10 | [Theory] 11 | [InlineData("DPoP-Nonce")] 12 | [InlineData("dpop-nonce")] 13 | [InlineData("DPOP-NONCE")] 14 | public void GetDPoPNonceIsCaseInsensitive(string headerName) 15 | { 16 | var expected = "expected-server-nonce"; 17 | var message = new HttpResponseMessage 18 | { 19 | Headers = 20 | { 21 | { headerName, expected } 22 | } 23 | }; 24 | message.GetDPoPNonce().ShouldNotBeNull() 25 | .ToString().ShouldBe(expected); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /identity-model/src/IdentityModel/Client/Messages/ClientCredentialsTokenRequest.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | namespace Duende.IdentityModel.Client; 5 | 6 | /// 7 | /// Request for token using client_credentials 8 | /// 9 | /// 10 | public class ClientCredentialsTokenRequest : TokenRequest 11 | { 12 | /// 13 | /// Space separated list of the requested scopes 14 | /// 15 | /// 16 | /// The scope. 17 | /// 18 | public string? Scope { get; set; } 19 | 20 | /// 21 | /// List of requested resources 22 | /// 23 | /// 24 | /// The scope. 25 | /// 26 | public ICollection Resource { get; set; } = new HashSet(); 27 | } 28 | -------------------------------------------------------------------------------- /access-token-management/src/AccessTokenManagement.OpenIdConnect/UserTokenRequestParameters.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | 5 | 6 | namespace Duende.AccessTokenManagement.OpenIdConnect; 7 | 8 | /// 9 | /// Additional optional per request parameters for a user access token request 10 | /// 11 | public sealed record UserTokenRequestParameters : TokenRequestParameters 12 | { 13 | /// 14 | /// Overrides the default sign-in scheme. This information may be used for state management. 15 | /// 16 | public Scheme? SignInScheme { get; set; } 17 | 18 | /// 19 | /// Overrides the default challenge scheme. This information may be used for deriving token service configuration. 20 | /// 21 | public Scheme? ChallengeScheme { get; set; } 22 | } 23 | -------------------------------------------------------------------------------- /identity-model/src/IdentityModel/Client/Messages/DynamicClientRegistrationRequest.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | namespace Duende.IdentityModel.Client; 5 | 6 | /// 7 | /// Request for dynamic client registration 8 | /// 9 | /// 10 | public class DynamicClientRegistrationRequest : ProtocolRequest 11 | { 12 | /// 13 | /// Gets or sets the token. 14 | /// 15 | /// 16 | /// The token. 17 | /// 18 | public string? Token { get; set; } 19 | 20 | /// 21 | /// Gets or sets the registration request. 22 | /// 23 | /// 24 | /// The registration request. 25 | /// 26 | public DynamicClientRegistrationDocument Document { get; set; } = default!; 27 | } 28 | -------------------------------------------------------------------------------- /access-token-management/src/AccessTokenManagement/ServiceProviderKeys.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | namespace Duende.AccessTokenManagement; 5 | 6 | /// 7 | /// Keys that are used to inject different implementations into a specific service. 8 | /// 9 | public static class ServiceProviderKeys 10 | { 11 | /// 12 | /// Key for the client credentials token cache. Use this to inject a different cache implementation into the client credentials token cache. 13 | /// 14 | public const string ClientCredentialsTokenCache = "ClientCredentialsTokenCache"; 15 | 16 | /// 17 | /// Key for the DPoP nonce store. Use this to inject a different cache into the DPoP nonce store. 18 | /// 19 | public const string DPoPNonceStore = "DPoPNonceStore"; 20 | } 21 | -------------------------------------------------------------------------------- /identity-model/samples/HttpClientFactory/Views/Shared/Error.cshtml: -------------------------------------------------------------------------------- 1 | @model ErrorViewModel 2 | @{ 3 | ViewData["Title"] = "Error"; 4 | } 5 | 6 |

Error.

7 |

An error occurred while processing your request.

8 | 9 | @if (Model.ShowRequestId) 10 | { 11 |

12 | Request ID: @Model.RequestId 13 |

14 | } 15 | 16 |

Development Mode

17 |

18 | Swapping to Development environment will display more detailed information about the error that occurred. 19 |

20 |

21 | Development environment should not be enabled in deployed applications, as it can result in sensitive information from exceptions being displayed to end users. For local debugging, development environment can be enabled by setting the ASPNETCORE_ENVIRONMENT environment variable to Development, and restarting the application. 22 |

23 | -------------------------------------------------------------------------------- /identity-model-oidc-client/test/IdentityModel.OidcClient.Tests/DPoP/Framework/DPoP/IReplayCache.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | namespace Duende.IdentityModel.OidcClient.DPoP.Framework.DPoP; 5 | 6 | public interface IReplayCache 7 | { 8 | /// 9 | /// Adds a handle to the cache 10 | /// 11 | /// 12 | /// 13 | /// 14 | /// 15 | Task AddAsync(string purpose, string handle, DateTimeOffset expiration); 16 | 17 | 18 | /// 19 | /// Checks if a cached handle exists 20 | /// 21 | /// 22 | /// 23 | /// 24 | Task ExistsAsync(string purpose, string handle); 25 | } 26 | -------------------------------------------------------------------------------- /access-token-management/src/AccessTokenManagement/IClientAssertionService.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | using Duende.IdentityModel.Client; 5 | 6 | namespace Duende.AccessTokenManagement; 7 | 8 | /// 9 | /// Service to create client assertions for back-channel clients 10 | /// 11 | public interface IClientAssertionService 12 | { 13 | /// 14 | /// Creates a client assertion based on client or configuration scheme (if present) 15 | /// 16 | /// 17 | /// 18 | /// 19 | /// 20 | Task GetClientAssertionAsync( 21 | ClientCredentialsClientName? clientName = null, 22 | TokenRequestParameters? parameters = null, 23 | CT ct = default); 24 | } 25 | -------------------------------------------------------------------------------- /access-token-management/test/AccessTokenManagement.Tests/TokenRequestCustomizer/HttpResponseMessageExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | using System.IdentityModel.Tokens.Jwt; 5 | using Duende.AccessTokenManagement.Framework; 6 | 7 | namespace Duende.AccessTokenManagement.TokenRequestCustomizer; 8 | 9 | internal static class HttpResponseMessageExtensions 10 | { 11 | internal static JwtSecurityToken ParseTokenFromResponse(this HttpResponseMessage response) 12 | { 13 | var result = response.Content.ReadAsStringAsync().Result; 14 | var tokenResult = System.Text.Json.JsonSerializer.Deserialize(result); 15 | var tokenHandler = new JwtSecurityTokenHandler(); 16 | var token = tokenHandler.ReadJwtToken(tokenResult!.token.Replace("Bearer ", string.Empty)); 17 | return token; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /identity-model-oidc-client/src/IdentityModel.OidcClient/Infrastructure/OidcClientOptionsExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | namespace Duende.IdentityModel.OidcClient.Infrastructure; 5 | 6 | internal static class OidcClientOptionsExtensions 7 | { 8 | public static HttpClient CreateClient(this OidcClientOptions options) 9 | { 10 | if (options.HttpClientFactory != null) 11 | { 12 | return options.HttpClientFactory(options); 13 | } 14 | 15 | HttpClient client; 16 | 17 | if (options.BackchannelHandler != null) 18 | { 19 | client = new HttpClient(options.BackchannelHandler); 20 | } 21 | else 22 | { 23 | client = new HttpClient(); 24 | } 25 | 26 | client.Timeout = options.BackchannelTimeout; 27 | return client; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /identity-model-oidc-client/test/IdentityModel.OidcClient.Tests/DPoP/Framework/IntegrationTestBase.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | namespace Duende.IdentityModel.OidcClient.DPoP.Framework; 5 | 6 | public class IntegrationTestBase : IAsyncLifetime 7 | { 8 | protected readonly IdentityServerHost IdentityServerHost; 9 | protected ApiHost ApiHost; 10 | 11 | public IntegrationTestBase() 12 | { 13 | IdentityServerHost = new IdentityServerHost(); 14 | ApiHost = new ApiHost(IdentityServerHost); 15 | } 16 | 17 | public async ValueTask DisposeAsync() 18 | { 19 | await ApiHost.DisposeAsync(); 20 | await IdentityServerHost.DisposeAsync(); 21 | } 22 | 23 | public async ValueTask InitializeAsync() 24 | { 25 | await ApiHost.InitializeAsync(); 26 | await IdentityServerHost.InitializeAsync(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /identity-model/src/IdentityModel/Client/BasicAuthenticationHeaderStyle.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | namespace Duende.IdentityModel.Client; 5 | 6 | /// 7 | /// Enum for specifying then encoding style of the basic authentication header 8 | /// 9 | public enum BasicAuthenticationHeaderStyle 10 | { 11 | /// 12 | /// Recommended. Uses the encoding as described in the OAuth 2.0 spec (https://tools.ietf.org/html/rfc6749#section-2.3.1). Base64(urlformencode(client_id) + ":" + urlformencode(client_secret)) 13 | /// 14 | Rfc6749, 15 | /// 16 | /// Uses the encoding as described in the original basic authentication spec (https://tools.ietf.org/html/rfc2617#section-2 - used by some non-OAuth 2.0 compliant authorization servers). Base64(client_id + ":" + client_secret). 17 | /// 18 | Rfc2617 19 | } 20 | -------------------------------------------------------------------------------- /identity-model/src/IdentityModel/Client/Messages/BackchannelAuthenticationTokenRequest.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | namespace Duende.IdentityModel.Client; 5 | 6 | /// 7 | /// Request for token using urn:openid:params:grant-type:ciba grant type 8 | /// 9 | /// 10 | public class BackchannelAuthenticationTokenRequest : TokenRequest 11 | { 12 | /// 13 | /// REQUIRED. It is the unique identifier to identify the authentication request (transaction) made by the Client. 14 | /// 15 | public string AuthenticationRequestId { get; set; } = default!; 16 | 17 | /// 18 | /// List of requested resources 19 | /// 20 | /// 21 | /// The resources. 22 | /// 23 | public ICollection Resource { get; set; } = new HashSet(); 24 | } 25 | -------------------------------------------------------------------------------- /identity-model/src/IdentityModel/Internal/AsyncLazy.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | namespace Duende.IdentityModel.Internal; 5 | 6 | internal class AsyncLazy : Lazy> 7 | { 8 | public AsyncLazy(Func> taskFactory) : 9 | base(() => GetTaskAsync(taskFactory).Unwrap()) 10 | { } 11 | 12 | private static async Task> GetTaskAsync(Func> taskFactory) 13 | { 14 | if (TaskHelpers.CanFactoryStartNew) 15 | { 16 | // Runs the task factory in a background thread and retrieves the resulting task. 17 | return Task>.Factory.StartNew(taskFactory).Unwrap(); 18 | } 19 | else 20 | { 21 | // Let the task factory run synchronously in its own context. 22 | await Task.Yield(); 23 | 24 | return taskFactory(); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /access-token-management/src/AccessTokenManagement.OpenIdConnect/Internal/HttpContextUserAccessor.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | using System.Security.Claims; 5 | using Microsoft.AspNetCore.Http; 6 | 7 | namespace Duende.AccessTokenManagement.OpenIdConnect.Internal; 8 | 9 | /// 10 | /// Accesses the current principal based on the HttpContext.User. 11 | /// 12 | internal class HttpContextUserAccessor : IUserAccessor 13 | { 14 | private readonly IHttpContextAccessor _httpContextAccessor; 15 | 16 | /// 17 | /// ctor 18 | /// 19 | public HttpContextUserAccessor(IHttpContextAccessor httpContextAccessor) => _httpContextAccessor = httpContextAccessor; 20 | 21 | /// 22 | public Task GetCurrentUserAsync(CT ct = default) => Task.FromResult(_httpContextAccessor.HttpContext?.User ?? new ClaimsPrincipal()); 23 | } 24 | -------------------------------------------------------------------------------- /access-token-management/test/AccessTokenManagement.Tests/Framework/TestClientAssertionService.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | 5 | using Duende.IdentityModel.Client; 6 | 7 | namespace Duende.AccessTokenManagement.Framework; 8 | 9 | public class TestClientAssertionService(string name, string assertionType, string assertionValue) 10 | : IClientAssertionService 11 | { 12 | public Task GetClientAssertionAsync(ClientCredentialsClientName? clientName = null, TokenRequestParameters? parameters = null, CancellationToken ct = default) 13 | { 14 | if (clientName == name) 15 | { 16 | return Task.FromResult(new() 17 | { 18 | Type = assertionType, 19 | Value = assertionValue 20 | }); 21 | } 22 | 23 | return Task.FromResult(null); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /introspection/src/AspNetCore.Authentication.OAuth2Introspection/AspNetCore.Authentication.OAuth2Introspection.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net8.0;net9.0;net10.0 4 | Duende.AspNetCore.Authentication.OAuth2Introspection 5 | Duende.AspNetCore.Authentication.OAuth2Introspection 6 | Duende.AspNetCore.Authentication.OAuth2Introspection 7 | ASP.NET Core authentication handler for validating tokens using OAuth 2.0 introspection 8 | OAuth2;OAuth 2.0;Introspection;Security;Identity;IdentityServer 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /access-token-management/src/AccessTokenManagement/DPoP/Internal/DefaultDPoPKeyStore.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | using Microsoft.Extensions.Options; 5 | 6 | namespace Duende.AccessTokenManagement.DPoP.Internal; 7 | 8 | /// 9 | /// Default implementation, which reads the dpop key from the client configuration. 10 | /// 11 | internal class DefaultDPoPKeyStore(IOptionsMonitor options) : IDPoPKeyStore 12 | { 13 | /// 14 | public virtual Task GetKeyAsync(ClientCredentialsClientName clientName, 15 | CT ct = default) 16 | { 17 | var client = options.Get(clientName.ToString()); 18 | 19 | 20 | if (client.DPoPJsonWebKey == null) 21 | { 22 | return Task.FromResult(null); 23 | } 24 | 25 | return Task.FromResult(client.DPoPJsonWebKey); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /identity-model/samples/HttpClientFactory/wwwroot/css/site.css: -------------------------------------------------------------------------------- 1 | /* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification\ 2 | for details on configuring this project to bundle and minify static web assets. */ 3 | body { 4 | padding-top: 50px; 5 | padding-bottom: 20px; 6 | } 7 | 8 | /* Wrapping element */ 9 | /* Set some basic padding to keep content from hitting the edges */ 10 | .body-content { 11 | padding-left: 15px; 12 | padding-right: 15px; 13 | } 14 | 15 | /* Carousel */ 16 | .carousel-caption p { 17 | font-size: 20px; 18 | line-height: 1.4; 19 | } 20 | 21 | /* Make .svg files in the carousel display properly in older browsers */ 22 | .carousel-inner .item img[src$=".svg"] { 23 | width: 100%; 24 | } 25 | 26 | /* QR code generator */ 27 | #qrCode { 28 | margin: 15px; 29 | } 30 | 31 | /* Hide/rearrange for smaller screens */ 32 | @media screen and (max-width: 767px) { 33 | /* Hide captions */ 34 | .carousel-caption { 35 | display: none; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /identity-model/test/IdentityModel.Tests/documents/success_introspection_response.jwt: -------------------------------------------------------------------------------- 1 | eyJraWQiOiJ3RzZEIiwidHlwIjoidG9rZW4taW50cm9zcGVjdGlvbitqd3QiLCJhbGciOiJSUzI1NiJ9.eyJpc3MiOiJodHRwczovL2FzLmV4YW1wbGUuY29tLyIsImF1ZCI6Imh0dHBzOi8vcnMuZXhhbXBsZS5jb20vcmVzb3VyY2UiLCJpYXQiOjE1MTQ3OTc4OTIsInRva2VuX2ludHJvc3BlY3Rpb24iOnsiYWN0aXZlIjp0cnVlLCJpc3MiOiJodHRwczovL2FzLmV4YW1wbGUuY29tLyIsImF1ZCI6Imh0dHBzOi8vcnMuZXhhbXBsZS5jb20vcmVzb3VyY2UiLCJpYXQiOjE1MTQ3OTc4MjIsImV4cCI6MTUxNDc5Nzk0MiwiY2xpZW50X2lkIjoicGFpQjJnb28wYSIsInNjb3BlIjoicmVhZCB3cml0ZSBkb2xwaGluIiwic3ViIjoiWjVPM3VwUEM4OFFyQWp4MDBkaXMiLCJiaXJ0aGRhdGUiOiIxOTgyLTAyLTAxIiwiZ2l2ZW5fbmFtZSI6IkpvaG4iLCJmYW1pbHlfbmFtZSI6IkRvZSIsImp0aSI6InQxRm9DQ2FaZDRYdjRPUkpVV1ZVZVRaZnNLaFczMENRQ3JXRERqd1h5NncifX0.przJMU5GhmNzvwtt1Sr-xa9xTkpiAg5IshbQsRiRVP_7eGR1GHYrNwQh84kxOkHCyje2g5WSRcYosGEVIiC-eoPJJ-qBwqwSlgx9JEeCDw2W5DjrblOI_N0Jvsq_dUeOyoWVMqlOydOBhKNY0smBrI4NZvEExucOm9WUJXMuJtvq1gBes-0go5j4TEv9sOP9uu81gqWTr_LOo6pgT0tFFyZfWC4kbXPXiQ2YT6mxCiQRRNM-l9cBdF6Jx6IOrsfFhBuYdYQ_mlL19HgDDOFaleyqmru6lKlASOsaE8dmLSeKcX91FbG79FKN8un24iwIDCbKT9xlUFl54xWVShNDFA 2 | -------------------------------------------------------------------------------- /introspection/src/AspNetCore.Authentication.OAuth2Introspection/Context/SendingRequestContext.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | using Duende.IdentityModel.Client; 5 | using Microsoft.AspNetCore.Authentication; 6 | using Microsoft.AspNetCore.Http; 7 | 8 | namespace Duende.AspNetCore.Authentication.OAuth2Introspection.Context; 9 | 10 | /// 11 | /// Context for the SendingRequest event 12 | /// 13 | public class SendingRequestContext( 14 | HttpContext context, 15 | AuthenticationScheme scheme, 16 | OAuth2IntrospectionOptions options, 17 | TokenIntrospectionRequest tokenIntrospectionRequest) 18 | : BaseContext(context, scheme, options) 19 | { 20 | /// 21 | /// The request 22 | /// 23 | public TokenIntrospectionRequest TokenIntrospectionRequest => tokenIntrospectionRequest; 24 | } 25 | -------------------------------------------------------------------------------- /identity-model/src/IdentityModel/Client/Messages/ResponseErrorType.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | namespace Duende.IdentityModel.Client; 5 | 6 | /// 7 | /// Various reasons for a protocol endpoint error 8 | /// 9 | public enum ResponseErrorType 10 | { 11 | /// 12 | /// none 13 | /// 14 | None, 15 | 16 | /// 17 | /// protocol related - valid response, but some protocol level error. 18 | /// 19 | Protocol, 20 | 21 | /// 22 | /// HTTP error - e.g. 404. 23 | /// 24 | Http, 25 | 26 | /// 27 | /// An exception occurred - exception while connecting to the endpoint, e.g. TLS problems. 28 | /// 29 | Exception, 30 | 31 | /// 32 | /// A policy violation - a configured policy was violated. 33 | /// 34 | PolicyViolation 35 | } 36 | -------------------------------------------------------------------------------- /identity-model-oidc-client/samples/Maui/MauiApp1/MauiApp1/Platforms/Windows/App.xaml.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | using Microsoft.UI.Xaml; 5 | 6 | // To learn more about WinUI, the WinUI project structure, 7 | // and more about our project templates, see: http://aka.ms/winui-project-info. 8 | 9 | namespace MauiApp1.WinUI; 10 | /// 11 | /// Provides application-specific behavior to supplement the default Application class. 12 | /// 13 | public partial class App : MauiWinUIApplication 14 | { 15 | /// 16 | /// Initializes the singleton application object. This is the first line of authored code 17 | /// executed, and as such is the logical equivalent of main() or WinMain(). 18 | /// 19 | public App() 20 | { 21 | this.InitializeComponent(); 22 | } 23 | 24 | protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); 25 | } 26 | 27 | -------------------------------------------------------------------------------- /access-token-management/samples/BlazorServer/Plumbing/AccountController.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | using Microsoft.AspNetCore.Authentication; 5 | using Microsoft.AspNetCore.Authorization; 6 | using Microsoft.AspNetCore.Mvc; 7 | 8 | namespace BlazorServer.Plumbing; 9 | 10 | [AllowAnonymous] 11 | public class AccountController : ControllerBase 12 | { 13 | public IActionResult LogIn(string? returnUrl) 14 | { 15 | var redirectUri = "/"; 16 | 17 | if (!string.IsNullOrWhiteSpace(returnUrl)) 18 | { 19 | if (Url.IsLocalUrl(returnUrl)) 20 | { 21 | redirectUri = returnUrl; 22 | } 23 | } 24 | 25 | var props = new AuthenticationProperties 26 | { 27 | RedirectUri = redirectUri 28 | }; 29 | 30 | return Challenge(props); 31 | } 32 | 33 | public IActionResult LogOut() => SignOut("cookie", "oidc"); 34 | } 35 | -------------------------------------------------------------------------------- /access-token-management/src/AccessTokenManagement.OpenIdConnect/Internal/CircuitServicesServiceCollectionExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | using Microsoft.AspNetCore.Components.Server.Circuits; 5 | using Microsoft.Extensions.DependencyInjection; 6 | 7 | namespace Duende.AccessTokenManagement.OpenIdConnect.Internal; 8 | 9 | // This code is from the blazor documentation: 10 | // https://learn.microsoft.com/en-us/aspnet/core/blazor/fundamentals/dependency-injection?view=aspnetcore-8.0#access-server-side-blazor-services-from-a-different-di-scope 11 | 12 | internal static class CircuitServicesServiceCollectionExtensions 13 | { 14 | public static IServiceCollection AddCircuitServicesAccessor( 15 | this IServiceCollection services) 16 | { 17 | services.AddScoped(); 18 | services.AddScoped(); 19 | 20 | return services; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /access-token-management/samples/WebJarJwt/Views/Home/Secure.cshtml: -------------------------------------------------------------------------------- 1 | @using Microsoft.AspNetCore.Authentication 2 | 3 |

Call API as User

4 | 5 | Manual 6 | | 7 | Extension method 8 | | 9 | HTTP client factory 10 | | 11 | HTTP client factory (typed) 12 | 13 |

Call API as Client

14 | 15 | Extension method 16 | | 17 | HTTP client factory 18 | | 19 | HTTP client factory (typed) 20 | 21 | 22 |

Claims

23 | 24 |
25 | @foreach (var claim in User.Claims) 26 | { 27 |
@claim.Type
28 |
@claim.Value
29 | } 30 |
31 | 32 |

Properties

33 | 34 |
35 | @foreach (var prop in (await Context!.AuthenticateAsync())!.Properties!.Items) 36 | { 37 |
@prop.Key
38 |
@prop.Value
39 | } 40 |
41 | -------------------------------------------------------------------------------- /access-token-management/src/AccessTokenManagement/Internal/Crypto.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | using System.Buffers.Text; 5 | using System.Security.Cryptography; 6 | using System.Text; 7 | 8 | namespace Duende.AccessTokenManagement.Internal; 9 | 10 | internal static class Crypto 11 | { 12 | /// 13 | /// Simple hashing algorithm that should only be used to obfuscate ephemeral data in a deterministic way 14 | /// in logs, not for storing passwords 15 | /// 16 | /// The data to hash 17 | /// Hash of the incoming data. 18 | public static string HashData(string data) 19 | { 20 | using var sha = SHA256.Create(); 21 | var hash = sha.ComputeHash(Encoding.ASCII.GetBytes(data)); 22 | 23 | var leftPart = new byte[16]; 24 | Array.Copy(hash, leftPart, 16); 25 | 26 | return Base64Url.EncodeToString(leftPart); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /identity-model-oidc-client/src/IdentityModel.OidcClient/LogoutResult.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Duende Software. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | namespace Duende.IdentityModel.OidcClient; 5 | 6 | /// 7 | /// Models the result of a logout 8 | /// 9 | /// 10 | public class LogoutResult : Result 11 | { 12 | /// 13 | /// Initializes a new instance of the class. 14 | /// 15 | public LogoutResult() 16 | { 17 | } 18 | 19 | /// 20 | /// Initializes a new instance of the class. 21 | /// 22 | /// The error. 23 | public LogoutResult(string error) => Error = error; 24 | 25 | /// 26 | /// Gets or sets the response. 27 | /// 28 | /// 29 | /// The response. 30 | /// 31 | public string Response { get; set; } 32 | } 33 | -------------------------------------------------------------------------------- /test.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | $(NoWarn);1591 5 | latest 6 | full 7 | false 8 | true 9 | true 10 | enable 11 | true 12 | $(NoWarn);NU1507 13 | true 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | --------------------------------------------------------------------------------