Search in sources :

Example 1 with AuthServiceBackendDTO

use of org.graylog.security.authservice.AuthServiceBackendDTO in project graylog2-server by Graylog2.

the class AuthServiceBackendsResource method delete.

@DELETE
@Path("{backendId}")
@ApiOperation("Delete authentication service backend")
@AuditEvent(type = SecurityAuditEventTypes.AUTH_SERVICE_BACKEND_DELETE)
public void delete(@ApiParam(name = "backendId", required = true) @PathParam("backendId") @NotBlank String backendId) {
    checkPermission(RestPermissions.AUTH_SERVICE_BACKEND_DELETE, backendId);
    final AuthServiceBackendDTO config = loadConfig(backendId);
    if (usageCheck.isAuthServiceInUse(backendId)) {
        throw new BadRequestException("Authentication service backend <" + backendId + "> is still in use");
    }
    dbService.delete(config.id());
}
Also used : BadRequestException(javax.ws.rs.BadRequestException) AuthServiceBackendDTO(org.graylog.security.authservice.AuthServiceBackendDTO) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) ApiOperation(io.swagger.annotations.ApiOperation) AuditEvent(org.graylog2.audit.jersey.AuditEvent)

Example 2 with AuthServiceBackendDTO

use of org.graylog.security.authservice.AuthServiceBackendDTO in project graylog2-server by Graylog2.

the class AuthServiceBackendsResource method getActiveType.

@GET
@RequiresGuest
@Path("active-backend/type")
@ApiOperation("Returns type of currently active authentication service backend")
public Response getActiveType() {
    String type = null;
    final AuthServiceBackendDTO activeBackendConfig = globalAuthServiceConfig.getActiveBackendConfig().orElse(null);
    if (activeBackendConfig != null) {
        type = activeBackendConfig.config().type();
    }
    return toResponse(type);
}
Also used : AuthServiceBackendDTO(org.graylog.security.authservice.AuthServiceBackendDTO) Path(javax.ws.rs.Path) RequiresGuest(org.apache.shiro.authz.annotation.RequiresGuest) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation)

Example 3 with AuthServiceBackendDTO

use of org.graylog.security.authservice.AuthServiceBackendDTO in project graylog2-server by Graylog2.

the class LDAPAuthServiceBackend method testConnection.

@Override
public AuthServiceBackendTestResult testConnection(@Nullable AuthServiceBackendDTO existingBackendConfig) {
    final LDAPAuthServiceBackendConfig testConfig = buildTestConfig(existingBackendConfig);
    final LDAPConnectorConfig config = testConfig.getLDAPConnectorConfig();
    if (config.serverList().size() == 1) {
        return testSingleConnection(config, config.serverList().get(0));
    }
    // Test each server separately, so we can see the result for each
    final List<AuthServiceBackendTestResult> testResults = config.serverList().stream().map(server -> testSingleConnection(config, server)).collect(Collectors.toList());
    if (testResults.stream().anyMatch(res -> !res.isSuccess())) {
        return AuthServiceBackendTestResult.createFailure("Test failure", testResults.stream().map(r -> {
            if (r.isSuccess()) {
                return r.message();
            } else {
                return r.message() + " : " + String.join(",", r.errors());
            }
        }).collect(Collectors.toList()));
    } else {
        return AuthServiceBackendTestResult.createSuccess("Successfully connected to " + config.serverList());
    }
}
Also used : LDAPConnection(com.unboundid.ldap.sdk.LDAPConnection) UnboundLDAPConnector(org.graylog.security.authservice.ldap.UnboundLDAPConnector) LoggerFactory(org.slf4j.LoggerFactory) HashMap(java.util.HashMap) LDAPUser(org.graylog.security.authservice.ldap.LDAPUser) Assisted(com.google.inject.assistedinject.Assisted) Inject(javax.inject.Inject) AuthServiceBackendDTO(org.graylog.security.authservice.AuthServiceBackendDTO) AuthServiceBackendTestResult(org.graylog.security.authservice.test.AuthServiceBackendTestResult) GeneralSecurityException(java.security.GeneralSecurityException) ImmutableList(com.google.common.collect.ImmutableList) AuthenticationDetails(org.graylog.security.authservice.AuthenticationDetails) Map(java.util.Map) LDAPException(com.unboundid.ldap.sdk.LDAPException) Nullable(javax.annotation.Nullable) UserDetails(org.graylog.security.authservice.UserDetails) EncryptedValue(org.graylog2.security.encryption.EncryptedValue) Logger(org.slf4j.Logger) ImmutableMap(com.google.common.collect.ImmutableMap) AuthenticationServiceUnavailableException(org.graylog2.shared.security.AuthenticationServiceUnavailableException) Collectors(java.util.stream.Collectors) List(java.util.List) AuthServiceCredentials(org.graylog.security.authservice.AuthServiceCredentials) UnboundLDAPConfig(org.graylog.security.authservice.ldap.UnboundLDAPConfig) AuthServiceBackend(org.graylog.security.authservice.AuthServiceBackend) ProvisionerService(org.graylog.security.authservice.ProvisionerService) LDAPConnectorConfig(org.graylog.security.authservice.ldap.LDAPConnectorConfig) Optional(java.util.Optional) Collections(java.util.Collections) AuthServiceBackendTestResult(org.graylog.security.authservice.test.AuthServiceBackendTestResult) LDAPConnectorConfig(org.graylog.security.authservice.ldap.LDAPConnectorConfig)

Example 4 with AuthServiceBackendDTO

use of org.graylog.security.authservice.AuthServiceBackendDTO in project graylog2-server by Graylog2.

the class AuthServiceBackendTestService method createNewBackend.

private Optional<AuthServiceBackend> createNewBackend(AuthServiceBackendTestRequest request) {
    final AuthServiceBackendDTO newBackend = request.backendConfiguration();
    final AuthServiceBackend.Factory<? extends AuthServiceBackend> backendFactory = backendFactories.get(newBackend.config().type());
    if (backendFactory == null) {
        return Optional.empty();
    }
    return Optional.of(backendFactory.create(newBackend));
}
Also used : AuthServiceBackendDTO(org.graylog.security.authservice.AuthServiceBackendDTO) AuthServiceBackend(org.graylog.security.authservice.AuthServiceBackend)

Example 5 with AuthServiceBackendDTO

use of org.graylog.security.authservice.AuthServiceBackendDTO in project graylog2-server by Graylog2.

the class ADAuthServiceBackend method testConnection.

@Override
public AuthServiceBackendTestResult testConnection(@Nullable AuthServiceBackendDTO existingBackendConfig) {
    final ADAuthServiceBackendConfig testConfig = buildTestConfig(existingBackendConfig);
    final LDAPConnectorConfig config = testConfig.getLDAPConnectorConfig();
    if (config.serverList().size() == 1) {
        return testSingleConnection(config, config.serverList().get(0));
    }
    // Test each server separately, so we can see the result for each
    final List<AuthServiceBackendTestResult> testResults = config.serverList().stream().map(server -> testSingleConnection(config, server)).collect(Collectors.toList());
    if (testResults.stream().anyMatch(res -> !res.isSuccess())) {
        return AuthServiceBackendTestResult.createFailure("Test failure", testResults.stream().map(r -> {
            if (r.isSuccess()) {
                return r.message();
            } else {
                return r.message() + " : " + String.join(",", r.errors());
            }
        }).collect(Collectors.toList()));
    } else {
        return AuthServiceBackendTestResult.createSuccess("Successfully connected to " + config.serverList());
    }
}
Also used : LDAPConnection(com.unboundid.ldap.sdk.LDAPConnection) UnboundLDAPConnector(org.graylog.security.authservice.ldap.UnboundLDAPConnector) LoggerFactory(org.slf4j.LoggerFactory) HashMap(java.util.HashMap) LDAPUser(org.graylog.security.authservice.ldap.LDAPUser) Assisted(com.google.inject.assistedinject.Assisted) Inject(javax.inject.Inject) AuthServiceBackendDTO(org.graylog.security.authservice.AuthServiceBackendDTO) AuthServiceBackendTestResult(org.graylog.security.authservice.test.AuthServiceBackendTestResult) GeneralSecurityException(java.security.GeneralSecurityException) ImmutableList(com.google.common.collect.ImmutableList) AuthenticationDetails(org.graylog.security.authservice.AuthenticationDetails) Map(java.util.Map) LDAPException(com.unboundid.ldap.sdk.LDAPException) Nullable(javax.annotation.Nullable) UserDetails(org.graylog.security.authservice.UserDetails) EncryptedValue(org.graylog2.security.encryption.EncryptedValue) Logger(org.slf4j.Logger) ImmutableMap(com.google.common.collect.ImmutableMap) AuthenticationServiceUnavailableException(org.graylog2.shared.security.AuthenticationServiceUnavailableException) Collectors(java.util.stream.Collectors) List(java.util.List) AuthServiceCredentials(org.graylog.security.authservice.AuthServiceCredentials) UnboundLDAPConfig(org.graylog.security.authservice.ldap.UnboundLDAPConfig) AuthServiceBackend(org.graylog.security.authservice.AuthServiceBackend) ProvisionerService(org.graylog.security.authservice.ProvisionerService) LDAPConnectorConfig(org.graylog.security.authservice.ldap.LDAPConnectorConfig) Optional(java.util.Optional) Filter(com.unboundid.ldap.sdk.Filter) Collections(java.util.Collections) AuthServiceBackendTestResult(org.graylog.security.authservice.test.AuthServiceBackendTestResult) LDAPConnectorConfig(org.graylog.security.authservice.ldap.LDAPConnectorConfig)

Aggregations

AuthServiceBackendDTO (org.graylog.security.authservice.AuthServiceBackendDTO)9 ApiOperation (io.swagger.annotations.ApiOperation)5 Path (javax.ws.rs.Path)4 GET (javax.ws.rs.GET)3 AuthServiceBackend (org.graylog.security.authservice.AuthServiceBackend)3 ImmutableList (com.google.common.collect.ImmutableList)2 ImmutableMap (com.google.common.collect.ImmutableMap)2 Assisted (com.google.inject.assistedinject.Assisted)2 LDAPConnection (com.unboundid.ldap.sdk.LDAPConnection)2 LDAPException (com.unboundid.ldap.sdk.LDAPException)2 GeneralSecurityException (java.security.GeneralSecurityException)2 Collections (java.util.Collections)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 Optional (java.util.Optional)2 Collectors (java.util.stream.Collectors)2 Nullable (javax.annotation.Nullable)2 Inject (javax.inject.Inject)2 AuthServiceCredentials (org.graylog.security.authservice.AuthServiceCredentials)2