aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/service/security/JuickUserDetailsService.java
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2020-03-20 15:18:29 +0300
committerGravatar Vitaly Takmazov2020-03-20 15:18:29 +0300
commitc3d889c92d8eacfd93bab2dbc2e9a4db61d9aae7 (patch)
tree1f9d64442f0ef7acf9f88840f9320b82bc605c7f /src/main/java/com/juick/service/security/JuickUserDetailsService.java
parentbdef56b6fc58dc3554171f3e14ac821655cb8ddd (diff)
enable spring boot actuator for admin users
Diffstat (limited to 'src/main/java/com/juick/service/security/JuickUserDetailsService.java')
-rw-r--r--src/main/java/com/juick/service/security/JuickUserDetailsService.java7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/main/java/com/juick/service/security/JuickUserDetailsService.java b/src/main/java/com/juick/service/security/JuickUserDetailsService.java
index a62bdadd..da222539 100644
--- a/src/main/java/com/juick/service/security/JuickUserDetailsService.java
+++ b/src/main/java/com/juick/service/security/JuickUserDetailsService.java
@@ -21,11 +21,14 @@ import com.juick.model.User;
import com.juick.service.UserService;
import com.juick.service.security.entities.JuickUser;
import org.apache.commons.lang3.StringUtils;
+import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.util.Assert;
+import java.util.List;
+
/**
* Created by aalexeev on 11/28/16.
*/
@@ -46,7 +49,9 @@ public class JuickUserDetailsService implements UserDetailsService {
if (!user.isAnonymous()) {
user.setAuthHash(userService.getHashByUID(user.getUid()));
- return new JuickUser(user);
+ List<GrantedAuthority> authorities = userService.isAdminUser(user) ?
+ JuickUser.ADMIN_AUTHORITY : JuickUser.USER_AUTHORITY;
+ return new JuickUser(user, authorities);
}
throw new UsernameNotFoundException("The username " + username + " is not found");