• +45 4949 9091
  • Support
  • Sprachen
    • Sprachen
    • English
    • Dansk
    • Svenska
    • Norsk
    • Deutsch
    • Nederlands
    • Polski
    • Français
    • Español
    • Italiano
    • Português
  • Registrieren
  • Anmelden
FoxIDs Logo
  • Plattform
    • Bereitstellung
    • Multi-Tenant
    • Identitätslogik
    • Compliance
  • Anwendungsfälle
    • Überblick
    • Kunden
    • Mitarbeitende
    • Partner
    • Kundengeschichten
  • Services
  • Preise
  • Dokumentation & Tools
    • Dokumentation
    • Artikel
    • JWT-Tool
    • SAML 2.0-Tool
    • Zertifikat-Tool
  • Kontakt
  • Registrieren
  • Anmelden

ITfoxtec Identity SAML 2.0

Das Open-Source-Paket ITfoxtec Identity Saml2 fügt SAML 2.0- / SAML-P-Unterstützung für .NET-Anwendungen hinzu, die als Identity Provider (IdP), Service Provider (SP) oder Relying Party (RP) arbeiten müssen.

Das Paket ITfoxtec Identity Saml2 eignet sich, wenn SAML 2.0 direkt in die Anwendung integriert werden soll. Es unterstützt Anmeldung, Abmeldung und Single Logout mit SAML 2.0, Metadaten, Redirect Binding, POST Binding, Artifact Binding, Signierung und Validierung von Nachrichten, ECDSA-Signaturen auf unterstützten modernen Zielversionen von .NET sowie konfigurierbare Verschlüsselung und Entschlüsselung von Assertions.

Der Firmenname ITfoxtec wurde geändert zu FoxIDs, aber die Komponenten behalten den ITfoxtec Namen vorerst als Teil des Komponentennamens bei.

Support

Stellen Sie Fragen auf Stack Overflow und taggen Sie mit 'itfoxtec-identity-saml2'.

Für Unterstützung bei der Implementierung oder Architekturberatung schreiben Sie an contact@foxids.com.

Paket

Veröffentlichungen NuGet ITfoxtec Identity SAML 2.0 NuGet ITfoxtec Identity SAML 2.0 MVC NuGet ITfoxtec Identity SAML 2.0 MVC Core

Code und Lizenz

Code auf GitHub Testbeispiele auf GitHub Open-Source-Lizenz

Wann FoxIDs relevant ist

Es gibt zwei praktische Wege. Verwenden Sie die Open-Source-Bibliothek, wenn SAML 2.0 direkt in Ihrer .NET-Anwendung implementiert werden soll. Wenn die Anwendung bereits OpenID Connect oder WS-Federation unterstützt, kann FoxIDs die SAML 2.0-Integration extern übernehmen, während die Anwendung ihr bestehendes Protokoll weiter nutzt.

  • Anwendungen bei OpenID Connect oder WS-Federation belassen, während FoxIDs die SAML 2.0-Verbindung übernimmt
  • Protokollübersetzung, Zertifikate, Metadaten und partnerspezifische Federation-Konfiguration außerhalb der Anwendung betreiben
  • FoxIDs Cloud, self-hosted oder hybrid nutzen, je nach betrieblichen Anforderungen
  • FoxIDs verwendet ITfoxtec.Identity.Saml2 für die SAML 2.0-Protokollverarbeitung, sodass Bibliothek und Bridge-Option technisch aufeinander abgestimmt sind
SAML 2.0 Bridge-Dokumentation Mit einem Experten sprechen Kostenlos starten

Getestete Umgebungen

Das ITfoxtec Identity Saml2 Paket ist auf Konformität mit Microsoft Entra ID (Azure AD), AD FS, Azure AD B2C, dem dänischen NemLog-in3 (MitID), dem dänischen Context Handler (auf Dänisch Fælleskommunal Adgangsstyring) und vielen weiteren IdPs und RPs getestet.

ASP.NET MVC und ASP.NET Core MVC werden von den ITfoxtec Identity SAML 2.0 MVC- und MVC Core-Paketen unterstützt, die helfen, das ITfoxtec SAML 2.0-Paket in MVC- und ASP.NET Core MVC-Anwendungen zu integrieren.

Unterstützte .NET Versionen

.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

Unterstützte Bindings

  • Redirect Binding
  • Post Binding
  • Artifact Binding

Die Bindings können je nach Bedarf verwendet werden für:

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

Signaturalgorithmen

SHA1/SHA256/SHA384/SHA512 wird für Nachrichtensignierung unterstützt.

RSA SHA1 RSA SHA256 RSA SHA384 RSA SHA512 RSA-PSS SHA256 ECDSA SHA256 ECDSA SHA384 ECDSA SHA512
Algorithmus-URIs anzeigen
  • 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

Konfigurierbare Verschlüsselung

Assertion Verschlüsselung kann getrennt für Datenverschlüsselung und Schlüsselverschlüsselung konfiguriert werden. Unterstützte Optionen umfassen AES-CBC, AES-GCM, RSA Key Transport und XML Encryption 1.1 RSA-OAEP mit validierten MGF-Parametern.

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

Sie können das SAML 2.0 Tool verwenden, um Tokens zu decodieren und mit dem Zertifikat Tool selbstsignierte Zertifikate zu erstellen.

Code

Der gezeigte Code ist nur eine Auswahl des Beispielcodes in GitHub.

Das Paket ITfoxtec Identity Saml2 wird in eine ASP.NET Core MVC Relying Party (RP)-Anwendung integriert, indem es in Startup konfiguriert und ein Auth Controller mit den folgenden Methoden hinzugefügt wird. Das gezeigte Binding kann je nach Anforderungen geändert werden.

Außerdem ist es möglich, einige optionale Parameter für Saml2AuthnRequest und Saml2LogoutRequest zu setzen. Bei Saml2AuthnRequest wird z. B. ForceAuthn unterstützt, was den Benutzer zwingt, Anmeldeinformationen einzugeben, auch wenn bereits ein SSO Kontext beim Security Token Service (STS) / Identity Provider (IdP) existiert.


Fügen Sie die Konfiguration zur ConfigureServices Methode in Startup hinzu

Konfiguration mit IdP Metadaten.
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();

Konfiguration ohne Metadaten.
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 im 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 im Auth Controller

Nach einer erfolgreichen oder fehlgeschlagenen Anmeldung erhält die ACS-Methode die Antwort.
[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 im 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 im Auth Controller

Nach einer erfolgreichen oder fehlgeschlagenen Abmeldung erhält die LoggedOut-Methode die Antwort.
[Route("LoggedOut")]
public IActionResult LoggedOut()
{
    var httpRequest = Request.ToGenericHttpRequest(validate: true);
    httpRequest.Binding.Unbind(httpRequest, new Saml2LogoutResponse(config));

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

SingleLogout Methode im Auth Controller

Empfängt eine Anfrage zum Single Logout und sendet eine Antwort.
[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

In Dänemark entwickelt. In Europa gehostet.

Entwickler

  • Dokumentation
  • Artikel
  • Veröffentlichungen
  • Cloud-Status

Produkt

  • Preise
  • Services
  • Bereitstellung
  • Compliance
  • Vertrauenszentrum

Unternehmen

  • Über
  • SKI-Lieferant
  • Kontakt

Rechtliches

  • Nutzungsbedingungen
  • Bedingungen für Self-Hosting
  • DSGVO und Datenschutzvereinbarung
  • Datenschutz- und Cookie-Richtlinie
© 2026 FoxIDs, Version 2.15.19
GitHub LinkedIn

Cookie-Auswahl

FoxIDs verwendet notwendige Cookies, damit die Website funktioniert. Wählen Sie Alle akzeptieren, um zusätzlich Analyse-Cookies zuzulassen, die uns helfen, die Nutzung der Website zu verstehen und sie zu verbessern, oder Alle ablehnen, um nur notwendige Cookies zu verwenden. Sie können Ihre Auswahl jederzeit in unserer Datenschutz- und Cookie-Richtlinie ändern.

Datenschutz- und Cookie-Richtlinie lesen