Search in sources :

Example 1 with WebhookAuthUser

use of com.hubspot.singularity.WebhookAuthUser in project Singularity by HubSpot.

the class RawUserResponseParser method parse.

SingularityUserPermissionsResponse parse(Response response) throws IOException {
    if (response.getStatusCode() > 299) {
        throw WebExceptions.unauthorized(String.format("Got status code %d when verifying jwt", response.getStatusCode()));
    } else {
        String responseBody = response.getResponseBody();
        WebhookAuthUser user = objectMapper.readValue(responseBody, WebhookAuthUser.class);
        return new SingularityUserPermissionsResponse(Optional.of(new SingularityUser(user.getUid(), Optional.of(user.getUid()), authConfiguration.getDefaultEmailDomain().map(d -> String.format("%s@%s", user.getUid(), d)), user.getGroups(), user.getScopes(), true)), Optional.empty());
    }
}
Also used : WebhookAuthUser(com.hubspot.singularity.WebhookAuthUser) WebExceptions(com.hubspot.singularity.WebExceptions) SingularityUser(com.hubspot.singularity.SingularityUser) Inject(com.google.inject.Inject) AuthConfiguration(com.hubspot.singularity.config.AuthConfiguration) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Singularity(com.hubspot.singularity.Singularity) Optional(java.util.Optional) IOException(java.io.IOException) WebhookAuthUser(com.hubspot.singularity.WebhookAuthUser) Singleton(com.google.inject.Singleton) Response(com.ning.http.client.Response) SingularityUser(com.hubspot.singularity.SingularityUser)

Aggregations

ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Inject (com.google.inject.Inject)1 Singleton (com.google.inject.Singleton)1 Singularity (com.hubspot.singularity.Singularity)1 SingularityUser (com.hubspot.singularity.SingularityUser)1 WebExceptions (com.hubspot.singularity.WebExceptions)1 WebhookAuthUser (com.hubspot.singularity.WebhookAuthUser)1 AuthConfiguration (com.hubspot.singularity.config.AuthConfiguration)1 Response (com.ning.http.client.Response)1 IOException (java.io.IOException)1 Optional (java.util.Optional)1