Joe*_*Joe 9 spring-security oauth-2.0
使用spring-security-oauth2保护我的资源免受可充当授权服务器的SSO端点的影响.当文档说明时我有点困惑:
OAuth 2.0中的提供者角色实际上是在授权服务和资源服务之间分配的,虽然这些角色有时位于同一个应用程序中,但是使用Spring Security OAuth,您可以选择将它们分成两个应用程序,还可以拥有多个共享的资源服务授权服务.
但我认为我没有找到这种情况的例子.在sparklr/tonr中,授权服务器和资源服务器位于同一个应用程序中.我从搜索中看到的唯一例子是spring-servlet.xml,它需要这个自定义实现ResourceServerTokenServices才能工作.
ResourceServerTokenServices如果可能的话,我想避免编写自定义实现.是否有另一种方法来支持资源服务器中的外部授权服务器?有点像:
<bean class="com.example.ExternalAuthorizationServerTokenServices"
p:remote-url="https://my-oauth-compatible-sso.com"
p:token-endpoint="/oauth/access_token"
p:authorize-endpoint="/oauth/authorize" />
Run Code Online (Sandbox Code Playgroud)
这可能吗?
*编辑:我将添加它作为一种解决方法(或者这可能是预期的解决方案)我正在使用jdbc令牌存储并依赖于这两个服务器碰巧有权访问该数据库的事实.
您可以在 spring-security.xml 中将开放资源和受保护资源分开
模式 /api/** 将受到保护,其他资源将开放。
<!-- Protected resources -->
<http pattern="/api/**" create-session="never" use-expressions="true"
entry-point-ref="oauthAuthenticationEntryPoint"
access-decision-manager-ref="accessDecisionManager"
xmlns="http://www.springframework.org/schema/security">
<anonymous enabled="false" />
<intercept-url pattern="/api/**"
access="hasAnyRole('ROLE_USER','ROLE_ADMIN')" />
<custom-filter ref="resourceServerFilter" before="PRE_AUTH_FILTER" />
<!-- <access-denied-handler ref="oauthAccessDeniedHandler"/> -->
<access-denied-handler ref="oauthAccessDeniedHandler" />
</http>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2739 次 |
| 最近记录: |