Skip to content

update to saml v10 #51

New issue

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

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

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@ ClientBin/
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<Compile Include="..\..\LicenseKey.cs" Link="LicenseKey.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Duende.IdentityServer" Version="7.0.0" />
<PackageReference Include="Rsk.Saml" Version="9.0.0" />
<PackageReference Include="Duende.IdentityServer" Version="7.1.0" />
<PackageReference Include="Rsk.Saml" Version="10.0.0" />
<PackageReference Include="Rsk.Saml.DuendeIdentityServer" Version="9.0.0" />
<PackageReference Include="Serilog.AspNetCore" Version="8.0.1" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Duende.IdentityModel;
using Duende.IdentityServer.Events;
using Duende.IdentityServer.Extensions;
using Duende.IdentityServer.Services;
using IdentityModel;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using Duende.IdentityModel;
using Duende.IdentityServer.Events;
using Duende.IdentityServer.Extensions;
using Duende.IdentityServer.Models;
using Duende.IdentityServer.Services;
using Duende.IdentityServer.Validation;
using IdentityModel;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
// Copyright (c) Duende Software. All rights reserved.
// See LICENSE in the project root for license information.


using IdentityModel;
using Microsoft.AspNetCore.Authentication;
using System.Text;
using System.Text.Json;
using Duende.IdentityModel;

namespace DuendeDynamicProviders.Pages.Diagnostics;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System.Security.Claims;
using Duende.IdentityModel;
using Duende.IdentityServer;
using Duende.IdentityServer.Events;
using Duende.IdentityServer.Services;
using Duende.IdentityServer.Test;
using IdentityModel;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
// Copyright (c) Duende Software. All rights reserved.
// See LICENSE in the project root for license information.


using IdentityModel;
using System.Security.Claims;
using System.Text.Json;
using Duende.IdentityModel;
using Duende.IdentityServer;
using Duende.IdentityServer.Test;

Expand Down
6 changes: 3 additions & 3 deletions DuendeIdentityServer/DuendeIdP/DuendeIdP.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Duende.IdentityServer" Version="7.0.0" />
<PackageReference Include="Rsk.Saml" Version="9.0.0" />
<PackageReference Include="Rsk.Saml.DuendeIdentityServer" Version="9.0.0" />
<PackageReference Include="Duende.IdentityServer" Version="7.1.0" />
<PackageReference Include="Rsk.Saml" Version="10.0.0" />
<PackageReference Include="Rsk.Saml.DuendeIdentityServer" Version="10.0.0" />

<PackageReference Include="Serilog.AspNetCore" Version="8.0.1" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Duende.IdentityModel;
using Duende.IdentityServer.Events;
using Duende.IdentityServer.Extensions;
using Duende.IdentityServer.Services;
using IdentityModel;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using Duende.IdentityModel;
using Duende.IdentityServer.Events;
using Duende.IdentityServer.Extensions;
using Duende.IdentityServer.Models;
using Duende.IdentityServer.Services;
using Duende.IdentityServer.Validation;
using IdentityModel;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
// See LICENSE in the project root for license information.


using IdentityModel;
using Microsoft.AspNetCore.Authentication;
using System.Text;
using System.Text.Json;
using Duende.IdentityModel;

namespace DuendeIdP.Pages.Diagnostics;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System.Security.Claims;
using Duende.IdentityModel;
using Duende.IdentityServer;
using Duende.IdentityServer.Events;
using Duende.IdentityServer.Services;
using Duende.IdentityServer.Test;
using IdentityModel;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
Expand Down
2 changes: 1 addition & 1 deletion DuendeIdentityServer/DuendeIdP/Pages/TestUsers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// See LICENSE in the project root for license information.


using IdentityModel;
using System.Security.Claims;
using System.Text.Json;
using Duende.IdentityModel;
using Duende.IdentityServer;
using Duende.IdentityServer.Test;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Security.Cryptography.X509Certificates;
using Duende.IdentityModel;
using Duende.IdentityServer;
using Duende.IdentityServer.Models;
using IdentityModel;
using Rsk.Saml;
using Rsk.Saml.Models;
using ServiceProvider = Rsk.Saml.Models.ServiceProvider;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AspNetCore.ReCaptcha" Version="1.8.1" />
<PackageReference Include="Duende.IdentityServer.EntityFramework" Version="7.0.0" />
<PackageReference Include="Duende.IdentityServer.EntityFramework" Version="7.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.WsFederation" Version="8.0.1" />
<PackageReference Include="Microsoft.AspNetCore.DataProtection" Version="8.0.1" />
<PackageReference Include="Microsoft.AspNetCore.DataProtection.EntityFrameworkCore" Version="8.0.1" />
Expand All @@ -15,8 +15,8 @@
<PackageReference Include="Microsoft.Extensions.Caching.StackExchangeRedis" Version="8.0.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Oracle.ManagedDataAccess.Core" Version="3.21.130" />
<PackageReference Include="Rsk.Saml.DuendeIdentityServer" Version="9.0.0" />
<PackageReference Include="Rsk.Saml.DuendeIdentityServer.EntityFramework" Version="9.0.0" />
<PackageReference Include="Rsk.Saml.DuendeIdentityServer" Version="10.0.0" />
<PackageReference Include="Rsk.Saml.DuendeIdentityServer.EntityFramework" Version="10.0.0" />
<PackageReference Include="Serilog.AspNetCore" Version="8.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="8.0.1" />
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.0" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System.Threading.Tasks;
using Duende.IdentityModel;
using Duende.IdentityServer.Events;
using Duende.IdentityServer.Extensions;
using Duende.IdentityServer.Services;
using IdentityModel;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Duende.IdentityModel;
using Duende.IdentityServer.Events;
using Duende.IdentityServer.Extensions;
using Duende.IdentityServer.Models;
using Duende.IdentityServer.Services;
using Duende.IdentityServer.Validation;
using IdentityModel;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
// See LICENSE in the project root for license information.


using IdentityModel;
using System.Collections.Generic;
using System.Security.Claims;
using System.Text.Json;
using Duende.IdentityModel;
using Duende.IdentityServer;
using Duende.IdentityServer.Test;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="8.0.1" />
<PackageReference Include="Microsoft.IdentityModel.Protocols.OpenIdConnect" Version="7.3.0" />
<PackageReference Include="Rsk.Saml" Version="9.0.0" />
<PackageReference Include="Rsk.Saml" Version="10.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<Compile Include="..\..\..\..\LicenseKey.cs" Link="LicenseKey.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Rsk.Saml" Version="9.0.0" />
<PackageReference Include="Rsk.Saml" Version="10.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="8.0.1" />
</ItemGroup>
<ItemGroup>
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<Compile Include="..\..\..\..\LicenseKey.cs" Link="LicenseKey.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Rsk.Saml" Version="9.0.0" />
<PackageReference Include="Rsk.Saml" Version="10.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="8.0.1" />
</ItemGroup>
<ItemGroup>
Expand Down
Binary file not shown.
12 changes: 6 additions & 6 deletions OpenIddict/OpenIddictIdP/Controllers/AuthorizationController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ public async Task<IActionResult> Authorize()
// - If prompt=login was specified by the client application.
// - If a max_age parameter was provided and the authentication cookie is not considered "fresh" enough.
var result = await HttpContext.AuthenticateAsync(IdentityConstants.ApplicationScheme);
if (result == null || !result.Succeeded || request.HasPrompt(Prompts.Login) ||
if (result == null || !result.Succeeded || request.HasPromptValue(PromptValues.Login) ||
request.MaxAge != null && result.Properties?.IssuedUtc != null &&
DateTimeOffset.UtcNow - result.Properties.IssuedUtc > TimeSpan.FromSeconds(request.MaxAge.Value))
{
// If the client application requested promptless authentication,
// return an error indicating that the user is not logged in.
if (request.HasPrompt(Prompts.None))
if (request.HasPromptValue(PromptValues.None))
{
return Forbid(
authenticationSchemes: OpenIddictServerAspNetCoreDefaults.AuthenticationScheme,
Expand All @@ -81,7 +81,7 @@ public async Task<IActionResult> Authorize()

// To avoid endless login -> authorization redirects, the prompt=login flag
// is removed from the authorization request payload before redirecting the user.
var prompt = string.Join(" ", request.GetPrompts().Remove(Prompts.Login));
var prompt = string.Join(" ", request.GetPromptValues().Remove(PromptValues.Login));

var parameters = Request.HasFormContentType ?
Request.Form.Where(parameter => parameter.Key != Parameters.Prompt).ToList() :
Expand Down Expand Up @@ -142,7 +142,7 @@ public async Task<IActionResult> Authorize()
// return an authorization response without displaying the consent form.
case ConsentTypes.Implicit:
case ConsentTypes.External when authorizations.Any():
case ConsentTypes.Explicit when authorizations.Any() && !request.HasPrompt(Prompts.Consent):
case ConsentTypes.Explicit when authorizations.Any() && !request.HasPromptValue(PromptValues.Consent):
// Create the claims-based identity that will be used by OpenIddict to generate tokens.
var identity = new ClaimsIdentity(
authenticationType: TokenValidationParameters.DefaultAuthenticationType,
Expand Down Expand Up @@ -178,8 +178,8 @@ public async Task<IActionResult> Authorize()

// At this point, no authorization was found in the database and an error must be returned
// if the client application specified prompt=none in the authorization request.
case ConsentTypes.Explicit when request.HasPrompt(Prompts.None):
case ConsentTypes.Systematic when request.HasPrompt(Prompts.None):
case ConsentTypes.Explicit when request.HasPromptValue(PromptValues.None):
case ConsentTypes.Systematic when request.HasPromptValue(PromptValues.None):
return Forbid(
authenticationSchemes: OpenIddictServerAspNetCoreDefaults.AuthenticationScheme,
properties: new AuthenticationProperties(new Dictionary<string, string>
Expand Down
9 changes: 9 additions & 0 deletions OpenIddict/OpenIddictIdP/JwtClaimTypes.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace openiddictidp;

public class JwtClaimTypes
{
public const string Subject = "sub";
public const string Name = "name";
public const string Role = "role";
public const string Email = "email";
}
12 changes: 6 additions & 6 deletions OpenIddict/OpenIddictIdP/OpenIddictIdP.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@
<Compile Include="..\..\LicenseKey.cs" Link="LicenseKey.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Rsk.Saml.OpenIddict.AspNetCore.Identity" Version="9.0.0" />
<PackageReference Include="Rsk.Saml.OpenIddict.AspNetCore.Identity" Version="10.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="8.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="8.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="8.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.1" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="8.0.0" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="OpenIddict.Quartz" Version="5.1.0" />
<PackageReference Include="OpenIddict.Quartz" Version="6.0.0" />
<PackageReference Include="Quartz.Extensions.Hosting" Version="3.8.0" />
<PackageReference Include="Rsk.Saml.OpenIddict" Version="9.0.0" />
<PackageReference Include="Rsk.Saml.OpenIddict.EntityFrameworkCore" Version="9.0.0" />
<PackageReference Include="Rsk.Saml.OpenIddict.Quartz" Version="9.0.0" />
<PackageReference Include="Rsk.Saml.OpenIddict" Version="10.0.0" />
<PackageReference Include="Rsk.Saml.OpenIddict.EntityFrameworkCore" Version="10.0.0" />
<PackageReference Include="Rsk.Saml.OpenIddict.Quartz" Version="10.0.0" />
</ItemGroup>
<ItemGroup>
<None Update="Resources\idsrv3test.cer">
Expand Down
27 changes: 9 additions & 18 deletions OpenIddict/OpenIddictIdP/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Rsk.Saml.OpenIddict.Quartz.Configuration.DependencyInjection;
using IdentityModel;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Identity;
Expand All @@ -15,6 +14,7 @@
using Rsk.Saml.OpenIddict.EntityFrameworkCore.Configuration.DependencyInjection;
using Rsk.Saml.Samples;
using static OpenIddict.Abstractions.OpenIddictConstants;
using Microsoft.Extensions.Options;

namespace openiddictidp;

Expand Down Expand Up @@ -92,9 +92,9 @@ public void ConfigureServices(IServiceCollection services)

// Enable the authorization, logout, token and userinfo endpoints.
options.SetAuthorizationEndpointUris("connect/authorize")
.SetLogoutEndpointUris("connect/logout")
.SetEndSessionEndpointUris("connect/logout")
.SetTokenEndpointUris("connect/token")
.SetUserinfoEndpointUris("connect/userinfo");
.SetUserInfoEndpointUris("connect/userinfo");

// Mark the "email", "profile" and "roles" scopes as supported scopes.
options.RegisterScopes(Scopes.Email, Scopes.Profile, Scopes.Roles);
Expand All @@ -110,9 +110,9 @@ public void ConfigureServices(IServiceCollection services)
// Register the ASP.NET Core host and configure the ASP.NET Core-specific options.
options.UseAspNetCore()
.EnableAuthorizationEndpointPassthrough()
.EnableLogoutEndpointPassthrough()
.EnableEndSessionEndpointPassthrough()
.EnableTokenEndpointPassthrough()
.EnableUserinfoEndpointPassthrough()
.EnableUserInfoEndpointPassthrough()
.EnableStatusCodePagesIntegration();

options.AddSamlPlugin(builder =>
Expand All @@ -122,18 +122,9 @@ public void ConfigureServices(IServiceCollection services)

//Already added the DbContext above
builder.UseSamlEntityFrameworkCore()
.AddSamlMessageDbContext(optionsBuilder =>
{
//Configure the database provider to use.
optionsBuilder.UseSqlServer(defaultConnectionString, x =>x.MigrationsAssembly(typeof(Startup).Assembly.FullName));
})
.AddSamlConfigurationDbContext(optionsBuilder =>
{
//Configure the database provider to use.
optionsBuilder.UseSqlServer(defaultConnectionString,
x => x.MigrationsAssembly(typeof(Startup).Assembly.FullName));
});

.AddSamlDbContexts(optionsBuilder => optionsBuilder.UseSqlServer(defaultConnectionString,
x => x.MigrationsAssembly(typeof(Startup).Assembly.FullName)));

builder.ConfigureSamlOpenIddictServerOptions(serverOptions =>
{
serverOptions.HostOptions = new SamlHostUserInteractionOptions()
Expand Down Expand Up @@ -202,4 +193,4 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
endpoints.MapRazorPages();
});
}
}
}
2 changes: 1 addition & 1 deletion OpenIddict/OpenIddictIdP/Worker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ private Task CreateMvcClientIfNotExists(IServiceScope scope)
ocd.Permissions.UnionWith(new[]
{
Permissions.Endpoints.Authorization,
Permissions.Endpoints.Logout,
Permissions.Endpoints.EndSession,
Permissions.Endpoints.Token,
Permissions.GrantTypes.AuthorizationCode,
Permissions.ResponseTypes.Code,
Expand Down
Loading