Vic*_*sky 0 java spring-security oauth-2.0 spring-social
我正在使用Spring Social和Spring Security对用户进行身份验证,并在我的Web应用程序上自动创建本地帐户.如何提供OAuth2 scope进行身份验证?
在春季社交样本中,我看不出scope应该去哪里.
<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="/spring-social-showcase/signup"
p:rememberMeServices-ref="org.springframework.security.web.authentication.rememberme.TokenBasedRememberMeServices#0" />
<bean id="socialAuthenticationProvider" class="org.springframework.social.security.SocialAuthenticationProvider"
c:_0-ref="usersConnectionRepository"
c:_1-ref="socialUsersDetailService" />
Run Code Online (Sandbox Code Playgroud)
一个特定的用例scope是让用户通过Facebook进行身份验证,然后获取用户的Facebook电子邮件(scope="email")以创建本地帐户.
在您的配置中,您需要指定scope为的属性FacebookAuthenticationService.这是处理调用的服务auth/facebook
在XML配置中,而不是:
<facebook:config app-id="${facebook.clientId}" app-secret="${facebook.clientSecret}"/>
Run Code Online (Sandbox Code Playgroud)
使用:
<bean id="connectionFactoryLocator" class="org.springframework.social.security.SocialAuthenticationServiceRegistry">
<property name="authenticationServices">
<list>
<bean class="org.springframework.social.facebook.security.FacebookAuthenticationService">
<constructor-arg value="${facebook.clientId}" />
<constructor-arg value="${facebook.clientSecret}" />
<!-- Important: The next property name changed from "scope" to "defaultScope" in 1.1.0.M4 -->
<property name="scope" value="email" />
</bean>
</list>
</property>
</bean>
Run Code Online (Sandbox Code Playgroud)
这适用于Spring Social 1.1.0.M3
| 归档时间: |
|
| 查看次数: |
4060 次 |
| 最近记录: |