2012-09-15 43 views
0

我對Spring安全和Spring社交相對較新。我正試圖通過標準的Spring Security或Spring社交Facebook來實現混合身份驗證。使用Spring安全性和Spring社交Facebook實現混合身份驗證

因此,用戶可以驗證:

  • 或者用標準的Spring安全登錄形式如下:

片段從我Thymeleaf的模板:

<form name="f" th:action="@{/resources/j_spring_security_check}" method="POST"> 
     <input id="j_username" type='text' name='j_username'/><br /> 
     <input id="j_password" type='password' name='j_password'/><br /> 
     <input id="proceed" type="submit" value="login" /> 
</form> 

該工程確定,例如用戶向受保護的資源發送請求,例如, www.example.com/memberArea/editMyProfile由以下攔截的URL保護:

<intercept-url pattern="/memberArea/**" access="hasRole('ROLE_USER')" /> 

用戶被重定向到登錄表單,並在成功登錄時,用戶最終重定向到受保護的資源,即www.example.com/memberArea/editMyProfile

  • 或者用戶可以選擇春社會Facebook和認證/註冊,像這樣的鏈接:

從我Thymeleaf的模板段:

<a th:href="@{'https://www.facebook.com/dialog/oauth/?client_id=414113641982512&amp;redirect_uri=http://www.example.com/&amp;state=UNIQUE&amp;scope=read_stream'}">Login with facebook</a> 

在這種情況下,用戶當然是重定向到www.example.com而不是www.example.com/memberArea/editMyProfile

我的問題是那麼,如何 - 仍然使用Spring安全和Spring社會Facebook的 - 我能以某種方式檢索請求的URL(這裏www.example.com/memberArea/editMyProfile )並最終將用戶重定向到此URL?

回答

2

你能幫我理解你想做什麼與Spring Social的ProviderSignInController的工作方式有什麼不同嗎?具體來說,如果你看看Spring社交展示(https://github.com/SpringSource/spring-social-samples/tree/master/spring-social-showcase)或Spring Social Quickstart(https://github.com)/SpringSource/spring-social-samples/tree/master/spring-social-quickstart),他們都使用ProviderSignInController通過Facebook對用戶進行身份驗證。

在展示示例中,通過將用戶的FB信息與先前建立的連接進行比較來完成驗證。在快速入門示例中,它是通過「隱式認證」完成的,其中沒有特定於應用程序的認證,而是使用Facebook授權充當應用程序認證。從我所瞭解的情況來看,你正在嘗試做與展示一樣的風格,但我可能會誤解你想要做的事情。順便說一下,在StackOverflow中可以繼續討論,但我鼓勵你在春季社交論壇上(http://forum.springsource.org/forumdisplay.php?82-Social)提問你的Spring社區問題, ,因爲我幾乎每天都在監視該論壇,但每週只能訪問一次(如果經常的話)。

+0

嗨,謝謝你克雷格,我剛剛git克隆,建立和運行春季社交展示,它只是我期望的行爲。如果我還有其他問題,我將探討這些功能併發布到Spring社區論壇。再次感謝您花時間回覆! – balteo

相關問題