我知道我的問題有點奇怪,但在連接到LDAP服務器的應用程序中,我們只需要讓用戶登錄到應用程序。是否可以使用Spring SecurityConfiguration HttpSecurity無密碼登錄?
該應用程序是一個Spring AngularJS。
所以,現在我正在改變代碼來做到這一點,但我發現登錄方法是做成Spring安全配置並使用密碼,所以我需要從數據庫中獲取密碼(user.getPassword()
),問題是,密碼與加密的PasswordEncoder所以沒有辦法decrypte它(在這裏在制酒紅一個答覆中提到)..
反正我不知道是否有使用彈簧安全登錄方式只是用戶名(沒有密碼)..
我試圖從配置類中刪除密碼聲明,但它doesn沒有工作。
在該類調用(public class SecurityConfiguration extends WebSecurityConfigurerAdapter
)我有未來的配置:
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.csrf()
.csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse())
.and()
.exceptionHandling()
.authenticationEntryPoint(authenticationEntryPoint)
.and()
.rememberMe()
.rememberMeServices(rememberMeServices)
.rememberMeParameter("remember-me")
.key(jHipsterProperties.getSecurity().getRememberMe().getKey())
.and()
.formLogin()
.loginProcessingUrl("/api/authentication")
.successHandler(ajaxAuthenticationSuccessHandler)
.failureHandler(ajaxAuthenticationFailureHandler)
.usernameParameter("j_username")
.passwordParameter("j_password")
.permitAll()
.and()
.logout()
.logoutUrl("/api/logout")
.logoutSuccessHandler(ajaxLogoutSuccessHandler)
.permitAll()
.and()
.headers()
.frameOptions()
.disable()
}
這裏是登錄方法:
function login (credentials) {
alert("log in this");
var data = 'j_username=' + encodeURIComponent(credentials.username)
+'&j_password=' + encodeURIComponent(credentials.password) +
'&remember-me=' + credentials.rememberMe + '&submit=Login';
return $http.post('api/authentication', data, {
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
}).success(function (response) {
return response;
});
}
任何想法的傢伙?
謝謝youuu
最佳答案非常感謝你! – Smahane