![]() |
VOOZH | about |
dotnet add package Aguacongas.IdentityServer.Saml2p.Duende --version 10.0.4
NuGet\Install-Package Aguacongas.IdentityServer.Saml2p.Duende -Version 10.0.4
<PackageReference Include="Aguacongas.IdentityServer.Saml2p.Duende" Version="10.0.4" />
<PackageVersion Include="Aguacongas.IdentityServer.Saml2p.Duende" Version="10.0.4" />Directory.Packages.props
<PackageReference Include="Aguacongas.IdentityServer.Saml2p.Duende" />Project file
paket add Aguacongas.IdentityServer.Saml2p.Duende --version 10.0.4
#r "nuget: Aguacongas.IdentityServer.Saml2p.Duende, 10.0.4"
#:package Aguacongas.IdentityServer.Saml2p.Duende@10.0.4
#addin nuget:?package=Aguacongas.IdentityServer.Saml2p.Duende&version=10.0.4Install as a Cake Addin
#tool nuget:?package=Aguacongas.IdentityServer.Saml2p.Duende&version=10.0.4Install as a Cake Tool
Add a SAML2P controller to your Duende Identity server.
This lib uses ITfoxtec.Identity.Saml2.MvcCore internally to implements the protocol.
services.AddIdentityServer()
.AddKeysRotation(options => configuration.GetSection(nameof(KeyRotationOptions))?.Bind(options));
services.AddControllersWithViews()
.AddIdentityServerSaml2P();
Saml2P depends on a
ISigningCredentialStore. You can register it usingAddSigningCredentialwith aX509Certificate2in place ofAddKeysRotationif you prefer.
saml2p/metadata returns the Saml2P metadata document.
You can add a client to you configuration with saml2p as protocol type:
new Client
{
ClientId = "itfoxtec-testwebappcore",
ProtocolType = ProtocolTypes.Saml2p,
RedirectUris = { "http://localhost:10314/Auth/AssertionConsumerService" },
PostLogoutRedirectUris = "http://localhost:10314/Auth/SingleLogout",
ClientSecrets = [
new Secret {
Type = SecretTypes.X509CertificateBase64,
Value = Convert.ToBase64String(certificate.Export(X509ContentType.Cert))
}
]
}
The client must have only one redirect uri pointing to the Assertion Consumer Service route and one X509Certificate secret mathing its signing certificate.
And configure the client to use Saml2P authentication using ITfoxtec.Identity.Saml2:
services.BindConfig<Saml2Configuration>(Configuration, "Saml2", (serviceProvider, saml2Configuration) =>
{
// The certificate must be the one configured as secret for the client;
saml2Configuration.SigningCertificate = CertificateUtil.Load(AppEnvironment.MapToPhysicalFilePath(Configuration["Saml2:SigningCertificateFile"]), Configuration["Saml2:SigningCertificatePassword"], X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.PersistKeySet);
saml2Configuration.AllowedAudienceUris.Add(saml2Configuration.Issuer);
var httpClientFactory = serviceProvider.GetService<IHttpClientFactory>();
var entityDescriptor = new EntityDescriptor();
entityDescriptor.ReadIdPSsoDescriptorFromUrlAsync(httpClientFactory, new Uri(Configuration["Saml2:IdPMetadata"])).GetAwaiter().GetResult();
if (entityDescriptor.IdPSsoDescriptor != null)
{
saml2Configuration.AllowedIssuer = entityDescriptor.EntityId;
saml2Configuration.SingleSignOnDestination = entityDescriptor.IdPSsoDescriptor.SingleSignOnServices.First().Location;
saml2Configuration.SingleLogoutDestination = entityDescriptor.IdPSsoDescriptor.SingleLogoutServices.First().Location;
foreach (var signingCertificate in entityDescriptor.IdPSsoDescriptor.SigningCertificates)
{
if (signingCertificate.IsValidLocalTime())
{
saml2Configuration.SignatureValidationCertificates.Add(signingCertificate);
}
}
if (saml2Configuration.SignatureValidationCertificates.Count <= 0)
{
throw new Exception("The IdP signing certificates has expired.");
}
if (entityDescriptor.IdPSsoDescriptor.WantAuthnRequestsSigned.HasValue)
{
saml2Configuration.SignAuthnRequest = entityDescriptor.IdPSsoDescriptor.WantAuthnRequestsSigned.Value;
}
}
else
{
throw new Exception("IdPSsoDescriptor not loaded from metadata.");
}
return saml2Configuration;
});
services.AddSaml2(slidingExpiration: true);
services.AddHttpClient();
appsettings.json
{
"Saml2": {
"IdPMetadata": "https://localhost:5443/saml2p/metadata", // Your Duende Identity server metadata uri
"Issuer": "itfoxtec-testwebappcore", // Client Id
"SignatureAlgorithm": "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256",
"SigningCertificateFile": "itfoxtec.identity.saml2.testwebappcore_Certificate.pfx",
"SigningCertificatePassword": "!QAZ2wsx",
"CertificateValidationMode": "None", // "ChainTrust"
"RevocationMode": "NoCheck"
}
}
Review samples in ITfoxtec/ITfoxtec.Identity.Saml2 repo
AddIdentityServerSaml2P extension accept a IConfiguration or a Saml2POptions parameter to configure the metadata document génération with claims lists.
mvcBuilder.AddIdentityServerSaml2P(configurationManager.GetSection(nameof(Saml2POptions)));
"Saml2POptions": {
"X509CertificateValidationMode": "None",
"ContactPersons": [
{
"ContactKind": "Technical",
"Company": "Aguafrommars",
"GivenName": "Olivier Lefebvre",
"SurName": "Aguacongas",
"EmailAddress": "aguacongas@gmail.com"
}
],
"RevocationMode": "NoCheck",
"SignatureAlgorithm": "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256",
"ValidUntil": 365
}
To access data the use a . You can implement this interface and provide your implementation to the DI to ovveride the default implementation.
/// <summary>
/// Custom IRelyingPartyStore implementation
/// </summary>
/// <seealso cref="IRelyingPartyStore" />
public class MyRelyingPartyStore : IRelyingPartyStore
{
public async Task<RelyingParty> FindRelyingPartyByRealm(string realm)
{
// TODO: Implement me
throw new NotImplementedException();
}
}
The DI configuration become:
services.AddIdentityServer()
.AddKeysRotation(options => configuration.GetSection(nameof(KeyRotationOptions))?.Bind(options));
services.AddControllersWithViews()
.AddIdentityServerSaml2P();
services.AddTransient<IRelyingPartyStore, MyRelyingPartyStore>();
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 10.0.4 | 110 | 5/14/2026 |
| 10.0.3 | 118 | 4/23/2026 |
| 10.0.2 | 146 | 2/13/2026 |
| 10.0.1 | 215 | 11/28/2025 |
| 10.0.0 | 399 | 11/17/2025 |
| 9.1.2 | 214 | 9/7/2025 |
| 9.1.1 | 320 | 3/18/2025 |
| 9.1.1-preview21- | 256 | 3/18/2025 |
| 9.1.0 | 244 | 2/22/2025 |
| 9.0.0 | 252 | 2/22/2025 |
| 9.0.0-preview106- | 153 | 2/22/2025 |
| 8.3.0 | 264 | 12/28/2024 |
| 8.2.1 | 262 | 12/28/2024 |
| 8.2.0 | 238 | 11/9/2024 |
| 8.1.1 | 248 | 11/9/2024 |
| 8.1.0-preview57- | 184 | 11/3/2024 |
| 8.0.1 | 649 | 9/22/2024 |
| 8.0.0 | 331 | 3/9/2024 |
| 8.0.0-preview1-0001 | 310 | 11/18/2023 |