伙计们,
我第一次使用Facebook Social Integration . 我从Spring.io样本中获取相关代码文件,并使用它构建一个极简主义的“使用Facebook验证”应用程序 .
当我点击“登录Uisng FB”按钮时,我可以打开FB页面 . 输入我的凭证(有效)后,我再次被重定向到登录页面(/ signin) . 我期待的是被重定向到'/ signup',这是没有发生的 . 我希望使用FB数据为用户创建一个影子帐户 .
这是我的配置 .
security.xml文件
<http auto-config="true">
<form-login login-page="/signin" login-processing-url="/signin/authenticate" authentication-failure-url="/signin?param.error=bad_credentials" />
<!-- intercept-url pattern="/admin**" access="ROLE_USER" /-->
<!-- Spring Social Security authentication filter -->
<intercept-url pattern="/signup/**" access="ROLE_ANONYMOUS" />
<custom-filter ref="socialAuthenticationFilter" before="PRE_AUTH_FILTER" />
</http>
<authentication-manager alias="authenticationManager">
<authentication-provider>
<user-service>
<user name="vais" password="123456" authorities="ROLE_USER" />
</user-service>
</authentication-provider>
</authentication-manager>
<beans:bean id="textEncryptor" class="org.springframework.security.crypto.encrypt.Encryptors"
factory-method="noOpText" />
<beans:bean id="passwordEncoder" class="org.springframework.security.crypto.password.NoOpPasswordEncoder"
factory-method="getInstance" />
</beans:beans>
Social.xml
<context:property-placeholder location="classpath:/config/application.properties" />
<facebook:config app-id="${facebook.clientId}" app-secret="${facebook.clientSecret}" app-namespace="socialshowcase" />
<jdbc:embedded-database id="dataSource" type="H2">
</jdbc:embedded-database>
<social:jdbc-connection-repository/>
<bean id="userIdSource" class="org.springframework.social.security.AuthenticationNameUserIdSource" />
<bean id="connectController" class="org.springframework.social.connect.web.ConnectController" autowire="constructor">
</bean>
<bean id="signInAdapter" class="com.mkyong.web.controller.SimpleSignInAdapter" autowire="constructor" />
<bean id="disconnectController" class="org.springframework.social.facebook.web.DisconnectController"
c:_0-ref="usersConnectionRepository" c:_1="${facebook.clientSecret}" />
社会的security.xml
<bean id="socialAuthenticationFilter" class="org.springframework.social.security.SocialAuthenticationFilter"
c:_0-ref="authenticationManager"
c:_1-ref="userIdSource"
c:_2-ref="usersConnectionRepository"
c:_3-ref="connectionFactoryLocator"
p:signupUrl="/signup"
/> <!-- TODO: Figure out how to wire this without this name -->
以下是在我的JSP中尝试和设置FB登录的方法:
<!-- FACEBOOK SIGNIN -->
<p><a href="<c:url value="/auth/facebook"/>"><img src="<c:url value="/resources/social/facebook/sign-in-with-facebook.png"/>" border="0"/></a>
</p>
我希望在使用Facebook成功登录后,用户应该被重定向到'注册'而不是现在正在发生的'signin' . 将不胜感激任何投入 .