Skip to content

Commit 8c92edd

Browse files
committed
Revert "Add Registration to Saml2Authentication"
This reverts commit efe42b9.
1 parent 55047fd commit 8c92edd

File tree

4 files changed

+5
-50
lines changed

4 files changed

+5
-50
lines changed

docs/manual/src/docs/asciidoc/_includes/servlet/saml2/saml2-login.adoc

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ where
107107
* `https://idp.example.com/issuer` is the value contained in the `Issuer` attribute of the SAML responses that the identity provider will issue
108108
* `classpath:idp.crt` is the location on the classpath for the identity provider's certificate for verifying SAML responses, and
109109
* `https://idp.example.com/issuer/sso` is the endpoint where the identity provider is expecting `AuthnRequest` s.
110-
* `adfs` is <<servlet-saml2login-relyingpartyregistrationid, an arbitrary identifier you choose>>
111110

112111
And that's it!
113112

@@ -191,7 +190,6 @@ image:{icondir}/number_10.png[] And finally, it takes the `NameID` from the firs
191190
Then, it places that principal and the authorities into a `Saml2Authentication`.
192191

193192
The resulting `Authentication#getPrincipal` is a Spring Security `Saml2AuthenticatedPrincipal` object, and `Authentication#getName` maps to the first assertion's `NameID` element.
194-
`Saml2Authentication#getRelyingPartyRegistrationId` holds the <<servlet-saml2login-relyingpartyregistrationid,identifier to the associated `RelyingPartyRegistration`>>.
195193

196194
[[servlet-saml2login-opensaml-customization]]
197195
==== Customizing OpenSAML Configuration
@@ -232,7 +230,7 @@ static {
232230
authnRequest.setForceAuthN(true);
233231
}
234232
}
235-
233+
236234
factory.getMarshallerFactory().registerMarshaller(AuthnRequest.DEFAULT_ELEMENT_NAME, marshaller);
237235
});
238236
}
@@ -344,10 +342,6 @@ public RelyingPartyRegistrationRepository relyingPartyRegistrations() {
344342
----
345343
====
346344

347-
[[servlet-saml2login-relyingpartyregistrationid]]
348-
[NOTE]
349-
The `registrationId` is an arbitrary value that you choose for differentiating between registrations.
350-
351345
Or you can provide each detail manually, as you can see below:
352346

353347
.Relying Party Registration Repository Manual Configuration

saml2/saml2-service-provider/core/src/main/java/org/springframework/security/saml2/provider/service/authentication/Saml2Authentication.java

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import org.springframework.security.core.AuthenticatedPrincipal;
2323
import org.springframework.security.core.Authentication;
2424
import org.springframework.security.core.GrantedAuthority;
25-
import org.springframework.security.saml2.provider.service.registration.RelyingPartyRegistration;
2625
import org.springframework.util.Assert;
2726

2827
/**
@@ -42,40 +41,14 @@ public class Saml2Authentication extends AbstractAuthenticationToken {
4241

4342
private final String saml2Response;
4443

45-
private final String relyingPartyRegistrationId;
46-
47-
/**
48-
* Construct a {@link Saml2Authentication} using the provided parameters
49-
* @param principal the logged in user
50-
* @param saml2Response the SAML 2.0 response used to authenticate the user
51-
* @param authorities the authorities for the logged in user
52-
* @deprecated Use
53-
* {@link #Saml2Authentication(AuthenticatedPrincipal, String, Collection, String)}
54-
*/
55-
@Deprecated
5644
public Saml2Authentication(AuthenticatedPrincipal principal, String saml2Response,
5745
Collection<? extends GrantedAuthority> authorities) {
58-
this(principal, saml2Response, authorities, null);
59-
}
60-
61-
/**
62-
* Construct a {@link Saml2Authentication} using the provided parameters
63-
* @param principal the logged in user
64-
* @param saml2Response the SAML 2.0 response used to authenticate the user
65-
* @param authorities the authorities for the logged in user
66-
* @param relyingPartyRegistrationId the
67-
* {@link RelyingPartyRegistration#getRegistrationId} associated with this user
68-
* @since 5.5
69-
*/
70-
public Saml2Authentication(AuthenticatedPrincipal principal, String saml2Response,
71-
Collection<? extends GrantedAuthority> authorities, String relyingPartyRegistrationId) {
7246
super(authorities);
7347
Assert.notNull(principal, "principal cannot be null");
7448
Assert.hasText(saml2Response, "saml2Response cannot be null");
7549
this.principal = principal;
7650
this.saml2Response = saml2Response;
7751
setAuthenticated(true);
78-
this.relyingPartyRegistrationId = relyingPartyRegistrationId;
7952
}
8053

8154
@Override
@@ -96,14 +69,4 @@ public Object getCredentials() {
9669
return getSaml2Response();
9770
}
9871

99-
/**
100-
* Get the registration id associated with the {@link RelyingPartyRegistration} that
101-
* this user belongs to
102-
* @return the relying party registration id
103-
* @since 5.5
104-
*/
105-
public String getRelyingPartyRegistrationId() {
106-
return this.relyingPartyRegistrationId;
107-
}
108-
10972
}

saml2/saml2-service-provider/opensaml3/src/main/java/org/springframework/security/saml2/provider/service/authentication/OpenSamlAuthenticationProvider.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -425,8 +425,7 @@ public static Converter<ResponseToken, Saml2Authentication> createDefaultRespons
425425
String username = assertion.getSubject().getNameID().getValue();
426426
Map<String, List<Object>> attributes = getAssertionAttributes(assertion);
427427
return new Saml2Authentication(new DefaultSaml2AuthenticatedPrincipal(username, attributes),
428-
token.getSaml2Response(), Collections.singleton(new SimpleGrantedAuthority("ROLE_USER")),
429-
responseToken.token.getRelyingPartyRegistration().getRegistrationId());
428+
token.getSaml2Response(), Collections.singleton(new SimpleGrantedAuthority("ROLE_USER")));
430429
};
431430
}
432431

@@ -628,8 +627,8 @@ private Converter<ResponseToken, Saml2Authentication> createCompatibleResponseAu
628627
String username = assertion.getSubject().getNameID().getValue();
629628
Map<String, List<Object>> attributes = getAssertionAttributes(assertion);
630629
return new Saml2Authentication(new DefaultSaml2AuthenticatedPrincipal(username, attributes),
631-
token.getSaml2Response(), this.authoritiesMapper.mapAuthorities(getAssertionAuthorities(assertion)),
632-
responseToken.token.getRelyingPartyRegistration().getRegistrationId());
630+
token.getSaml2Response(),
631+
this.authoritiesMapper.mapAuthorities(getAssertionAuthorities(assertion)));
633632
};
634633
}
635634

saml2/saml2-service-provider/opensaml4/src/main/java/org/springframework/security/saml2/provider/service/authentication/OpenSaml4AuthenticationProvider.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,8 +365,7 @@ public static Converter<ResponseToken, Saml2Authentication> createDefaultRespons
365365
String username = assertion.getSubject().getNameID().getValue();
366366
Map<String, List<Object>> attributes = getAssertionAttributes(assertion);
367367
return new Saml2Authentication(new DefaultSaml2AuthenticatedPrincipal(username, attributes),
368-
token.getSaml2Response(), AuthorityUtils.createAuthorityList("ROLE_USER"),
369-
responseToken.token.getRelyingPartyRegistration().getRegistrationId());
368+
token.getSaml2Response(), AuthorityUtils.createAuthorityList("ROLE_USER"));
370369
};
371370
}
372371

0 commit comments

Comments
 (0)