Ich habe ein Problem mit der Integration meiner Entra in meine Spring -Boot -Anwendung für SSO mit SAML. Meine Umgebung ist Spring Boot 3.4.3, Java 17. Ich habe einen Benutzer auf Entra erstellt, um SSO zu implementieren, und der Anmeldeteil funktioniert gut, aber wenn er von der Antwort -URL von der Antwort -URL in meine Anwendung umgeleitet wird, sollte die Spring Security das Authentifizierungsobjekt mit geeigneten Werten erstellen, in denen ich sie als Null empfehle. Ich habe angepasstes Authentifizierungsobjekt mit samlresponse aus den von Debugger validierten Params erstellt, die ich durch Debugger validiert habe, aber das SAML2AuthenticationToken, wenn er erstellt wurde, hat erneut Nullwerte.
Ich habe ein [url=viewtopic.php?t=20324]Problem[/url] mit der Integration meiner Entra in meine Spring -Boot -Anwendung für SSO mit SAML. Meine Umgebung ist Spring Boot 3.4.3, Java 17. Ich habe einen Benutzer auf Entra erstellt, um SSO zu implementieren, und der Anmeldeteil funktioniert gut, aber wenn er von der Antwort -URL von der Antwort -URL in meine Anwendung umgeleitet wird, sollte die Spring Security das Authentifizierungsobjekt mit geeigneten Werten erstellen, in denen ich sie als Null empfehle. Ich habe angepasstes Authentifizierungsobjekt mit samlresponse aus den von Debugger validierten Params erstellt, die ich durch Debugger validiert habe, aber das SAML2AuthenticationToken, wenn er erstellt wurde, hat erneut Nullwerte.[code]import jakarta.servlet.http.HttpServletRequest; import org.opensaml.saml.saml2.core.Response; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.core.Authentication; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.saml2.provider.service.authentication.AbstractSaml2AuthenticationRequest; import org.springframework.security.saml2.provider.service.authentication.Saml2AuthenticationToken; import org.springframework.security.saml2.provider.service.authentication.Saml2AuthenticatedPrincipal; import org.springframework.security.saml2.provider.service.registration.RelyingPartyRegistration; import org.springframework.security.saml2.provider.service.registration.RelyingPartyRegistrationRepository; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.web.bind.annotation.*;
import java.util.Base64; import java.util.List;
@RestController @RequestMapping("/saml") public class SamlController {
@PostMapping("/acs") public String processSamlResponse(HttpServletRequest request) throws Exception { // Get the SAML Response from the request String samlResponseFromRequest = request.getParameter("SAMLResponse");
if (samlResponseFromRequest == null) { return "No SAML Response received"; }
// Decode the Base64 encoded SAML response String decodedResponse = new String(Base64.getDecoder().decode(samlResponseFromRequest));
// Delegate the response parsing and authentication to Spring Security's built-in mechanism // Spring Security will automatically create the Saml2AuthenticationToken Saml2AuthenticationToken token = parseSamlResponse(decodedResponse);
if (token.getPrincipal() == null) { return "SAML response parsing failed, no principal found."; }
// Set the Authentication object in the SecurityContext Authentication authentication = createAuthentication(token); SecurityContextHolder.getContext().setAuthentication(authentication);
// Process the authentication if (authentication != null) { Saml2AuthenticatedPrincipal principal = (Saml2AuthenticatedPrincipal) authentication.getPrincipal();
// Get user details from the principal String name = principal.getName(); List emailList = principal.getAttributes().get("email"); String email = (emailList != null && !emailList.isEmpty()) ? emailList.get(0).toString() : "Email not found";
private Saml2AuthenticationToken parseSamlResponse(String samlResponse) throws Exception { // Spring Security automatically parses the SAML response and creates a Saml2AuthenticationToken // The token will have the principal and authorities populated if the response is valid Saml2AuthenticationToken token = new Saml2AuthenticationToken(repository.findByRegistrationId("microsoft"), samlResponse);
// Spring Security's internal filters should handle the population of the principal and authorities return token; // return OpenSamlUtils.parseResponse(samlResponse); }
Ich habe mir Microsofts Beispiel „Secure an ASP.NET Core Blazor Web App with Microsoft Entra ID“ / GitHub angesehen.
In program.cs ist die Authentifizierung wie folgt konfiguriert....
Ich arbeite an der Integration der SAML -Authentifizierung in die Microsoft -Graph -API, um ein OAuth2 -Zugriffstoken zu erhalten. Mein Ziel ist es, den Authentifizierungsprozess abzuschließen, ohne...
Ich habe ein Problem mit Routing und Authentifizierung. Ich habe auch die öffentliche \ simpleSeMlphp \ config \ config.php Datei
konfiguriert, wenn ich diese Anmeldemugel versuche. Es gibt mir ein...
Ich versuche, die SAML -Authentifizierung mit der Cyberark -Passwort -Vault -Anwendung durchzuführen. Ich erhielt diesen PowerShell -Code von Cyberark für die Durchführung dieser SAML...