File tree Expand file tree Collapse file tree
src/main/java/eu/openanalytics/containerproxy/service Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -103,6 +103,22 @@ public String[] getAdminGroups() {
103103
104104 return adminGroups .toArray (new String [adminGroups .size ()]);
105105 }
106+
107+ public String [] getAdminUsers () {
108+ Set <String > adminUsers = new HashSet <>();
109+
110+ // Support for old, non-array notation
111+ String singleUser = environment .getProperty ("proxy.admin-users" );
112+ if (singleUser != null && !singleUser .isEmpty ()) adminUsers .add (singleUser );
113+
114+ for (int i =0 ;; i ++) {
115+ String userName = environment .getProperty (String .format ("proxy.admin-users[%s]" , i ));
116+ if (userName == null || userName .isEmpty ()) break ;
117+ adminUsers .add (userName );
118+ }
119+
120+ return adminUsers .toArray (new String [adminUsers .size ()]);
121+ }
106122
107123 public String [] getGroups () {
108124 return getGroups (getCurrentAuth ());
@@ -125,9 +141,18 @@ public boolean isAdmin() {
125141 }
126142
127143 public boolean isAdmin (Authentication auth ) {
144+ if (!authBackend .hasAuthorization ()) {
145+ return false ;
146+ }
147+
128148 for (String adminGroup : getAdminGroups ()) {
129149 if (isMember (auth , adminGroup )) return true ;
130150 }
151+
152+ String userName = getUserId (auth );
153+ for (String adminUser : getAdminUsers ()) {
154+ if (userName != null && userName .equals (adminUser )) return true ;
155+ }
131156 return false ;
132157 }
133158
You can’t perform that action at this time.
0 commit comments