2017-03-07 93 views
0

我有一個Spring Boot啓用的應用程序,其登錄由第三方Siteminder應用程序控制。成功驗證後,Sitemeinder將重定向到我們的應用程序url。我們從Siteminder獲取HttpRequest並處理請求。如何爲使用第三方登錄的應用程序啓用Spring Security?

現在,在這種情況下,如何根據角色授權用戶來啓用Spring安全性。

@Controller 
public class LoginController 

@RequestMapping(value= "/") 
public void requestProcessor(HttpServletRequest request) 
{ 
. 
. 
.} 

上述控制器的請求映射器讀取的SiteMinder來的請求,並處理其中有用戶登錄,我們可以在哪裏春季安全啓用授權頁面和服務方式,以用戶的角色要求。

回答

-1

取決於你在會話中得到什麼。

@Autowired 
AuthenticationManager authenticationManager; 
... 

public boolean autoLogin(String username, String password) { 
    UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(username, password); 
    Authentication auth = authenticationManager.authenticate(token); 

    if (auth.isAuthenticated()) { 
     logger.debug("Succeed to auth user: " + username); 
     SecurityContextHolder.getContext().setAuthentication(auth); 
     return true; 
    } 

    return false; 
} 
+0

的SiteMinder不回密碼,它認證自己,並提供標題信息,如用戶名,角色等 – rinuthomaz

+0

@GVART正如我的隊友在上面評論中提到的,我們沒有得到用戶的密碼請求對象。 – Chandan

+0

這不安全 – jny

0

Spring Security的過程要求它得到您的控制器在春季安全配置配置filter前:如果以某種方式ü可以從會議採取用戶名和密碼就可以直接從代碼作爲用戶進行身份驗證。 有關於如何使用SiteMinder配置彈簧安全性的文檔。

在配置的規則將定義資源的訪問進行

相關問題