0
我有一個網站,其登錄表單看起來像這樣。Safari Autopassword爲空字符串
<h:panelGrid columns="3">
<p:outputLabel value="Username:" for="username"/>
<p:inputText id="username" autocomplete="off" />
<p:message for="username"/>
<p:outputLabel value="Password:" for="password"/>
<p:password id="password" />
<p:message for="password"/>
</h:panelGrid>
我們正在使用Spring安全來驗證密碼,當我在春天的UsernamePasswordAuthenticationFilter拋出一個破發點,使用Safari的自動填充密碼功能時,密碼總是空白。這會導致登錄失敗。
僅供參考,這裏是我的破發點位於
public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) throws AuthenticationException {
if (postOnly && !request.getMethod().equals("POST")) {
throw new AuthenticationServiceException("Authentication method not supported: " + request.getMethod());
}
String username = obtainUsername(request);
String password = obtainPassword(request);
if (username == null) {
username = "";
}
//My breakpoint is here, but password = "" even though we have a user name
if (password == null) {
password = "";
}
username = username.trim();
UsernamePasswordAuthenticationToken authRequest = new UsernamePasswordAuthenticationToken(username, password);
// Allow subclasses to set the "details" property
setDetails(request, authRequest);
return this.getAuthenticationManager().authenticate(authRequest);
}
我在一個總損失什麼,我可以檢查來解決這個Spring的代碼部分。此密碼問題僅影響Safari。其他瀏覽器,如IE,Chrome,FF工作得很好。
你如何提交你的表單?,你正在處理你的'p:password'嗎? –