Revert "Merge branch 'builder-enhancements'"
This reverts commit95644fb73c, reversing changes made tofbf7bb3be1. Reverting this commit will allow us more time to consider the ideal way to add this support to the public API.
This commit is contained in:
+2
-4
@@ -8,7 +8,6 @@ import org.springframework.security.authentication.TestingAuthenticationToken;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.security.authentication.ott.OneTimeTokenAuthentication;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.BuildableAuthentication;
|
||||
import org.springframework.security.core.authority.AuthorityUtils;
|
||||
import org.springframework.security.core.authority.FactorGrantedAuthority;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
@@ -31,9 +30,8 @@ public class CopyAuthoritiesTests {
|
||||
// tag::springSecurity[]
|
||||
Authentication lastestResult = authenticationManager.authenticate(authenticationRequest);
|
||||
Authentication previousResult = SecurityContextHolder.getContext().getAuthentication();
|
||||
if (previousResult != null && previousResult.isAuthenticated() &&
|
||||
lastestResult instanceof BuildableAuthentication buildable) {
|
||||
lastestResult = buildable.toBuilder()
|
||||
if (previousResult != null && previousResult.isAuthenticated()) {
|
||||
lastestResult = lastestResult.toBuilder()
|
||||
.authorities((a) -> a.addAll(previous.getAuthorities()))
|
||||
.build();
|
||||
}
|
||||
|
||||
+1
-2
@@ -10,7 +10,6 @@ import org.springframework.security.authentication.TestingAuthenticationToken
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken
|
||||
import org.springframework.security.authentication.ott.OneTimeTokenAuthentication
|
||||
import org.springframework.security.core.Authentication
|
||||
import org.springframework.security.core.BuildableAuthentication
|
||||
import org.springframework.security.core.authority.AuthorityUtils
|
||||
import org.springframework.security.core.authority.FactorGrantedAuthority
|
||||
import org.springframework.security.core.context.SecurityContextHolder
|
||||
@@ -29,7 +28,7 @@ class CopyAuthoritiesTests {
|
||||
// tag::springSecurity[]
|
||||
var latestResult: Authentication = authenticationManager.authenticate(authenticationRequest)
|
||||
val previousResult = SecurityContextHolder.getContext().authentication;
|
||||
if (previousResult?.isAuthenticated == true && latestResult is BuildableAuthentication) {
|
||||
if (previousResult?.isAuthenticated == true) {
|
||||
latestResult = latestResult.toBuilder().authorities { a ->
|
||||
a.addAll(previousResult.authorities)
|
||||
}.build()
|
||||
|
||||
Reference in New Issue
Block a user