Skip to content

Commit

Permalink
SecurityContext.allowExecuteAdminProcedure is changing in 4.3 to prov…
Browse files Browse the repository at this point in the history
…ide more information than just true / false. Update to reflect this. I haven't done so, but it would be possible to use this to provide a better error message if this is desirable.
  • Loading branch information
mnd999 committed Jun 11, 2021
1 parent 0a89345 commit 8d49d87
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions core/src/main/java/apoc/util/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -659,8 +659,15 @@ public static void logErrors(String message, Map<String, Long> errors, Log log)
}
}

public static void checkAdmin(SecurityContext securityContext, ProcedureCallContext callContext, String procedureName) {
if (!securityContext.allowExecuteAdminProcedure(callContext.id())) throw new RuntimeException("This procedure "+ procedureName +" is only available to admin users");
public static void checkAdmin( SecurityContext securityContext, ProcedureCallContext callContext, String procedureName )
{
switch ( securityContext.allowExecuteAdminProcedure( callContext.id() ) )
{
case EXPLICIT_GRANT:
return;
default:
throw new RuntimeException( "This procedure " + procedureName + " is only available to admin users" );
}
}

public static void sleep(int millis) {
Expand Down

0 comments on commit 8d49d87

Please sign in to comment.