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());
}
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);
}
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());
}
}
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));
}
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());
}
}
Aggregations