Search in sources :

Example 1 with KeycloakClientConfig

use of org.jboss.pnc.common.json.moduleconfig.KeycloakClientConfig in project pnc by project-ncl.

the class SystemConfigMock method withKeycloakServiceAccount.

public static SystemConfig withKeycloakServiceAccount() throws IOException {
    String configJson = IoUtils.readResource("keycloakClientConfig.json", SystemConfigMock.class.getClassLoader());
    KeycloakClientConfig serviceAccountConfig = JsonOutputConverterMapper.readValue(configJson, KeycloakClientConfig.class);
    return new SystemConfig(null, null, null, null, null, null, null, "10", serviceAccountConfig, null, null, "", "10");
}
Also used : SystemConfig(org.jboss.pnc.common.json.moduleconfig.SystemConfig) KeycloakClientConfig(org.jboss.pnc.common.json.moduleconfig.KeycloakClientConfig)

Example 2 with KeycloakClientConfig

use of org.jboss.pnc.common.json.moduleconfig.KeycloakClientConfig in project pnc by project-ncl.

the class JaxRsActivatorNew method getAuthScheme.

private SecurityScheme getAuthScheme() {
    try {
        final KeycloakClientConfig keycloakConfig = systemConfig.getKeycloakServiceAccountConfig();
        if (keycloakConfig == null || StringUtils.isEmpty(keycloakConfig.getAuthServerUrl())) {
            return null;
        }
        URI keycloakURL = new URI(keycloakConfig.getAuthServerUrl() + "/").resolve("realms/" + keycloakConfig.getRealm() + "/protocol/openid-connect/auth");
        final OAuthFlow implicitFlow = new OAuthFlow().authorizationUrl(keycloakURL.toString());
        SecurityScheme scheme = new SecurityScheme();
        scheme.type(SecurityScheme.Type.OAUTH2).description("This application uses Keycloak oauth authentication").flows(new OAuthFlows().implicit(implicitFlow));
        return scheme;
    } catch (URISyntaxException ex) {
        logger.warn("Failed to parse Keycloak setting", ex);
        return null;
    }
}
Also used : OAuthFlow(io.swagger.v3.oas.models.security.OAuthFlow) OAuthFlows(io.swagger.v3.oas.models.security.OAuthFlows) URISyntaxException(java.net.URISyntaxException) KeycloakClientConfig(org.jboss.pnc.common.json.moduleconfig.KeycloakClientConfig) URI(java.net.URI) SecurityScheme(io.swagger.v3.oas.models.security.SecurityScheme)

Aggregations

KeycloakClientConfig (org.jboss.pnc.common.json.moduleconfig.KeycloakClientConfig)2 OAuthFlow (io.swagger.v3.oas.models.security.OAuthFlow)1 OAuthFlows (io.swagger.v3.oas.models.security.OAuthFlows)1 SecurityScheme (io.swagger.v3.oas.models.security.SecurityScheme)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 SystemConfig (org.jboss.pnc.common.json.moduleconfig.SystemConfig)1