use of com.hubspot.singularity.SingularityAuthorizationScope in project Singularity by HubSpot.
the class SingularityClient method isUserAuthorized.
//
// Auth
//
/**
* Check if a user is authorized for the specified scope on the specified request
*
* @param requestId
* The request to check authorization on
* @param userId
* The user whose authorization will be checked
* @param scope
* The scope to check that `user` has
*
* @return
* true if the user is authorized for scope, false otherwise
*/
public boolean isUserAuthorized(String requestId, String userId, SingularityAuthorizationScope scope) {
final Function<String, String> requestUri = (host) -> String.format(AUTH_CHECK_USER_FORMAT, getApiBase(host), requestId, userId);
Map<String, Object> params = Collections.singletonMap("scope", scope.name());
HttpResponse response = executeGetSingleWithParams(requestUri, "auth check", "", Optional.of(params));
return response.isSuccess();
}
Aggregations