Skip to content
Snippets Groups Projects
Commit 84689aa6 authored by Daniel Gerhardt's avatar Daniel Gerhardt
Browse files

Correctly state guest authentication

The API returned "ldap" instead of "guest" for guest authentication
before.
parent 69c939ab
Branches
Tags
No related merge requests found
......@@ -18,6 +18,7 @@ public class User implements Serializable {
public static final String THM = "thm";
public static final String LDAP = "ldap";
public static final String ANONYMOUS = "anonymous";
public static final String GUEST = "guest";
private static final long serialVersionUID = 1L;
private String username;
......
......@@ -21,6 +21,7 @@ import org.springframework.security.authentication.AnonymousAuthenticationToken;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.cas.authentication.CasAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;
......@@ -106,6 +107,9 @@ public class UserService implements IUserService {
} else if (authentication instanceof UsernamePasswordAuthenticationToken) {
UsernamePasswordAuthenticationToken token = (UsernamePasswordAuthenticationToken) authentication;
user = new User(token);
if (authentication.getAuthorities().contains(new SimpleGrantedAuthority("ROLE_GUEST"))) {
user.setType(User.GUEST);
}
}
if (user == null || user.getUsername().equals("anonymous")) {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment