Search in sources :

Example 6 with BasicCredentials

use of org.apache.druid.java.util.http.client.auth.BasicCredentials in project druid by druid-io.

the class ITTLSTest method testPlaintextAccess.

@Test
public void testPlaintextAccess() {
    LOG.info("---------Testing resource access without TLS---------");
    HttpClient adminClient = new CredentialedHttpClient(new BasicCredentials("admin", "priest"), httpClient);
    makeRequest(adminClient, HttpMethod.GET, config.getCoordinatorUrl() + "/status", null);
    makeRequest(adminClient, HttpMethod.GET, config.getOverlordUrl() + "/status", null);
    makeRequest(adminClient, HttpMethod.GET, config.getBrokerUrl() + "/status", null);
    makeRequest(adminClient, HttpMethod.GET, config.getHistoricalUrl() + "/status", null);
    makeRequest(adminClient, HttpMethod.GET, config.getRouterUrl() + "/status", null);
    makeRequest(adminClient, HttpMethod.GET, config.getPermissiveRouterUrl() + "/status", null);
    makeRequest(adminClient, HttpMethod.GET, config.getNoClientAuthRouterUrl() + "/status", null);
}
Also used : CredentialedHttpClient(org.apache.druid.java.util.http.client.CredentialedHttpClient) HttpClient(org.apache.druid.java.util.http.client.HttpClient) CredentialedHttpClient(org.apache.druid.java.util.http.client.CredentialedHttpClient) BasicCredentials(org.apache.druid.java.util.http.client.auth.BasicCredentials) Test(org.testng.annotations.Test)

Example 7 with BasicCredentials

use of org.apache.druid.java.util.http.client.auth.BasicCredentials in project druid by druid-io.

the class ITBasicAuthConfigurationTest method setupTestSpecificHttpClients.

@Override
protected void setupTestSpecificHttpClients() throws Exception {
    // create a new user+role that can read /status
    createUserAndRoleWithPermissions(adminClient, "druid", "helloworld", "druidrole", STATE_ONLY_PERMISSIONS);
    // create 100 users
    for (int i = 0; i < 100; i++) {
        HttpUtil.makeRequest(adminClient, HttpMethod.POST, config.getCoordinatorUrl() + "/druid-ext/basic-security/authentication/db/basic/users/druid" + i, null);
        HttpUtil.makeRequest(adminClient, HttpMethod.POST, config.getCoordinatorUrl() + "/druid-ext/basic-security/authorization/db/basic/users/druid" + i, null);
        LOG.info("Finished creating user druid" + i);
    }
    // setup the last of 100 users and check that it works
    HttpUtil.makeRequest(adminClient, HttpMethod.POST, config.getCoordinatorUrl() + "/druid-ext/basic-security/authentication/db/basic/users/druid99/credentials", jsonMapper.writeValueAsBytes(new BasicAuthenticatorCredentialUpdate("helloworld", 5000)));
    HttpUtil.makeRequest(adminClient, HttpMethod.POST, config.getCoordinatorUrl() + "/druid-ext/basic-security/authorization/db/basic/users/druid99/roles/druidrole", null);
    druid99 = new CredentialedHttpClient(new BasicCredentials("druid99", "helloworld"), httpClient);
}
Also used : CredentialedHttpClient(org.apache.druid.java.util.http.client.CredentialedHttpClient) BasicAuthenticatorCredentialUpdate(org.apache.druid.security.basic.authentication.entity.BasicAuthenticatorCredentialUpdate) BasicCredentials(org.apache.druid.java.util.http.client.auth.BasicCredentials)

Example 8 with BasicCredentials

use of org.apache.druid.java.util.http.client.auth.BasicCredentials in project druid by druid-io.

the class AbstractAuthConfigurationTest method verifyInvalidAuthNameFails.

protected void verifyInvalidAuthNameFails(String endpoint) {
    HttpClient adminClient = new CredentialedHttpClient(new BasicCredentials("admin", "priest"), httpClient);
    HttpUtil.makeRequestWithExpectedStatus(adminClient, HttpMethod.POST, endpoint, "SERIALIZED_DATA".getBytes(StandardCharsets.UTF_8), HttpResponseStatus.INTERNAL_SERVER_ERROR);
}
Also used : CredentialedHttpClient(org.apache.druid.java.util.http.client.CredentialedHttpClient) HttpClient(org.apache.druid.java.util.http.client.HttpClient) CredentialedHttpClient(org.apache.druid.java.util.http.client.CredentialedHttpClient) BasicCredentials(org.apache.druid.java.util.http.client.auth.BasicCredentials)

Example 9 with BasicCredentials

use of org.apache.druid.java.util.http.client.auth.BasicCredentials in project druid by druid-io.

the class AbstractAuthConfigurationTest method setupCommonHttpClients.

protected void setupCommonHttpClients() {
    adminClient = new CredentialedHttpClient(new BasicCredentials("admin", "priest"), httpClient);
    datasourceOnlyUserClient = new CredentialedHttpClient(new BasicCredentials("datasourceOnlyUser", "helloworld"), httpClient);
    datasourceAndSysUserClient = new CredentialedHttpClient(new BasicCredentials("datasourceAndSysUser", "helloworld"), httpClient);
    datasourceWithStateUserClient = new CredentialedHttpClient(new BasicCredentials("datasourceWithStateUser", "helloworld"), httpClient);
    stateOnlyUserClient = new CredentialedHttpClient(new BasicCredentials("stateOnlyUser", "helloworld"), httpClient);
    internalSystemClient = new CredentialedHttpClient(new BasicCredentials("druid_system", "warlock"), httpClient);
}
Also used : CredentialedHttpClient(org.apache.druid.java.util.http.client.CredentialedHttpClient) BasicCredentials(org.apache.druid.java.util.http.client.auth.BasicCredentials)

Example 10 with BasicCredentials

use of org.apache.druid.java.util.http.client.auth.BasicCredentials in project druid by druid-io.

the class AbstractAuthConfigurationTest method verifyAdminOptionsRequest.

protected void verifyAdminOptionsRequest() {
    HttpClient adminClient = new CredentialedHttpClient(new BasicCredentials("admin", "priest"), httpClient);
    testOptionsRequests(adminClient);
}
Also used : CredentialedHttpClient(org.apache.druid.java.util.http.client.CredentialedHttpClient) HttpClient(org.apache.druid.java.util.http.client.HttpClient) CredentialedHttpClient(org.apache.druid.java.util.http.client.CredentialedHttpClient) BasicCredentials(org.apache.druid.java.util.http.client.auth.BasicCredentials)

Aggregations

CredentialedHttpClient (org.apache.druid.java.util.http.client.CredentialedHttpClient)10 BasicCredentials (org.apache.druid.java.util.http.client.auth.BasicCredentials)10 HttpClient (org.apache.druid.java.util.http.client.HttpClient)7 SSLContext (javax.net.ssl.SSLContext)2 DruidHttpClientConfig (org.apache.druid.guice.http.DruidHttpClientConfig)2 Lifecycle (org.apache.druid.java.util.common.lifecycle.Lifecycle)2 HttpClientConfig (org.apache.druid.java.util.http.client.HttpClientConfig)2 TLSUtils (org.apache.druid.server.security.TLSUtils)2 Test (org.testng.annotations.Test)2 StatusResponseHolder (org.apache.druid.java.util.http.client.response.StatusResponseHolder)1 BasicAuthenticatorCredentialUpdate (org.apache.druid.security.basic.authentication.entity.BasicAuthenticatorCredentialUpdate)1