Search in sources :

Example 56 with SecurityAuthConfig

use of com.thoughtworks.go.config.SecurityAuthConfig in project gocd by gocd.

the class SecurityAuthConfigRepresenter method fromJSON.

public static SecurityAuthConfig fromJSON(JsonReader jsonReader) {
    SecurityAuthConfig securityAuthConfig = new SecurityAuthConfig(jsonReader.optString("id").orElse(null), jsonReader.getString("plugin_id"));
    securityAuthConfig.setAllowOnlyKnownUsersToLogin(jsonReader.optBoolean("allow_only_known_users_to_login").orElse(false));
    securityAuthConfig.addConfigurations(ConfigurationPropertyRepresenter.fromJSONArray(jsonReader, "properties"));
    return securityAuthConfig;
}
Also used : SecurityAuthConfig(com.thoughtworks.go.config.SecurityAuthConfig)

Example 57 with SecurityAuthConfig

use of com.thoughtworks.go.config.SecurityAuthConfig in project gocd by gocd.

the class SecurityAuthConfigInternalControllerV2 method verifyConnection.

public String verifyConnection(Request request, Response response) throws IOException {
    SecurityAuthConfig securityAuthConfig = buildEntityFromRequestBody(request);
    VerifyConnectionResponse verifyConnectionResponse = securityAuthConfigService.verifyConnection(securityAuthConfig);
    if (!verifyConnectionResponse.isSuccessful()) {
        response.status(422);
    }
    return writerForTopLevelObject(request, response, writer -> VerifyConnectionResponseRepresenter.toJSON(writer, verifyConnectionResponse, securityAuthConfig));
}
Also used : VerifyConnectionResponse(com.thoughtworks.go.plugin.domain.common.VerifyConnectionResponse) SecurityAuthConfig(com.thoughtworks.go.config.SecurityAuthConfig)

Example 58 with SecurityAuthConfig

use of com.thoughtworks.go.config.SecurityAuthConfig in project gocd by gocd.

the class SecurityAuthConfigUpdateCommand method update.

@Override
public void update(CruiseConfig preprocessedConfig) {
    SecurityAuthConfig existingProfile = findExistingProfile(preprocessedConfig);
    SecurityAuthConfigs profiles = getPluginProfiles(preprocessedConfig);
    profiles.set(profiles.indexOf(existingProfile), profile);
}
Also used : SecurityAuthConfig(com.thoughtworks.go.config.SecurityAuthConfig) SecurityAuthConfigs(com.thoughtworks.go.config.SecurityAuthConfigs)

Example 59 with SecurityAuthConfig

use of com.thoughtworks.go.config.SecurityAuthConfig in project gocd by gocd.

the class AuthorizationMessageConverterV1 method getAuthConfigs.

private List<Map<String, Object>> getAuthConfigs(List<SecurityAuthConfig> authConfigs) {
    List<Map<String, Object>> configs = new ArrayList<>();
    if (authConfigs == null) {
        return configs;
    }
    for (SecurityAuthConfig securityAuthConfig : authConfigs) {
        Map<String, Object> authConfig = new HashMap<>();
        authConfig.put("id", securityAuthConfig.getId());
        authConfig.put("configuration", securityAuthConfig.getConfigurationAsMap(true));
        configs.add(authConfig);
    }
    return configs;
}
Also used : SecurityAuthConfig(com.thoughtworks.go.config.SecurityAuthConfig)

Example 60 with SecurityAuthConfig

use of com.thoughtworks.go.config.SecurityAuthConfig in project gocd by gocd.

the class AuthorizationExtensionTest method shouldReturnTrueForSupportsValidatingUserExistenceForAuthorizationExtensionV2.

@Test
void shouldReturnTrueForSupportsValidatingUserExistenceForAuthorizationExtensionV2() throws Exception {
    String pluginId = "cd.go.ldap";
    when(pluginManager.resolveExtensionVersion(pluginId, AUTHORIZATION_EXTENSION, SUPPORTED_VERSIONS)).thenReturn(AuthorizationMessageConverterV2.VERSION);
    SecurityAuthConfig authConfig = new SecurityAuthConfig("ldap", pluginId, create("url", false, "some-url"));
    boolean expected = authorizationExtension.supportsPluginAPICallsRequiredForAccessToken(authConfig);
    assertThat(expected).isTrue();
}
Also used : SecurityAuthConfig(com.thoughtworks.go.config.SecurityAuthConfig) Test(org.junit.jupiter.api.Test)

Aggregations

SecurityAuthConfig (com.thoughtworks.go.config.SecurityAuthConfig)81 Test (org.junit.jupiter.api.Test)46 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)28 Test (org.junit.Test)16 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)14 AuthenticationResponse (com.thoughtworks.go.plugin.access.authorization.models.AuthenticationResponse)14 User (com.thoughtworks.go.plugin.access.authorization.models.User)11 PluginRoleConfig (com.thoughtworks.go.config.PluginRoleConfig)9 Username (com.thoughtworks.go.server.domain.Username)9 UserDetails (org.springframework.security.userdetails.UserDetails)8 ConfigurationProperty (com.thoughtworks.go.domain.config.ConfigurationProperty)7 SecurityConfig (com.thoughtworks.go.config.SecurityConfig)5 VerifyConnectionResponse (com.thoughtworks.go.plugin.domain.common.VerifyConnectionResponse)5 UsernamePasswordAuthenticationToken (org.springframework.security.providers.UsernamePasswordAuthenticationToken)5 BasicCruiseConfig (com.thoughtworks.go.config.BasicCruiseConfig)4 SecurityAuthConfigs (com.thoughtworks.go.config.SecurityAuthConfigs)4 RecordNotFoundException (com.thoughtworks.go.config.exceptions.RecordNotFoundException)4 DefaultGoPluginApiResponse (com.thoughtworks.go.plugin.api.response.DefaultGoPluginApiResponse)4 ValidationResult (com.thoughtworks.go.plugin.domain.common.ValidationResult)4 GoUserPrinciple (com.thoughtworks.go.server.security.userdetail.GoUserPrinciple)4