Skip to content

Commit

Permalink
Keep original authentication object when possible
Browse files Browse the repository at this point in the history
  • Loading branch information
fdaugan committed Feb 12, 2024
1 parent a3c8643 commit dfea75b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<groupId>org.ligoj.plugin</groupId>
<artifactId>plugin-id</artifactId>
<version>2.1.8-SNAPSHOT</version>
<version>2.2.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Ligoj - Plugin ID</name>
<url>https://github.com/ligoj/plugin-id</url>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ public Authentication authenticate(final Authentication authentication, final St
// Authenticate the user
final var user = repository.authenticate(authentication.getName(), (String) authentication.getCredentials());
if (user != null) {
if (primary && user.getId().equals(authentication.getName())) {
// Return the provided authentication
return authentication;
}
// Return a new authentication based on resolved application user
return primary ? new UsernamePasswordAuthenticationToken(user.getId(), null)
: new UsernamePasswordAuthenticationToken(toApplicationUser(repository, authentication), null);
Expand Down

0 comments on commit dfea75b

Please sign in to comment.