Wildfly Form Auth在使用特殊字符时失败 [英] Wildfly Form Auth fails when using special characters
问题描述
我们正在将我们的GWT应用程序部署到Wild 8.1.0服务器,并使用表单身份验证进行安全。我们的问题是,每当我们的客户使用用户名或密码都有特殊字符(æøåäëö等)时,就无法登录。
We are deploying our GWT app to a Wildly 8.1.0 server and are using form authentication for security. Our problem is that every time our customer has a special character (æøåäëö, etc.) in their username or password, they cannot login.
我看过其他人同样的问题:
I have seen other people having the same issue:
https: //developer.jboss.org/thread/42859?tstart=0
UTF-8编码的j_security_check用户名在Tomcat领域中被错误解码为Latin-1
但是他们使用的是Tomcat / Apache / Spring等,所以我找不到一个可以为我们设置。
but they are using Tomcat/Apache/Spring etc., so I'm having trouble finding a solution that would work for our setup.
Wildly / Undertow是否有任何配置参数,所以我们可以在用户登录时确保UTF-8编码?
Is there any configuration parameter for Wildly/Undertow, so that we can ensure a UTF-8 encoding when our users log in?
我们的web.xml:
Our web.xml:
<login-config>
<auth-method>FORM</auth-method>
<realm-name>project-security-policy</realm-name>
<form-login-config>
<form-login-page>/login.html</form-login-page>
<form-error-page>/error.html</form-error-page>
</form-login-config>
</login-config>
登录表单:
<form name="loginform" method="post" autocomplete="on" action="j_security_check" accept-charset="UTF-8 ISO-8859-1" onsubmit="return validate_login_form();">
<input id="usernameInput" name="j_username" class="form-input" type="text" placeholder="Username" autofocus="">
<input id="passwordInput" name="j_password" class="form-input" type="password" placeholder="Password">
<input id="submitButton" type="submit" value="Login">
</form>
推荐答案
我找到了解决方案。在独立文件中,我已经在undertow子系统中编辑了 servlet-container
参数,并添加了 default-encoding
属性。现在我的用户可以在用户名和密码中使用特殊字符。
I've found the solution. In the standalone file, I have edited the servlet-container
parameter in the undertow subsystem, and added the default-encoding
attribute. Now my users can have special characters in the username and the password.
<servlet-container name="default" default-encoding="UTF-8">
整个子系统如下所示:
<subsystem xmlns="urn:jboss:domain:undertow:1.1">
<buffer-cache name="default" />
<server name="default-server">
<http-listener name="default" socket-binding="http" />
<host name="default-host" alias="localhost">
<location name="/" handler="welcome-content" />
<filter-ref name="server-header" />
<filter-ref name="x-powered-by-header" />
</host>
</server>
<servlet-container name="default" default-encoding="UTF-8">
<jsp-config />
</servlet-container>
<handlers>
<file name="welcome-content" path="${jboss.home.dir}/welcome-content" />
</handlers>
<filters>
<response-header name="server-header" header-name="Server" header-value="WildFly/8" />
<response-header name="x-powered-by-header" header-name="X-Powered-By" header-value="Undertow/1" />
</filters>
</subsystem>
这篇关于Wildfly Form Auth在使用特殊字符时失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!