![](/img/trans.png)
[英]How to authenticate a ldap user from any ldap server(except embedded server) using bind authentication mechanism in spring security
[英]Authenticate User using LDAP server (configured) from @service class
我正在使用spring boot rest URL“ / login”進行用戶登錄,並使用用戶憑據從前端訪問此URL。 我的spring boot服務與LDAP服務器配置在一起,並且在顯示任何結果之前正在對所有所需的請求進行身份驗證。 但是現在,我希望它在不顯示其他登錄頁面的情況下對用戶進行身份驗證,因為當我從前端本身發送用戶憑據時。
LDAP配置:
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.anyRequest().fullyAuthenticated()
.and()
.formLogin();
}
控制器:
@RequestMapping(value = "/login", method = RequestMethod.POST)
public ResponseEntity<?> authenticateUser(@Valid @ModelAttribute LoginRequest loginRequest, BindingResult result){
ResponseEntity<?> errorMap = mapValidationErrorService.getMapValidationErrors(result);
if(errorMap != null) return errorMap;
String jwt = null;
在LoginRequest pojo內部,我提供了我的用戶憑據。 我需要做的就是直接從ldap服務器驗證這些詳細信息,而無需任何進一步的重定向。
請提供建議/幫助。 提前致謝!
嘗試這個
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests().
.antMatchers("/login").permitAll()
.anyRequest().fullyAuthenticated();
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.