【发布时间】:2015-11-10 03:38:00
【问题描述】:
我们已经使用 spring-oauth2 实现了一个服务器 API。我注意到即使从不同的设备调用,服务器也会为每个用户/客户端 ID 组合生成相同的令牌。这会导致一个问题,因为我的客户可以运行多个实例:例如安卓和ios应用。我需要一种将令牌链接到特定实例而不重复使用相同令牌的方法。
需要这样做的一个示例是 GCM(或推送通知),其中 API 需要知道它正在与哪个实例进行通信。
这是我当前的 spring 配置:
<http pattern="/oauth/token" create-session="stateless"
authentication-manager-ref="clientAuthenticationManager"
entry-point-ref="oauthAuthenticationEntryPoint" xmlns="http://www.springframework.org/schema/security">
<intercept-url pattern="/oauth/token" access="IS_AUTHENTICATED_FULLY" />
<anonymous enabled="false" />
<http-basic entry-point-ref="oauthAuthenticationEntryPoint" />
<!-- include this only if you need to authenticate clients via request parameters -->
<custom-filter ref="clientCredentialsTokenEndpointFilter" before="BASIC_AUTH_FILTER" />
<access-denied-handler ref="oauthAccessDeniedHandler" />
</http>
<oauth:authorization-server
client-details-service-ref="mongoclientDetails" token-services-ref="tokenServices"
user-approval-handler-ref="userApprovalHandler">
<!-- authorization-endpoint-url="/oauth/authorize" token-endpoint-url="/oauth/token"> -->
<oauth:authorization-code />
<oauth:implicit />
<oauth:refresh-token />
<oauth:client-credentials />
<oauth:password />
</oauth:authorization-server>
我不想给每个客户一个不同的 id,因为那是不切实际的。有什么想法吗?
【问题讨论】:
-
你得到答案了吗?我遇到了类似的问题。
-
看看这个。看看有没有帮助..stackoverflow.com/questions/27020702/…
-
我可以通过使用范围来解决这个问题。我发布了一个答案。希望它有帮助..