Allow a function to be passed to keycloak.protect():
  keycloak.protect( function(token) {
    // return true if allowed, false if denied
  }, myHandler );