- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用 KeyCloak 集成来部署和测试简单的 Spring Boot 应用程序。我正在关注这个官方教程:https://blog.keycloak.org/2017/05/easily-secure-your-spring-boot.html 。但我在浏览器中收到错误“此页面无法正常工作”(未显示 KeyCloak 登录页面)并且 KeyCloak 抛出此异常:
IllegalArgumentException: An invalid control character was present in the
cookie value or attribute
这是我的 pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>demo</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.13.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<keycloak.version>3.3.0.Final</keycloak.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-freemarker</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.keycloak.bom</groupId>
<artifactId>keycloak-adapter-bom</artifactId>
<version>${keycloak.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
这是异常日志:
09:55:18,976 ERROR [io.undertow.request] (default task-7) UT005071: Undertow
req
uest failed HttpServerExchange{ GET /auth/ request {Accept=
[text/html,applicatio
n/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8], Accept-
Langu
age=[en-US,en;q=0.9,ru-RU;q=0.8,ru;q=0.7], Cache-Control=[max-age=0],
Accept-Enc
oding=[gzip, deflate, br], User-Agent=[Mozilla/5.0 (Windows NT 6.1; Win64;
x64)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36],
Conn
ection=[keep-alive], Cookie=[OAuth_Token_Request_State=2132636f-ed6a-44e2-
915b-9
cefed4dc446; JSESSIONID=D0DA2ADDBE8F62E55C9F65EB71BE85A0], Referer=
[http://local
host:8080/], Upgrade-Insecure-Requests=[1], Host=[localhost:8080]} response
{Cac
he-Control=[no-cache, must-revalidate, no-transform, no-store], X-Powered-
By=[Un
dertow/1], Server=[WildFly/11], X-XSS-Protection=[1; mode=block], X-Frame-
Option s=[SAMEORIGIN], Content-Security-Policy=[frame-src 'self'; frame
ancestors
'self
'; object-src 'none';], Date=[Wed, 23 May 2018 03:55:18 GMT], Connection=
[keep-a
live], X-Robots-Tag=[none], X-Content-Type-Options=[nosniff], Content-Type=
[text
/html;charset=utf-8], Content-Length=[2740]}}:
java.lang.IllegalArgumentExceptio
n: UT000173: An invalid control character [1087] was present in the cookie
value
or attribute
at io.undertow.util.LegacyCookieSupport.isHttpSeparator(LegacyCookieSupp
ort.java:142)
at io.undertow.util.LegacyCookieSupport.isHttpToken(LegacyCookieSupport.
java:163)
at io.undertow.util.LegacyCookieSupport.adjustedCookieVersion(LegacyCook
ieSupport.java:248)
at io.undertow.server.Connectors.getCookieString(Connectors.java:154)
at io.undertow.server.Connectors.flattenCookies(Connectors.java:99)
at io.undertow.server.protocol.http.HttpResponseConduit.processWrite(Htt
pResponseConduit.java:161)
at io.undertow.server.protocol.http.HttpResponseConduit.write(HttpRespon
seConduit.java:596)
at io.undertow.conduits.AbstractFixedLengthStreamSinkConduit.write(Abstr
actFixedLengthStreamSinkConduit.java:106)
at org.xnio.conduits.Conduits.writeFinalBasic(Conduits.java:132)
at io.undertow.conduits.AbstractFixedLengthStreamSinkConduit.writeFinal(
AbstractFixedLengthStreamSinkConduit.java:175)
at org.xnio.conduits.ConduitStreamSinkChannel.writeFinal(ConduitStreamSi
nkChannel.java:104)
at io.undertow.channels.DetachableStreamSinkChannel.writeFinal(Detachabl
eStreamSinkChannel.java:195)
at io.undertow.server.HttpServerExchange$WriteDispatchChannel.writeFinal
(HttpServerExchange.java:2042)
at io.undertow.servlet.spec.ServletOutputStreamImpl.writeBufferBlocking(
ServletOutputStreamImpl.java:568)
at io.undertow.servlet.spec.ServletOutputStreamImpl.close(ServletOutputS
treamImpl.java:603)
at io.undertow.servlet.spec.HttpServletResponseImpl.closeStreamAndWriter
(HttpServletResponseImpl.java:479)
at io.undertow.servlet.spec.HttpServletResponseImpl.responseDone(HttpSer
vletResponseImpl.java:568)
at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest
(ServletInitialHandler.java:339)
at io.undertow.servlet.handlers.ServletInitialHandler.access$100(Servlet
InitialHandler.java:81)
at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInit
ialHandler.java:138)
at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInit
ialHandler.java:135)
at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.cal
l(ServletRequestContextThreadSetupAction.java:48)
at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(Context
ClassLoaderSetupAction.java:43)
at org.wildfly.extension.undertow.security.SecurityContextThreadSetupAct
ion.lambda$create$0(SecurityContextThreadSetupAction.java:105)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoServi
ce$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java : 第1508章) 在 org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoServi
ce$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:第1508章) 在 org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoServi
ce$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java: 第1508章) 在 org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoServi
ce$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java: 第1508章) 在 io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(Se rvletInitialHandler.java:272) 在 io.undertow.servlet.handlers.ServletInitialHandler.access$000(Servlet InitialHandler.java:81) 在 io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(Se rvletInitialHandler.java:104) 在 io.undertow.server.Connectors.executeRootHandler(Connectors.java:326)
at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:8
12)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.
java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
.java:624)
at java.lang.Thread.run(Thread.java:748)
如果我清除浏览数据 keycloak 将起作用,但无论如何在我部署应用程序并单击“我的产品”后,我再次遇到相同的异常...
有什么猜测吗?
最佳答案
哈哈!解决方案很愚蠢...我的电脑名称...我的电脑名称是 Talgat-ПК。 П 和 К 是俄语字母...在我将其重命名为 Talgat-PC 后,一切开始正常工作。
关于java - KeyCloak 服务器响应 IllegalArgumentException :An invalid control character was present in the cookie value or attribute,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50452274/
我是一名优秀的程序员,十分优秀!