diff --git a/pom.xml b/pom.xml
index 01a96442ba..f5283f043f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -44,12 +44,12 @@
${datasource.ohdsi.schema}.BATCH_
ISOLATION_READ_COMMITTED
-
default
+
43200
http://localhost:8080
8443
- false
+ true
http://localhost:8080/Atlas/#/welcome
http://localhost:8084/WebAPI/user/oauth/callback
diff --git a/src/main/java/org/ohdsi/webapi/service/UserService.java b/src/main/java/org/ohdsi/webapi/service/UserService.java
index be0a0cf838..59823c9416 100644
--- a/src/main/java/org/ohdsi/webapi/service/UserService.java
+++ b/src/main/java/org/ohdsi/webapi/service/UserService.java
@@ -9,12 +9,14 @@
import java.util.Set;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
+import javax.ws.rs.DefaultValue;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import org.ohdsi.webapi.shiro.Entities.PermissionEntity;
import org.ohdsi.webapi.shiro.Entities.RoleEntity;
@@ -171,8 +173,9 @@ public Role updateRole(@PathParam("roleId") Long id, Role role) throws Exception
@GET
@Path("role")
@Produces(MediaType.APPLICATION_JSON)
- public ArrayList getRoles() {
- Iterable roleEntities = this.authorizer.getRoles();
+ public ArrayList getRoles(
+ @DefaultValue("false") @QueryParam("include_personal") boolean includePersonalRoles) {
+ Iterable roleEntities = this.authorizer.getRoles(includePersonalRoles);
ArrayList roles = convertRoles(roleEntities);
return roles;
}
diff --git a/src/main/java/org/ohdsi/webapi/shiro/Entities/UserRepository.java b/src/main/java/org/ohdsi/webapi/shiro/Entities/UserRepository.java
index 446737f834..7d62cab027 100644
--- a/src/main/java/org/ohdsi/webapi/shiro/Entities/UserRepository.java
+++ b/src/main/java/org/ohdsi/webapi/shiro/Entities/UserRepository.java
@@ -1,5 +1,6 @@
package org.ohdsi.webapi.shiro.Entities;
+import java.util.Set;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
@@ -10,6 +11,9 @@ public interface UserRepository extends CrudRepository {
public UserEntity findByLogin(String login);
+ @Query("SELECT u.login FROM UserEntity u")
+ public Set getUserLogins();
+
@Query("from UserEntity where login = 'testLogin'")
public UserEntity getTestUser();
}
diff --git a/src/main/java/org/ohdsi/webapi/shiro/PermissionManager.java b/src/main/java/org/ohdsi/webapi/shiro/PermissionManager.java
index 0204a8e050..d9f4ceb491 100644
--- a/src/main/java/org/ohdsi/webapi/shiro/PermissionManager.java
+++ b/src/main/java/org/ohdsi/webapi/shiro/PermissionManager.java
@@ -1,6 +1,8 @@
package org.ohdsi.webapi.shiro;
import java.security.Principal;
+import java.util.Arrays;
+import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
@@ -93,8 +95,21 @@ public void removeUserFromRole(String roleName, String login) throws Exception {
this.userRoleRepository.delete(userRole);
}
- public Iterable getRoles() {
- return this.roleRepository.findAll();
+ public Iterable getRoles(boolean includePersonalRoles) {
+ Iterable roles = this.roleRepository.findAll();
+ if (includePersonalRoles) {
+ return roles;
+ }
+
+ Set logins = this.userRepository.getUserLogins();
+ HashSet filteredRoles = new HashSet<>();
+ for (RoleEntity role : roles) {
+ if (!logins.contains(role.getName())) {
+ filteredRoles.add(role);
+ }
+ }
+
+ return filteredRoles;
}
public AuthorizationInfo getAuthorizationInfo(final String login) {