Search in sources :

Example 1 with OauthClient

use of io.hops.hopsworks.persistence.entity.remote.oauth.OauthClient in project hopsworks by logicalclocks.

the class VariablesService method getAuthStatus.

@GET
@Path("authStatus")
@Produces(MediaType.APPLICATION_JSON)
@JWTNotRequired
@Deprecated
public Response getAuthStatus() {
    List<OauthClient> oauthClients = oauthClientFacade.findAll();
    List<OpenIdProvider> providers = new ArrayList<>();
    for (OauthClient client : oauthClients) {
        providers.add(new OpenIdProvider(client.getProviderName(), client.getProviderDisplayName(), client.getProviderLogoURI()));
    }
    AuthStatus authStatus = new AuthStatus(settings.getTwoFactorAuth(), settings.getLDAPAuthStatus(), settings.getKRBAuthStatus(), settings.isPasswordLoginDisabled(), settings.isRegistrationUIDisabled(), providers);
    return noCacheResponse.getNoCacheResponseBuilder(Response.Status.OK).entity(authStatus).build();
}
Also used : OauthClient(io.hops.hopsworks.persistence.entity.remote.oauth.OauthClient) ArrayList(java.util.ArrayList) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) JWTNotRequired(io.hops.hopsworks.api.filter.JWTNotRequired)

Example 2 with OauthClient

use of io.hops.hopsworks.persistence.entity.remote.oauth.OauthClient in project hopsworks by logicalclocks.

the class VariablesService method getAuthenticationStatus.

@GET
@Path("authenticationStatus")
@Produces(MediaType.APPLICATION_JSON)
@JWTNotRequired
public Response getAuthenticationStatus() {
    boolean remoteAuthEnabled = remoteUserHelper.isRemoteUserAuthAvailable();
    List<OpenIdProvider> providers = new ArrayList<>();
    if (remoteAuthEnabled) {
        List<OauthClient> oauthClients = oauthClientFacade.findAll();
        for (OauthClient client : oauthClients) {
            providers.add(new OpenIdProvider(client.getProviderName(), client.getProviderDisplayName(), client.getProviderLogoURI()));
        }
    }
    AuthenticationStatus authenticationStatus = new AuthenticationStatus(OTPAuthStatus.fromTwoFactorMode(settings.getTwoFactorAuth()), settings.isLdapEnabled(), settings.isKrbEnabled(), settings.isOAuthEnabled(), providers, settings.isPasswordLoginDisabled(), settings.isRegistrationUIDisabled(), remoteAuthEnabled);
    return Response.ok(authenticationStatus).build();
}
Also used : OauthClient(io.hops.hopsworks.persistence.entity.remote.oauth.OauthClient) ArrayList(java.util.ArrayList) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) JWTNotRequired(io.hops.hopsworks.api.filter.JWTNotRequired)

Example 3 with OauthClient

use of io.hops.hopsworks.persistence.entity.remote.oauth.OauthClient in project hopsworks by logicalclocks.

the class OAuthClientRegistration method onRowEdit.

public void onRowEdit(RowEditEvent event) {
    if (!checkOAuthHelper()) {
        return;
    }
    OauthClient oauthClient = (OauthClient) event.getObject();
    try {
        oAuthClientHelper.getoAuthHelper().updateClient(oauthClient);
        MessagesController.addInfoMessage("Updated OAuth server.");
    } catch (Exception e) {
        MessagesController.addErrorMessage(e.getMessage(), getRootCause(e));
    }
}
Also used : OauthClient(io.hops.hopsworks.persistence.entity.remote.oauth.OauthClient) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException)

Example 4 with OauthClient

use of io.hops.hopsworks.persistence.entity.remote.oauth.OauthClient in project hopsworks by logicalclocks.

the class OAuthClientRegistration method saveClient.

public void saveClient() {
    if (!providerMetadataEndpointSupported && (authorisationEndpoint == null || authorisationEndpoint.isEmpty() || tokenEndpoint == null || tokenEndpoint.isEmpty() || userInfoEndpoint == null || userInfoEndpoint.isEmpty() || jwksURI == null || jwksURI.isEmpty())) {
        LOGGER.log(Level.WARNING, "Failed to create client. Required field/s missing.");
        MessagesController.addErrorMessage("Failed to create client.", "Missing required field/s.");
        return;
    }
    try {
        OauthClient oauthClient = new OauthClient(this.clientId, this.clientSecret, this.providerURI, this.providerName, this.providerLogoURI, this.providerDisplayName, this.providerMetadataEndpointSupported, this.authorisationEndpoint, this.tokenEndpoint, this.userInfoEndpoint, this.jwksURI);
        oAuthClientHelper.getoAuthHelper().saveClient(oauthClient);
        MessagesController.addInfoMessage("Added new OAuth server.");
        init();
    } catch (Exception e) {
        LOGGER.log(Level.WARNING, "Failed to create client. {0}", e.getMessage());
        MessagesController.addErrorMessage(e.getMessage(), getRootCause(e));
    }
}
Also used : OauthClient(io.hops.hopsworks.persistence.entity.remote.oauth.OauthClient) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException)

Aggregations

OauthClient (io.hops.hopsworks.persistence.entity.remote.oauth.OauthClient)4 JWTNotRequired (io.hops.hopsworks.api.filter.JWTNotRequired)2 IOException (java.io.IOException)2 URISyntaxException (java.net.URISyntaxException)2 ArrayList (java.util.ArrayList)2 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2