【问题标题】:Spring oauth2 add additional fieldpSpring oauth2 添加额外的fieldp
【发布时间】:2016-07-28 05:14:20
【问题描述】:

登录后 /uaa/oauth/token spring 发送该字段:

{
  "access_token": "eyJhbG",
  "token_type": "bearer",
  "refresh_token": "asfasfda"
  "expires_in": 86399,
  "scope": "events",
  "jti": "a4e4584c-ed38-4a26-b778-1748b27046ae",
  "key" : "my own field"
}

但是如何添加我自己的自定义字段,例如键?

【问题讨论】:

  • 您可以在该请求上发送自定义键/值对并使用过滤器拦截和读取额外的键值参数?
  • 我认为这不是明确的解决方案
  • 我不认为它听起来那么糟糕。我基本上在我的安全配置中配置了一个过滤器。请参阅下面的答案。

标签: java spring spring-security spring-security-oauth2


【解决方案1】:
 @Configuration
    @EnableResourceServer
    protected static class ResourceServerConfiguration extends ResourceServerConfigurerAdapter {

        @Override
        public void configure(ResourceServerSecurityConfigurer resources) {
            resources.resourceId(Constants.RESOURCE_ID);
        }

        @Override
        public void configure(HttpSecurity http) throws Exception {
           http
            .addFilter(new AuthTokenRequestFilter())
           .....
        }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-10-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-02-03
    相关资源
    最近更新 更多