Skip to content

Dots are not allowed in the path in Hostname v2 #32643

@0x442E472E

Description

@0x442E472E

Before reporting an issue

  • I have read and understood the above terms for submitting issues, and I understand that my issue may be closed without action if I do not follow them.

Area

core

Describe the bug

Setting hostname/KC_HOSTNAME with the new Hostname v2 to an URL containing a dot in the path will crash keycloak at startup with the following message:

ERROR: Unexpected error when starting the server in (production) mode
Error details:
java.lang.RuntimeException: Failed to start quarkus
	at io.quarkus.runner.ApplicationImpl.<clinit>(Unknown Source)
	at java.base/jdk.internal.misc.Unsafe.ensureClassInitialized0(Native Method)
	at java.base/jdk.internal.misc.Unsafe.ensureClassInitialized(Unsafe.java:1160)
	at java.base/jdk.internal.reflect.MethodHandleAccessorFactory.ensureClassInitialized(MethodHandleAccessorFactory.java:300)
	at java.base/jdk.internal.reflect.MethodHandleAccessorFactory.newConstructorAccessor(MethodHandleAccessorFactory.java:103)
	at java.base/jdk.internal.reflect.ReflectionFactory.newConstructorAccessor(ReflectionFactory.java:200)
	at java.base/java.lang.reflect.Constructor.acquireConstructorAccessor(Constructor.java:549)
	at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:486)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:70)
	at org.keycloak.quarkus.runtime.KeycloakMain.start(KeycloakMain.java:139)
	at org.keycloak.quarkus.runtime.cli.command.AbstractStartCommand.run(AbstractStartCommand.java:35)
	at picocli.CommandLine.executeUserObject(CommandLine.java:2026)
	at picocli.CommandLine.access$1500(CommandLine.java:148)
	at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2461)
	at picocli.CommandLine$RunLast.handle(CommandLine.java:2453)
	at picocli.CommandLine$RunLast.handle(CommandLine.java:2415)
	at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2273)
	at picocli.CommandLine$RunLast.execute(CommandLine.java:2417)
	at picocli.CommandLine.execute(CommandLine.java:2170)
	at org.keycloak.quarkus.runtime.cli.Picocli.parseAndRun(Picocli.java:119)
	at org.keycloak.quarkus.runtime.KeycloakMain.main(KeycloakMain.java:99)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at io.quarkus.bootstrap.runner.QuarkusEntryPoint.doRun(QuarkusEntryPoint.java:62)
	at io.quarkus.bootstrap.runner.QuarkusEntryPoint.main(QuarkusEntryPoint.java:33)
Caused by: java.lang.IllegalArgumentException: Provided hostname is neither a plain hostname or a valid URL
	at org.keycloak.url.HostnameV2ProviderFactory.validateAndCreateUri(HostnameV2ProviderFactory.java:84)
	at org.keycloak.url.HostnameV2ProviderFactory.init(HostnameV2ProviderFactory.java:64)
	at org.keycloak.quarkus.runtime.integration.QuarkusKeycloakSessionFactory.<init>(QuarkusKeycloakSessionFactory.java:83)
	at org.keycloak.quarkus.runtime.KeycloakRecorder.configSessionFactory(KeycloakRecorder.java:116)
	at io.quarkus.deployment.steps.KeycloakProcessor$configureKeycloakSessionFactory343981823.deploy_4(Unknown Source)
	at io.quarkus.deployment.steps.KeycloakProcessor$configureKeycloakSessionFactory343981823.deploy(Unknown Source)
	... 26 more

With Keycloak 24, the setting hostname-url/KC_HOSTNAME_URL has worked in this scenario.

Version

25.0.4

Regression

  • The issue is a regression

Expected behavior

Keycloak 25 with Hostname v2 can work with a sub path that contains dots, like Keycloak 24 did.

Actual behavior

Keycloak crashes at startup.

How to Reproduce?

Set hostname/KC_HOSTNAME to https://my-example.com/auth.this/crashes

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions