Skip to content

Commit

Permalink
OpenIddict
Browse files Browse the repository at this point in the history
  • Loading branch information
phongnguyend committed Jan 17, 2025
1 parent 0fa59d8 commit 87110e6
Show file tree
Hide file tree
Showing 17 changed files with 83 additions and 80 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<AnalysisMode>Recommended</AnalysisMode>
<AnalysisModeSecurity>All</AnalysisModeSecurity>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="9.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.1" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<AnalysisMode>Recommended</AnalysisMode>
<AnalysisModeSecurity>All</AnalysisModeSecurity>
</PropertyGroup>
Expand All @@ -11,7 +11,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="System.Text.Json" Version="8.0.0" />
<PackageReference Include="System.Text.Json" Version="9.0.1" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<AnalysisMode>Recommended</AnalysisMode>
<AnalysisModeSecurity>All</AnalysisModeSecurity>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.1" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<PrivateAssets>all</PrivateAssets>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<AnalysisMode>Recommended</AnalysisMode>
<AnalysisModeSecurity>All</AnalysisModeSecurity>
<UserSecretsId>aae914a2-80ef-4814-891a-8ed4e63c8c79</UserSecretsId>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.Facebook" Version="8.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Google" Version="8.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.MicrosoftAccount" Version="8.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="8.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="8.0.0" />
<PackageReference Include="OpenIddict.AspNetCore" Version="4.10.1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Facebook" Version="9.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Google" Version="9.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.MicrosoftAccount" Version="9.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="9.0.1" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="9.0.0" />
<PackageReference Include="OpenIddict.AspNetCore" Version="6.0.0" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ public async Task<IActionResult> Exchange()
claimsPrincipal = new ClaimsPrincipal(identity);

claimsPrincipal.SetScopes(request.GetScopes());
claimsPrincipal.SetResources(await _scopeManager.ListResourcesAsync(claimsPrincipal.GetScopes()).ToListAsync());
}
else if (request.IsAuthorizationCodeGrantType())
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build-env
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build-env
WORKDIR /ClassifiedAds.IdentityServer

# Copy csproj and restore as distinct layers
Expand All @@ -17,7 +17,7 @@ COPY . ./
RUN dotnet publish ./ClassifiedAds.IdentityServer/ClassifiedAds.IdentityServer.csproj -c Release -o out

# Build runtime image
FROM mcr.microsoft.com/dotnet/aspnet:8.0
FROM mcr.microsoft.com/dotnet/aspnet:9.0
WORKDIR /ClassifiedAds.IdentityServer
COPY --from=build-env /ClassifiedAds.IdentityServer/out .

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ private static async Task RegisterApplicationsAsync(IServiceScope scope, Cancell
{
OpenIddictConstants.Permissions.Endpoints.Authorization,
OpenIddictConstants.Permissions.Endpoints.Token,
OpenIddictConstants.Permissions.Endpoints.Logout,
OpenIddictConstants.Permissions.Endpoints.EndSession,

OpenIddictConstants.Permissions.GrantTypes.AuthorizationCode,
OpenIddictConstants.Permissions.GrantTypes.ClientCredentials,
Expand All @@ -59,7 +59,7 @@ private static async Task RegisterApplicationsAsync(IServiceScope scope, Cancell
{
OpenIddictConstants.Requirements.Features.ProofKeyForCodeExchange
},
Type = OpenIddictConstants.ClientTypes.Confidential,
ClientType = OpenIddictConstants.ClientTypes.Confidential,
}, cancellationToken);

await UpsertClientApplication(manager, new OpenIddictApplicationDescriptor
Expand All @@ -79,7 +79,7 @@ private static async Task RegisterApplicationsAsync(IServiceScope scope, Cancell
{
OpenIddictConstants.Permissions.Endpoints.Authorization,
OpenIddictConstants.Permissions.Endpoints.Token,
OpenIddictConstants.Permissions.Endpoints.Logout,
OpenIddictConstants.Permissions.Endpoints.EndSession,

OpenIddictConstants.Permissions.GrantTypes.AuthorizationCode,
OpenIddictConstants.Permissions.GrantTypes.ClientCredentials,
Expand All @@ -96,7 +96,7 @@ private static async Task RegisterApplicationsAsync(IServiceScope scope, Cancell
{
OpenIddictConstants.Requirements.Features.ProofKeyForCodeExchange
},
Type = OpenIddictConstants.ClientTypes.Confidential,
ClientType = OpenIddictConstants.ClientTypes.Confidential,
}, cancellationToken);

await UpsertClientApplication(manager, new OpenIddictApplicationDescriptor
Expand All @@ -116,7 +116,7 @@ private static async Task RegisterApplicationsAsync(IServiceScope scope, Cancell
{
OpenIddictConstants.Permissions.Endpoints.Authorization,
OpenIddictConstants.Permissions.Endpoints.Token,
OpenIddictConstants.Permissions.Endpoints.Logout,
OpenIddictConstants.Permissions.Endpoints.EndSession,

OpenIddictConstants.Permissions.GrantTypes.AuthorizationCode,
OpenIddictConstants.Permissions.GrantTypes.ClientCredentials,
Expand All @@ -133,7 +133,7 @@ private static async Task RegisterApplicationsAsync(IServiceScope scope, Cancell
{
OpenIddictConstants.Requirements.Features.ProofKeyForCodeExchange
},
Type = OpenIddictConstants.ClientTypes.Confidential,
ClientType = OpenIddictConstants.ClientTypes.Confidential,
}, cancellationToken);

await UpsertClientApplication(manager, new OpenIddictApplicationDescriptor
Expand All @@ -153,7 +153,7 @@ private static async Task RegisterApplicationsAsync(IServiceScope scope, Cancell
{
OpenIddictConstants.Permissions.Endpoints.Authorization,
OpenIddictConstants.Permissions.Endpoints.Token,
OpenIddictConstants.Permissions.Endpoints.Logout,
OpenIddictConstants.Permissions.Endpoints.EndSession,

OpenIddictConstants.Permissions.GrantTypes.AuthorizationCode,
OpenIddictConstants.Permissions.GrantTypes.ClientCredentials,
Expand All @@ -169,7 +169,7 @@ private static async Task RegisterApplicationsAsync(IServiceScope scope, Cancell
{
OpenIddictConstants.Requirements.Features.ProofKeyForCodeExchange
},
Type = OpenIddictConstants.ClientTypes.Confidential,
ClientType = OpenIddictConstants.ClientTypes.Confidential,
}, cancellationToken);

await UpsertClientApplication(manager, new OpenIddictApplicationDescriptor
Expand All @@ -188,7 +188,7 @@ private static async Task RegisterApplicationsAsync(IServiceScope scope, Cancell
{
OpenIddictConstants.Permissions.Endpoints.Authorization,
OpenIddictConstants.Permissions.Endpoints.Token,
OpenIddictConstants.Permissions.Endpoints.Logout,
OpenIddictConstants.Permissions.Endpoints.EndSession,

OpenIddictConstants.Permissions.GrantTypes.AuthorizationCode,
OpenIddictConstants.Permissions.GrantTypes.ClientCredentials,
Expand All @@ -204,7 +204,7 @@ private static async Task RegisterApplicationsAsync(IServiceScope scope, Cancell
{
OpenIddictConstants.Requirements.Features.ProofKeyForCodeExchange
},
Type = OpenIddictConstants.ClientTypes.Public,
ClientType = OpenIddictConstants.ClientTypes.Public,
}, cancellationToken);

await UpsertClientApplication(manager, new OpenIddictApplicationDescriptor
Expand All @@ -223,7 +223,7 @@ private static async Task RegisterApplicationsAsync(IServiceScope scope, Cancell
{
OpenIddictConstants.Permissions.Endpoints.Authorization,
OpenIddictConstants.Permissions.Endpoints.Token,
OpenIddictConstants.Permissions.Endpoints.Logout,
OpenIddictConstants.Permissions.Endpoints.EndSession,

OpenIddictConstants.Permissions.GrantTypes.AuthorizationCode,
OpenIddictConstants.Permissions.GrantTypes.ClientCredentials,
Expand All @@ -239,7 +239,7 @@ private static async Task RegisterApplicationsAsync(IServiceScope scope, Cancell
{
OpenIddictConstants.Requirements.Features.ProofKeyForCodeExchange
},
Type = OpenIddictConstants.ClientTypes.Public,
ClientType = OpenIddictConstants.ClientTypes.Public,
}, cancellationToken);

await UpsertClientApplication(manager, new OpenIddictApplicationDescriptor
Expand All @@ -258,7 +258,7 @@ private static async Task RegisterApplicationsAsync(IServiceScope scope, Cancell
{
OpenIddictConstants.Permissions.Endpoints.Authorization,
OpenIddictConstants.Permissions.Endpoints.Token,
OpenIddictConstants.Permissions.Endpoints.Logout,
OpenIddictConstants.Permissions.Endpoints.EndSession,

OpenIddictConstants.Permissions.GrantTypes.AuthorizationCode,
OpenIddictConstants.Permissions.GrantTypes.ClientCredentials,
Expand All @@ -274,7 +274,7 @@ private static async Task RegisterApplicationsAsync(IServiceScope scope, Cancell
{
OpenIddictConstants.Requirements.Features.ProofKeyForCodeExchange
},
Type = OpenIddictConstants.ClientTypes.Public,
ClientType = OpenIddictConstants.ClientTypes.Public,
}, cancellationToken);

await UpsertClientApplication(manager, new OpenIddictApplicationDescriptor
Expand All @@ -293,7 +293,7 @@ private static async Task RegisterApplicationsAsync(IServiceScope scope, Cancell
{
OpenIddictConstants.Permissions.Endpoints.Authorization,
OpenIddictConstants.Permissions.Endpoints.Token,
OpenIddictConstants.Permissions.Endpoints.Logout,
OpenIddictConstants.Permissions.Endpoints.EndSession,

OpenIddictConstants.Permissions.GrantTypes.AuthorizationCode,
OpenIddictConstants.Permissions.GrantTypes.ClientCredentials,
Expand All @@ -309,7 +309,7 @@ private static async Task RegisterApplicationsAsync(IServiceScope scope, Cancell
{
OpenIddictConstants.Requirements.Features.ProofKeyForCodeExchange
},
Type = OpenIddictConstants.ClientTypes.Public,
ClientType = OpenIddictConstants.ClientTypes.Public,
}, cancellationToken);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ public void ConfigureServices(IServiceCollection services)
options
.SetTokenEndpointUris("connect/token")
.SetAuthorizationEndpointUris("connect/authorize")
.SetLogoutEndpointUris("connect/logout")
.SetUserinfoEndpointUris("connect/userinfo");
.SetEndSessionEndpointUris("connect/logout")
.SetUserInfoEndpointUris("connect/userinfo");

options.AllowAuthorizationCodeFlow()
.AllowHybridFlow()
Expand All @@ -115,8 +115,8 @@ public void ConfigureServices(IServiceCollection services)
.UseAspNetCore()
.EnableTokenEndpointPassthrough()
.EnableAuthorizationEndpointPassthrough()
.EnableLogoutEndpointPassthrough()
.EnableUserinfoEndpointPassthrough();
.EnableEndSessionEndpointPassthrough()
.EnableUserInfoEndpointPassthrough();

options.DisableAccessTokenEncryption();
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
"EncryptionCertificate": {
"Thumbprint": null,
"Path": "Certs/classifiedads.identityserver.pfx",
"Password": "password1234"
"Password": "password1234",
"X509KeyStorageFlags": "EphemeralKeySet"
},
"SigningCertificate": {
"Thumbprint": null,
"Path": "Certs/classifiedads.identityserver.pfx",
"Password": "password1234"
"Password": "password1234",
"X509KeyStorageFlags": "EphemeralKeySet"
}
},
"Logging": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<AnalysisMode>Recommended</AnalysisMode>
<AnalysisModeSecurity>All</AnalysisModeSecurity>
</PropertyGroup>

<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Azure.Data.AppConfiguration" Version="1.3.0" />
<PackageReference Include="Azure.Extensions.AspNetCore.Configuration.Secrets" Version="1.3.0" />
<PackageReference Include="Azure.Identity" Version="1.10.4" />
<PackageReference Include="Azure.Data.AppConfiguration" Version="1.5.0" />
<PackageReference Include="Azure.Extensions.AspNetCore.Configuration.Secrets" Version="1.3.2" />
<PackageReference Include="Azure.Identity" Version="1.13.2" />
<PackageReference Include="Castle.Core" Version="5.1.1" />
<PackageReference Include="CryptographyHelper" Version="3.0.0" />
<PackageReference Include="Dapper.StrongName" Version="2.1.24" />
<PackageReference Include="CryptographyHelper" Version="3.1.0" />
<PackageReference Include="Dapper.StrongName" Version="2.1.35" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.22.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="8.0.0" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="8.0.0" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.MessagePack" Version="8.0.0" />
<PackageReference Include="Microsoft.Azure.AppConfiguration.AspNetCore" Version="7.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Caching.Redis" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Caching.SqlServer" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.AzureAppServices" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.EventLog" Version="8.0.0" />
<PackageReference Include="MiniProfiler.AspNetCore.Mvc" Version="4.3.8" />
<PackageReference Include="MiniProfiler.EntityFrameworkCore" Version="4.3.8" />
<PackageReference Include="MiniProfiler.Providers.SqlServer" Version="4.3.8" />
<PackageReference Include="Quartz" Version="3.8.0" />
<PackageReference Include="Serilog" Version="3.1.1" />
<PackageReference Include="Serilog.AspNetCore" Version="8.0.0" />
<PackageReference Include="Serilog.Enrichers.Environment" Version="2.3.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="9.0.1" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="9.0.1" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.MessagePack" Version="9.0.1" />
<PackageReference Include="Microsoft.Azure.AppConfiguration.AspNetCore" Version="8.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.1" />
<PackageReference Include="Microsoft.Extensions.Caching.Redis" Version="2.3.0" />
<PackageReference Include="Microsoft.Extensions.Caching.SqlServer" Version="9.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging.AzureAppServices" Version="9.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging.EventLog" Version="9.0.1" />
<PackageReference Include="MiniProfiler.AspNetCore.Mvc" Version="4.5.4" />
<PackageReference Include="MiniProfiler.EntityFrameworkCore" Version="4.5.4" />
<PackageReference Include="MiniProfiler.Providers.SqlServer" Version="4.5.4" />
<PackageReference Include="Quartz" Version="3.13.1" />
<PackageReference Include="Serilog" Version="4.2.0" />
<PackageReference Include="Serilog.AspNetCore" Version="9.0.0" />
<PackageReference Include="Serilog.Enrichers.Environment" Version="3.0.1" />
<PackageReference Include="Serilog.Exceptions" Version="8.4.0" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="VaultSharp" Version="1.13.0.1" />
<PackageReference Include="VaultSharp" Version="1.17.5.1" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<AnalysisMode>Recommended</AnalysisMode>
<AnalysisModeSecurity>All</AnalysisModeSecurity>
<UserSecretsId>b8df572d-5be2-4f41-b55a-8f4e2ef2b569</UserSecretsId>
Expand All @@ -21,13 +21,13 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="dbup" Version="5.0.37" />
<PackageReference Include="Polly" Version="8.2.0" />
<PackageReference Include="dbup" Version="5.0.41" />
<PackageReference Include="Polly" Version="8.5.1" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.0">
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="9.0.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Loading

0 comments on commit 87110e6

Please sign in to comment.