私は、スプリングソーシャルワークがどのくらい正確に機能するかを理解しようとしており、サンプルアプリケーションをコーディングすることでそれを学ぶことにしました。スプリングセキュリティ+スプリングソーシャルXML設定
アプリのコアは、基本的なスプリングセキュリティが既に設定されているappfuse quicksart archetype(マルチモジュール、Spring MVC)に基づいています。
私は、Spring SocialとSpring Securityの統合について説明しているthis tutorialを使用しています。しかし、この例では、Spring SocialのためのJavaベースの設定を使用しています。私が知る限り、公式のドキュメントはほとんどがJavaベースです。これは、XML構成は前述のチュートリアルからSocialContext
と同様である必要があり、このSO questionに基づいています
<!-- Ensures that configuration properties are read from a property file -->
<context:property-placeholder location="classpath:*social.properties"/>
<!--
Configures FB support.
-->
<facebook:config app-id="${facebook.app.id}" app-secret="${facebook.app.secret}" />
<social:jdbc-connection-repository data-source-ref="dataSource" connection-signup-ref="accountConnectionSignup"/>
<bean id="userIdSource" class="org.springframework.social.security.AuthenticationNameUserIdSource" />
<!--
This bean is custom account connection signup bean for your registeration logic.
-->
<bean id="accountConnectionSignup" class="com.yoso.socialApp.service.impl.ConnectionSignupManagerImpl"></bean>
<!--
This bean manages the connection flow between the account provider and
the example application.
-->
<bean id="connectController" class="org.springframework.social.connect.web.ConnectController" autowire="constructor">
<constructor-arg index="0" ref="connectionFactoryLocator"/>
<constructor-arg index="1" ref="connectionRepository"/>
</bean>
<bean id="textEncryptor" class="org.springframework.security.crypto.encrypt.Encryptors"
factory-method="noOpText" />
</beans>
私social.xmlです。
のsecurity.xmlファイルが変更されていない、私はhtml
タグにのみ、このライン
<intercept-url pattern="/auth" access="ROLE_ANONYMOUS,ROLE_ADMIN,ROLE_USER" />
を追加しました。
また、ログインページには、/auth/facebook
にリダイレクトされ、social.xml
〜web.xml
への参照が追加されています。さて、問題は、fbボタンをクリックするたびに何も起こらないということです。ページはちょうどリフレッシュされます。サーバーコンソールにもエラーもメッセージもありません。
また、/auth*
のコントローラを作成する必要があるかどうかはわかりません。documentationによれば、SocialAuthenticationFilter
はそれを行う必要があります。