在 spring Oauth2 中避免使用 JDBCTokenStore
Avoid JDBCTokenStore in spring Oauth2
我正在创建一个 spring oath2 应用程序。有用。我有疑问。
基于此 URL http://projects.spring.io/spring-security-oauth/docs/oauth2.html 只有 2 个实物期权:
JdbcTokenStore, JwtTokenStore.
是否可以使用 JDBCTokenStore 但不在 resourceServers 中引用它?
我的意思是我们不能只在 AuthorizationServer 中直接引用它,资源服务器可以使用来自 AuthorizationServer 的端点而不是配置另一个直接的 JDBCTokenStore 引用。
动机:希望避免在 AuthorizationServer 和多个 ResourceServer 之间共享一个数据库。有没有其他方法可以实现这个动机。
R
在您的资源服务器中,您可以使用 RemoteTokenServices。此 class 查询授权服务器中存在的 /check_token 端点以验证令牌。
您可以只为身份验证服务器使用一个数据库,为您的资源服务器使用另一个数据库。
<bean id="tokenServices" class="org.springframework.security.oauth2.provider.token.RemoteTokenServices">
<property name="checkTokenEndpointUrl" value="${auth.service.url:https://localhost:8443/auth-service}/oauth/check_token"/>
<property name="clientId" value="${auth.client.name:TEST_API}"/>
<property name="clientSecret" value="${auth.client.secret:password}"/>
<property name="accessTokenConverter" ref="accessTokenConverter"/>
<property name="restTemplate" ref="oauth2RestTemplate"/>
</bean>
我正在创建一个 spring oath2 应用程序。有用。我有疑问。
基于此 URL http://projects.spring.io/spring-security-oauth/docs/oauth2.html 只有 2 个实物期权: JdbcTokenStore, JwtTokenStore.
是否可以使用 JDBCTokenStore 但不在 resourceServers 中引用它? 我的意思是我们不能只在 AuthorizationServer 中直接引用它,资源服务器可以使用来自 AuthorizationServer 的端点而不是配置另一个直接的 JDBCTokenStore 引用。
动机:希望避免在 AuthorizationServer 和多个 ResourceServer 之间共享一个数据库。有没有其他方法可以实现这个动机。
R
在您的资源服务器中,您可以使用 RemoteTokenServices。此 class 查询授权服务器中存在的 /check_token 端点以验证令牌。
您可以只为身份验证服务器使用一个数据库,为您的资源服务器使用另一个数据库。
<bean id="tokenServices" class="org.springframework.security.oauth2.provider.token.RemoteTokenServices">
<property name="checkTokenEndpointUrl" value="${auth.service.url:https://localhost:8443/auth-service}/oauth/check_token"/>
<property name="clientId" value="${auth.client.name:TEST_API}"/>
<property name="clientSecret" value="${auth.client.secret:password}"/>
<property name="accessTokenConverter" ref="accessTokenConverter"/>
<property name="restTemplate" ref="oauth2RestTemplate"/>
</bean>