• +45 4949 9091
  • Ondersteuning
  • Talen
    • Talen
    • English
    • Dansk
    • Svenska
    • Norsk
    • Deutsch
    • Nederlands
    • Polski
    • Français
    • Español
    • Italiano
    • Português
  • Registreren
  • Inloggen
FoxIDs logo
  • Platform
    • Uitrol
    • Multi-tenant
    • Identiteitslogica
    • Compliance
  • Toepassingen
    • Overzicht
    • Klanten
    • Medewerkers
    • Partners
    • Klantverhalen
  • Diensten
  • Prijzen
  • Docs & tools
    • Documentatie
    • Artikelen
    • JWT tool
    • SAML 2.0 tool
    • Certificaat tool
  • Neem contact op
  • Registreren
  • Inloggen

ITfoxtec Identity SAML 2.0

Het open-sourcepakket ITfoxtec Identity Saml2 voegt SAML 2.0- / SAML-P-ondersteuning toe voor .NET-applicaties die moeten werken als Identity Provider (IdP), Service Provider (SP) of Relying Party (RP).

Het pakket ITfoxtec Identity Saml2 is geschikt wanneer SAML 2.0 rechtstreeks in de applicatie moet worden geïmplementeerd. Het ondersteunt aanmelden, afmelden en single logout via SAML 2.0, metadata, Redirect Binding, POST Binding, Artifact Binding, ondertekening en validatie van berichten, ECDSA-handtekeningen op ondersteunde moderne doelversies van .NET en configureerbare versleuteling en ontsleuteling van assertions.

De bedrijfsnaam ITfoxtec is gewijzigd in FoxIDs, maar de componenten behouden voorlopig de ITfoxtec naam als onderdeel van de componentnaam.

Support

Stel vragen op Stack Overflow en tag met 'itfoxtec-identity-saml2'.

Voor implementatiehulp of architectuuradvies kunt u mailen naar contact@foxids.com.

Pakket

Releases NuGet ITfoxtec Identity SAML 2.0 NuGet ITfoxtec Identity SAML 2.0 MVC NuGet ITfoxtec Identity SAML 2.0 MVC Core

Code en licentie

Code op GitHub Testvoorbeelden op GitHub Open-source licentie

Wanneer FoxIDs relevant is

Er zijn twee praktische routes. Gebruik de open-sourcebibliotheek wanneer SAML 2.0 direct in uw .NET-applicatie moet worden geïmplementeerd. Als de applicatie al OpenID Connect of WS-Federation ondersteunt, kan FoxIDs de SAML 2.0-integratie extern afhandelen terwijl de applicatie het bestaande protocol blijft gebruiken.

  • Laat applicaties OpenID Connect of WS-Federation blijven gebruiken terwijl FoxIDs de SAML 2.0-verbinding afhandelt
  • Beheer protocolvertaling, certificaten, metadata en partnerspecifieke federation-configuratie buiten de applicatie
  • Gebruik FoxIDs Cloud, self-hosted of hybride deployment afhankelijk van operationele vereisten
  • FoxIDs gebruikt ITfoxtec.Identity.Saml2 voor SAML 2.0-protocolafhandeling, waardoor de bibliotheek en bridge-optie technisch op elkaar zijn afgestemd
SAML 2.0 bridge-documentatie Praat met een expert Begin gratis

Geteste omgevingen

Het ITfoxtec Identity Saml2 pakket is getest op conformiteit met Microsoft Entra ID (Azure AD), AD FS, Azure AD B2C, de Deense NemLog-in3 (MitID), de Deense Context Handler (in het Deens Fælleskommunal Adgangsstyring) en vele andere IdP's en RP's.

ASP.NET MVC en ASP.NET Core MVC worden ondersteund door de ITfoxtec Identity SAML 2.0 MVC- en MVC Core-pakketten, die helpen om het ITfoxtec SAML 2.0-pakket te integreren in MVC- en ASP.NET Core MVC-applicaties.

Ondersteunde .NET versies

.NET 10.0 .NET 9.0 .NET 8.0 .NET 7.0 .NET 6.0 .NET Standard 2.1 .NET Framework 4.6.2 .NET Framework 4.8

Ondersteunde bindings

  • Redirect Binding
  • Post Binding
  • Artifact Binding

Bindings kunnen naar behoefte worden gebruikt voor:

  • Authn Request
  • Authn Response (SAML 2.0 Response)
  • Logout Request
  • Logout Response

Ondertekeningsalgoritmen

SHA1/SHA256/SHA384/SHA512 wordt ondersteund voor berichtondertekening.

RSA SHA1 RSA SHA256 RSA SHA384 RSA SHA512 RSA-PSS SHA256 ECDSA SHA256 ECDSA SHA384 ECDSA SHA512
Algoritme-URI's weergeven
  • RSA SHA1http://www.w3.org/2000/09/xmldsig#rsa-sha1
  • RSA SHA256http://www.w3.org/2001/04/xmldsig-more#rsa-sha256
  • RSA SHA384http://www.w3.org/2001/04/xmldsig-more#rsa-sha384
  • RSA SHA512http://www.w3.org/2001/04/xmldsig-more#rsa-sha512
  • RSA-PSS SHA256http://www.w3.org/2007/05/xmldsig-more#sha256-rsa-MGF1
  • ECDSA SHA256http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha256
  • ECDSA SHA384http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha384
  • ECDSA SHA512http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha512

Configureerbare encryptie

Assertion encryptie kan afzonderlijk worden geconfigureerd voor data encryptie en sleutel encryptie. Ondersteunde opties zijn AES-CBC, AES-GCM, RSA key transport en XML Encryption 1.1 RSA-OAEP met gevalideerde MGF-parameters.

Data
AES-CBC AES-GCM
Key
RSA 1.5 RSA-OAEP RSA-OAEP 1.1

Je kunt de SAML 2.0 tool gebruiken om tokens te decoderen en zelfondertekende certificaten te maken met de certificaattool.

Code

De getoonde code is slechts een selectie van de voorbeeldcode in GitHub.

Het ITfoxtec Identity Saml2-pakket wordt geïntegreerd in een ASP.NET Core MVC Relying Party (RP)-applicatie door configuratie in Startup en door een Auth Controller toe te voegen met de volgende methoden. De getoonde binding kan naar behoefte worden aangepast afhankelijk van de vereisten.

Daarnaast is het mogelijk om enkele optionele parameters in te stellen op de Saml2AuthnRequest en Saml2LogoutRequest. Op de Saml2AuthnRequest wordt bijvoorbeeld ForceAuthn ondersteund, waardoor de gebruiker gedwongen wordt om inloggegevens in te voeren, zelfs als er al een SSO context bestaat bij de Security Token Service (STS) / Identity Provider (IdP).


Voeg configuratie toe aan de ConfigureServices methode in Startup

Configuratie met IdP metadata.
services.BindConfig<Saml2Configuration>(Configuration, "Saml2", (serviceProvider, saml2Configuration) =>
{
    saml2Configuration.SigningCertificate = CertificateUtil.Load(AppEnvironment.MapToPhysicalFilePath(
        Configuration["Saml2:SigningCertificateFile"]), Configuration["Saml2:SigningCertificatePassword"]);
    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;
        saml2Configuration.SignatureValidationCertificates.AddRange(entityDescriptor.IdPSsoDescriptor.SigningCertificates);
    }
    else
    {
        throw new Exception("IdPSsoDescriptor not loaded from metadata.");
    }
    return saml2Configuration;
});
services.AddSaml2();
services.AddHttpClient();

Configuratie zonder metadata.
services.BindConfig<Saml2Configuration>(Configuration, "Saml2", (serviceProvider, saml2Configuration) =>
{
    saml2Configuration.SigningCertificate = CertificateUtil.Load(AppEnvironment.MapToPhysicalFilePath(
        Configuration["Saml2:SigningCertificateFile"]), Configuration["Saml2:SigningCertificatePassword"]);
    saml2Configuration.AllowedAudienceUris.Add(saml2Configuration.Issuer);

    saml2Configuration.SignatureValidationCertificates.Add(CertificateUtil.Load(AppEnvironment.MapToPhysicalFilePath(
        Configuration["Saml2:SignatureValidationCertificateFile"])));
    return saml2Configuration;
});
services.AddSaml2();   

Login methode in de Auth Controller

[Route("Login")]
public IActionResult Login(string returnUrl = null)
{
    var binding = new Saml2RedirectBinding();
    binding.SetRelayStateQuery(new Dictionary<string, string> 
        { { relayStateReturnUrl, returnUrl ?? Url.Content("~/") } });

    return binding.Bind(new Saml2AuthnRequest(config)).ToActionResult();
}

AssertionConsumerService methode in de Auth Controller

Na een geslaagde of mislukte aanmelding ontvangt de ACS-methode de respons.
[Route("AssertionConsumerService")]
public async Task<IActionResult> AssertionConsumerService()
{       
    var httpRequest = Request.ToGenericHttpRequest(validate: true);
    var saml2AuthnResponse = new Saml2AuthnResponse(config);

    httpRequest.Binding.ReadSamlResponse(httpRequest, saml2AuthnResponse);
    if (saml2AuthnResponse.Status != Saml2StatusCodes.Success)
    {
        throw new AuthenticationException($"SAML Response status: {saml2AuthnResponse.Status}");
    }
    httpRequest.Binding.Unbind(httpRequest, saml2AuthnResponse);
    await saml2AuthnResponse.CreateSessionAsync(HttpContext,
        claimsTransform: (claimsPrincipal) => Task.FromResult(ClaimsTransform.Transform(claimsPrincipal)));

    var relayStateQuery = httpRequest.Binding.GetRelayStateQuery();
    var returnUrl = relayStateQuery.ContainsKey(relayStateReturnUrl) ? relayStateQuery[relayStateReturnUrl] : Url.Content("~/");
    return Redirect(returnUrl);
}

Logout methode in de Auth Controller

[HttpPost("Logout")]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Logout()
{
    if (!User.Identity.IsAuthenticated)
    {
        return Redirect(Url.Content("~/"));
    }

    var binding = new Saml2PostBinding();
    var saml2LogoutRequest = await new Saml2LogoutRequest(config, User).DeleteSession(HttpContext);
    return binding.Bind(saml2LogoutRequest).ToActionResult();
}

LoggedOut methode in de Auth Controller

Na een geslaagde of mislukte afmelding ontvangt de LoggedOut-methode de respons.
[Route("LoggedOut")]
public IActionResult LoggedOut()
{
    var httpRequest = Request.ToGenericHttpRequest(validate: true);
    httpRequest.Binding.Unbind(httpRequest, new Saml2LogoutResponse(config));

    return Redirect(Url.Content("~/"));
}

SingleLogout methode in de Auth Controller

Ontvangt een verzoek voor Single Logout en stuurt een respons.
[Route("SingleLogout")]
public async Task<IActionResult> SingleLogout()
{
    Saml2StatusCodes status;
    var httpRequest = Request.ToGenericHttpRequest(validate: true);
    var logoutRequest = new Saml2LogoutRequest(config, User);
    try
    {
        httpRequest.Binding.Unbind(httpRequest, logoutRequest);
        status = Saml2StatusCodes.Success;
        await logoutRequest.DeleteSession(HttpContext);
    }
    catch (Exception exc)
    {
        // log exception
        Debug.WriteLine("SingleLogout error: " + exc.ToString());
        status = Saml2StatusCodes.RequestDenied;
    }

    var responseBinding = new Saml2PostBinding();
    responseBinding.RelayState = httpRequest.Binding.RelayState;
    var saml2LogoutResponse = new Saml2LogoutResponse(config)
    {
        InResponseToAsString = logoutRequest.IdAsString,
        Status = status,
    };
    return responseBinding.Bind(saml2LogoutResponse).ToActionResult();
}
FoxIDs logo

Ontwikkeld in Denemarken. Gehost in Europa.

Ontwikkelaars

  • Documentatie
  • Artikelen
  • Releases
  • Cloud status

Product

  • Prijzen
  • Diensten
  • Uitrol
  • Compliance
  • Trust Center

Bedrijf

  • Over
  • SKI leverancier
  • Neem contact op

Juridisch

  • Servicevoorwaarden
  • Voorwaarden voor self-hosting
  • AVG en gegevensbeschermingsovereenkomst
  • Privacy- en cookiebeleid
© 2026 FoxIDs, versie 2.15.19
GitHub LinkedIn

Cookiekeuzes

FoxIDs gebruikt noodzakelijke cookies om de website te laten werken. Kies Alles accepteren om ook analytische cookies toe te staan die ons helpen het gebruik van de website te begrijpen en de website te verbeteren, of Alles weigeren om alleen noodzakelijke cookies te gebruiken. U kunt uw keuze op elk moment wijzigen in ons privacy- en cookiebeleid.

Lees ons privacy- en cookiebeleid