Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
14 changes: 14 additions & 0 deletions .github/settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
https://maven.apache.org/xsd/settings-1.0.0.xsd">
<mirrors>
<mirror>
<id>jboss-public-repository-group-https</id>
<mirrorOf>jboss-public-repository-group</mirrorOf>
<name>Jboss public https</name>
<url>https://repository.jboss.org/nexus/content/groups/public/</url>
</mirror>
</mirrors>

</settings>
53 changes: 20 additions & 33 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ name: Keycloak CI

on: [push, pull_request]

env:
# workaround for Maven >= 3.8.1 (see KEYCLOAK-17812)
MVN_MIRRORS: '[{ "id": "jboss-public-repository-group-https", "mirrorOf": "jboss-public-repository-group", "url": "https://repository.jboss.org/nexus/content/groups/public/" }]'

jobs:
build:
name: Build
Expand All @@ -15,9 +11,8 @@ jobs:
- uses: actions/setup-java@v1
with:
java-version: 1.8
- uses: whelk-io/maven-settings-xml-action@v15
with:
mirrors: ${{ env.MVN_MIRRORS }}
- name: Update maven settings
run: mkdir -p ~/.m2 ; cp .github/settings.xml ~/.m2/
- name: Cache Maven packages
id: cache
uses: actions/cache@v2
Expand Down Expand Up @@ -59,9 +54,8 @@ jobs:
- uses: actions/setup-java@v1
with:
java-version: 1.8
- uses: whelk-io/maven-settings-xml-action@v15
with:
mirrors: ${{ env.MVN_MIRRORS }}
- name: Update maven settings
run: mkdir -p ~/.m2 ; cp .github/settings.xml ~/.m2/
- name: Cache Maven packages
uses: actions/cache@v2
with:
Expand Down Expand Up @@ -101,9 +95,8 @@ jobs:
- uses: actions/setup-java@v1
with:
java-version: 1.8
- uses: whelk-io/maven-settings-xml-action@v15
with:
mirrors: ${{ env.MVN_MIRRORS }}
- name: Update maven settings
run: mkdir -p ~/.m2 ; cp .github/settings.xml ~/.m2/
- name: Cache Maven packages
uses: actions/cache@v2
with:
Expand Down Expand Up @@ -168,9 +161,8 @@ jobs:
- uses: actions/setup-java@v1
with:
java-version: 1.8
- uses: whelk-io/maven-settings-xml-action@v15
with:
mirrors: ${{ env.MVN_MIRRORS }}
- name: Update maven settings
run: mkdir -p ~/.m2 ; cp .github/settings.xml ~/.m2/

- name: Run base tests
run: |
Expand Down Expand Up @@ -233,10 +225,9 @@ jobs:
if: ${{ github.event_name != 'pull_request' || env.GIT_DIFF != 0 }}
with:
java-version: 1.8
- uses: whelk-io/maven-settings-xml-action@v15
- name: Update maven settings
if: ${{ github.event_name != 'pull_request' || env.GIT_DIFF != 0 }}
with:
mirrors: ${{ env.MVN_MIRRORS }}
run: mkdir -p ~/.m2 ; cp .github/settings.xml ~/.m2/

- name: Run cluster tests
if: ${{ github.event_name != 'pull_request' || env.GIT_DIFF != 0 }}
Expand Down Expand Up @@ -273,10 +264,9 @@ jobs:
if: ${{ github.event_name != 'pull_request' || env.GIT_DIFF != 0 }}
with:
java-version: 1.8
- uses: whelk-io/maven-settings-xml-action@v15
- name: Update maven settings
if: ${{ github.event_name != 'pull_request' || env.GIT_DIFF != 0 }}
with:
mirrors: ${{ env.MVN_MIRRORS }}
run: mkdir -p ~/.m2 ; cp .github/settings.xml ~/.m2/

- name: Cache Maven packages
if: ${{ github.event_name != 'pull_request' || env.GIT_DIFF != 0 }}
Expand Down Expand Up @@ -347,9 +337,8 @@ jobs:
- uses: actions/setup-java@v1
with:
java-version: 1.8
- uses: whelk-io/maven-settings-xml-action@v15
with:
mirrors: ${{ env.MVN_MIRRORS }}
- name: Update maven settings
run: mkdir -p ~/.m2 ; cp .github/settings.xml ~/.m2/
- name: Run Quarkus cluster tests
run: |
echo '::group::Compiling testsuite'
Expand Down Expand Up @@ -386,10 +375,8 @@ jobs:
- uses: actions/setup-java@v1
with:
java-version: 1.8
- uses: whelk-io/maven-settings-xml-action@v15
with:
mirrors: ${{ env.MVN_MIRRORS }}

- name: Update maven settings
run: mkdir -p ~/.m2 ; cp .github/settings.xml ~/.m2/
- name: Cache Maven packages
uses: actions/cache@v2
with:
Expand All @@ -409,13 +396,13 @@ jobs:
run: keycloak/.github/scripts/quickstarts/prepare-server.sh

- name: Build Quickstarts
run: .github/scripts/build-quickstarts.sh
run: scripts/build-quickstarts.sh

- name: Start Keycloak
run: .github/scripts/start-local-server.sh
run: scripts/start-local-server.sh

- name: Run tests
run: .github/scripts/run-tests.sh
run: scripts/run-tests.sh

- name: Archive logs
if: ${{ always() }}
Expand All @@ -425,4 +412,4 @@ jobs:
retention-days: 2
path: |
test-logs
keycloak.log
keycloak.log
3 changes: 3 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v2

- name: Update maven settings
run: mkdir -p ~/.m2 ; cp .github/settings.xml ~/.m2/

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
Expand Down
2 changes: 1 addition & 1 deletion adapters/oidc/adapter-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<artifactId>keycloak-parent</artifactId>
<groupId>org.keycloak</groupId>
<version>14.0.0-SNAPSHOT</version>
<version>15.0.0-SNAPSHOT</version>
<relativePath>../../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,18 @@ public HttpClient build(AdapterHttpClientConfig adapterConfig) {

configureProxyForAuthServerIfProvided(adapterConfig);

if (socketTimeout == -1 && adapterConfig.getSocketTimeout() > 0) {
socketTimeout(adapterConfig.getSocketTimeout(), TimeUnit.MILLISECONDS);
}

if (establishConnectionTimeout == -1 && adapterConfig.getConnectionTimeout() > 0) {
establishConnectionTimeout(adapterConfig.getConnectionTimeout(), TimeUnit.MILLISECONDS);
}

if (connectionTTL == -1 && adapterConfig.getConnectionTTL() > 0) {
connectionTTL(adapterConfig.getConnectionTTL(), TimeUnit.MILLISECONDS);
}

return build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ protected String getRedirectUri(String state) {
}
KeycloakUriBuilder secureUrl = KeycloakUriBuilder.fromUri(url).scheme("https").port(-1);
if (port != 443) secureUrl.port(port);
url = secureUrl.build().toString();
url = secureUrl.buildAsString();
}

String loginHint = getQueryParamValue("login_hint");
Expand Down Expand Up @@ -197,7 +197,7 @@ protected String getRedirectUri(String state) {
scope = TokenUtil.attachOIDCScope(scope);
redirectUriBuilder.queryParam(OAuth2Constants.SCOPE, scope);

return redirectUriBuilder.build().toString();
return redirectUriBuilder.buildAsString();
}

protected int sslRedirectPort() {
Expand Down Expand Up @@ -385,7 +385,7 @@ protected String stripOauthParametersFromRedirect() {
.replaceQueryParam(OAuth2Constants.CODE, null)
.replaceQueryParam(OAuth2Constants.STATE, null)
.replaceQueryParam(OAuth2Constants.SESSION_STATE, null);
return builder.build().toString();
return builder.buildAsString();
}

private String rewrittenRedirectUri(String originalUri) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ protected static String stripOauthParametersFromRedirect(String uri) {
KeycloakUriBuilder builder = KeycloakUriBuilder.fromUri(uri)
.replaceQueryParam(OAuth2Constants.CODE, null)
.replaceQueryParam(OAuth2Constants.STATE, null);
return builder.build().toString();
return builder.buildAsString();
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,13 +281,15 @@ public PathConfig matches(String targetUri) {
Map<String, Map<String, Object>> cipConfig = null;
PolicyEnforcerConfig.EnforcementMode enforcementMode = PolicyEnforcerConfig.EnforcementMode.ENFORCING;
ResourceRepresentation targetResource = matchingResources.get(0);
List<PolicyEnforcerConfig.MethodConfig> methodConfig = null;

if (pathConfig != null) {
cipConfig = pathConfig.getClaimInformationPointConfig();
enforcementMode = pathConfig.getEnforcementMode();
methodConfig = pathConfig.getMethods();
} else {
for (PathConfig existingPath : paths.values()) {
if (existingPath.getId().equals(targetResource.getId())
if (targetResource.getId().equals(existingPath.getId())
&& existingPath.isStatic()
&& !PolicyEnforcerConfig.EnforcementMode.DISABLED.equals(existingPath.getEnforcementMode())) {
return null;
Expand All @@ -300,6 +302,10 @@ public PathConfig matches(String targetUri) {
if (cipConfig != null) {
pathConfig.setClaimInformationPointConfig(cipConfig);
}

if (methodConfig != null) {
pathConfig.setMethods(methodConfig);
}

pathConfig.setEnforcementMode(enforcementMode);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@

package org.keycloak.adapters;

import org.apache.http.client.HttpClient;
import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
import org.apache.http.params.CoreConnectionPNames;
import org.hamcrest.CoreMatchers;
import org.junit.Test;
import org.keycloak.adapters.authentication.ClientIdAndSecretCredentialsProvider;
import org.keycloak.adapters.authentication.JWTClientCredentialsProvider;
Expand All @@ -29,6 +32,7 @@
import org.keycloak.common.util.PemUtils;
import org.keycloak.enums.TokenStore;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
Expand Down Expand Up @@ -101,5 +105,18 @@ public void loadSecretJwtCredentials() {
assertEquals(JWTClientSecretCredentialsProvider.PROVIDER_ID, deployment.getClientAuthenticator().getId());
}

@Test
public void loadHttpClientTimeoutConfiguration() {
KeycloakDeployment deployment = KeycloakDeploymentBuilder.build(getClass().getResourceAsStream("/keycloak-http-client.json"));
assertThat(deployment, CoreMatchers.notNullValue());

HttpClient client = deployment.getClient();
assertThat(client, CoreMatchers.notNullValue());

long socketTimeout = client.getParams().getIntParameter(CoreConnectionPNames.SO_TIMEOUT, -2);
long connectionTimeout = client.getParams().getIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, -2);

assertThat(socketTimeout, CoreMatchers.is(2000L));
assertThat(connectionTimeout, CoreMatchers.is(6000L));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"realm": "demo",
"resource": "customer-portal",
"auth-server-url": "https://localhost:8443/auth",
"public-client": true,
"socket-timeout-millis": 2000,
"connection-timeout-millis": 6000
}
2 changes: 1 addition & 1 deletion adapters/oidc/as7-eap6/as7-adapter-spi/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<artifactId>keycloak-as7-integration-pom</artifactId>
<groupId>org.keycloak</groupId>
<version>14.0.0-SNAPSHOT</version>
<version>15.0.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion adapters/oidc/as7-eap6/as7-adapter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<artifactId>keycloak-as7-integration-pom</artifactId>
<groupId>org.keycloak</groupId>
<version>14.0.0-SNAPSHOT</version>
<version>15.0.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion adapters/oidc/as7-eap6/as7-subsystem/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-as7-integration-pom</artifactId>
<version>14.0.0-SNAPSHOT</version>
<version>15.0.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@
public class KeycloakExtension implements Extension {

public static final String SUBSYSTEM_NAME = "keycloak";
public static final String NAMESPACE = "urn:jboss:domain:keycloak:1.1";
public static final String NAMESPACE_1_1 = "urn:jboss:domain:keycloak:1.1";
public static final String NAMESPACE_1_2 = "urn:jboss:domain:keycloak:1.2";
public static final String CURRENT_NAMESPACE = NAMESPACE_1_2;
private static final KeycloakSubsystemParser PARSER = new KeycloakSubsystemParser();
static final PathElement PATH_SUBSYSTEM = PathElement.pathElement(SUBSYSTEM, SUBSYSTEM_NAME);
private static final String RESOURCE_NAME = KeycloakExtension.class.getPackage().getName() + ".LocalDescriptions";
Expand All @@ -63,7 +65,8 @@ public static StandardResourceDescriptionResolver getResourceDescriptionResolver
*/
@Override
public void initializeParsers(final ExtensionParsingContext context) {
context.setSubsystemXmlMapping(SUBSYSTEM_NAME, KeycloakExtension.NAMESPACE, PARSER);
context.setSubsystemXmlMapping(SUBSYSTEM_NAME, KeycloakExtension.NAMESPACE_1_1, PARSER);
context.setSubsystemXmlMapping(SUBSYSTEM_NAME, KeycloakExtension.NAMESPACE_1_2, PARSER);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ private String readNameAttribute(XMLExtendedStreamReader reader) throws XMLStrea
*/
@Override
public void writeContent(final XMLExtendedStreamWriter writer, final SubsystemMarshallingContext context) throws XMLStreamException {
context.startSubsystemElement(KeycloakExtension.NAMESPACE, false);
context.startSubsystemElement(KeycloakExtension.CURRENT_NAMESPACE, false);
writeRealms(writer, context);
writeSecureDeployments(writer, context);
writer.writeEndElement();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.jboss.as.controller.SimpleAttributeDefinition;
import org.jboss.as.controller.SimpleAttributeDefinitionBuilder;
import org.jboss.as.controller.operations.validation.IntRangeValidator;
import org.jboss.as.controller.operations.validation.LongRangeValidator;
import org.jboss.as.controller.operations.validation.StringLengthValidator;
import org.jboss.dmr.ModelNode;
import org.jboss.dmr.ModelType;
Expand Down Expand Up @@ -81,6 +82,24 @@ class SharedAttributeDefinitons {
.setAllowExpression(true)
.setValidator(new IntRangeValidator(0, true))
.build();
protected static final SimpleAttributeDefinition SOCKET_TIMEOUT =
new SimpleAttributeDefinitionBuilder("socket-timeout-millis", ModelType.LONG, true)
.setXmlName("socket-timeout-millis")
.setAllowExpression(true)
.setValidator(new LongRangeValidator(-1L, true))
.build();
protected static final SimpleAttributeDefinition CONNECTION_TTL =
new SimpleAttributeDefinitionBuilder("connection-ttl-millis", ModelType.LONG, true)
.setXmlName("connection-ttl-millis")
.setAllowExpression(true)
.setValidator(new LongRangeValidator(-1L, true))
.build();
protected static final SimpleAttributeDefinition CONNECTION_TIMEOUT =
new SimpleAttributeDefinitionBuilder("connection-timeout-millis", ModelType.LONG, true)
.setXmlName("connection-timeout-millis")
.setAllowExpression(true)
.setValidator(new LongRangeValidator(-1L, true))
.build();

protected static final SimpleAttributeDefinition ENABLE_CORS =
new SimpleAttributeDefinitionBuilder("enable-cors", ModelType.BOOLEAN, true)
Expand Down Expand Up @@ -192,6 +211,9 @@ class SharedAttributeDefinitons {
ATTRIBUTES.add(ALLOW_ANY_HOSTNAME);
ATTRIBUTES.add(DISABLE_TRUST_MANAGER);
ATTRIBUTES.add(CONNECTION_POOL_SIZE);
ATTRIBUTES.add(SOCKET_TIMEOUT);
ATTRIBUTES.add(CONNECTION_TTL);
ATTRIBUTES.add(CONNECTION_TIMEOUT);
ATTRIBUTES.add(ENABLE_CORS);
ATTRIBUTES.add(CLIENT_KEYSTORE);
ATTRIBUTES.add(CLIENT_KEYSTORE_PASSWORD);
Expand Down
Loading