Skip to content

Disabling credentials erasure on custom AuthenticationManager is not working #15683

Closed
@kmartin88

Description

@kmartin88

Describe the bug
In the documentation there is an example on how to customize the AuthenticationManager:
https://docs.spring.io/spring-security/reference/servlet/authentication/passwords/index.html#customize-global-authentication-manager (below "Publish AuthenticationManager bean for Spring Security").
Even though eraseCredentialsAfterAuthentication is set to false, the credentials get erased. They seem to get erased by another ProviderManager which has an AnonymousAuthenticationProvider.

To Reproduce
Create an empty Spring Boot Project with Spring Security and Spring Web MVC, create a @RestController and a SecurityConfig like in the example. The RestController should have a method which autowires the Authentication and returns the credentials of this Authentication object. Then you call the controller with user credentials and see that the credentials are empty/null.

Expected behavior
The password of the user should be returned when calling the controller.

Metadata

Metadata

Assignees

Labels

in: docsAn issue in Documentation or samplestype: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions