我已经设置了一个具有弹簧安全性的 OAuth2 服务器。我想编写客户端应用程序以在不保护任何资源的情况下使用这个带有 Spring Security 的 oauth 服务器。意味着我只想使用 spring security 3.1 从客户端运行 oauth2。我已经编写了以下配置,但它在重定向到 oauth2 服务器授权页面之前要求提供凭据。但我想在从客户端询问任何凭据之前将用户重定向到 oauth2 服务器授权页面。我正在使用以下配置
<http auto-config='true' xmlns="http://www.springframework.org/schema/security">
<intercept-url pattern="/product/**" access="IS_AUTHENTICATED_ANONYMOUSLY" />
<custom-filter ref="oauth2ClientFilter" after="EXCEPTION_TRANSLATION_FILTER" />
</http>
<authentication-manager xmlns="http://www.springframework.org/schema/security">
<authentication-provider>
<user-service>
<user name="jimi" password="jimi" authorities="ROLE_USER" />
</user-service>
</authentication-provider>
</authentication-manager>
<!--apply the oauth client context -->
<oauth:client id="oauth2ClientFilter" />
<oauth:resource id="fooClient" type="authorization_code"
client-id="foo" client-secret="secret" access-token-uri="${accessTokenUri}"
user-authorization-uri="${userAuthorizationUri}" scope="read" />
<bean id="dService" class="com.abc.service.DServiceImpl">
<property name="dURL" value="${dURL}"></property>
<property name="dRestTemplate">
<oauth:rest-template resource="fooClient" />
</property>
</bean>
所以我只想 /product url 应该访问 oauth2 服务器。没有这个,其余的 URL 映射应该可以工作。并且用户应该是客户端的匿名用户(无需在客户端显示登录)。
但是当我运行我的应用程序“http://localhost/client-sample/product/1”时,它会显示“http://localhost/client-sample/spring_security_login”。但我希望用户应该重定向到 oaut2 服务器页面。