Skip to content

Instantly share code, notes, and snippets.

@sudarshansb143
Created March 9, 2023 12:32
Show Gist options
  • Select an option

  • Save sudarshansb143/e2cb10f6a10fa02b79dfb0a02be3ac8a to your computer and use it in GitHub Desktop.

Select an option

Save sudarshansb143/e2cb10f6a10fa02b79dfb0a02be3ac8a to your computer and use it in GitHub Desktop.
Auth Middleware
private String ADMIN_ROLE = "admin"
// Assuming this function will be called from each API with provided params
public boolean isAccessAllowed(token, entityId, branchId, orgId, userRole){
if (token.role == ADMIN_ROLE) {
return true;
} else if (token.entityId == entityId && token.branchId === branchId && token.orgId === orgId && token.role == userRole ) {
return true
} else {
return false
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment