如何将标记发送到Swagger的标题

时间:2017-09-27 09:35:07

标签: spring-boot swagger swagger-ui auth0 springfox

我有Spring Boot应用程序。我想在我的项目中整合招摇。

我在swagger上使用springfox 2.7.0和auth0进行身份验证,但是从auth0到swagger的头部发送id_token有问题。

这是我的Swagger配置代码:

@Bean
public Docket api() { 

return new Docket(DocumentationType.SWAGGER_2)  
  .select()              
  .apis(RequestHandlerSelectors.basePackage("name.web"))              
  .paths(PathSelectors.any())                          
  .build()
  .apiInfo(apiInfo())
  .securitySchemes(Collections.singletonList(securitySchema()));            

}

 private OAuth securitySchema() {

   List<AuthorizationScope> authorizationScopeList = new ArrayList<>();

   authorizationScopeList.add(new AuthorizationScope("openid", "access all"));

    List<GrantType> grantTypes = new ArrayList<>();

    final TokenRequestEndpoint tokenRequestEndpoint = new TokenRequestEndpoint("https://bovinet.auth0.com/authorize", "clientId", "secretKey");

    final TokenEndpoint tokenEndpoint = new TokenEndpoint("http://server.com/oauth/token", "id_token");


    AuthorizationCodeGrant authorizationCodeGrant = new 
    AuthorizationCodeGrant(tokenRequestEndpoint, tokenEndpoint);

    grantTypes.add(authorizationCodeGrant);

    OAuth oAuth = new OAuth("oauth2", authorizationScopeList, grantTypes);

    return oAuth;
 }


 private ApiInfo apiInfo() {
    @SuppressWarnings("deprecation")
     ApiInfo apiInfo = new ApiInfo(
    "Name", "", "", "", "", "", "");
     return apiInfo;
 }

 @Bean
 SecurityConfiguration security() {
  return new SecurityConfiguration(
   "clientId",
   "secretKey",
   "test-app-realm",
   "https://server.com",
   "api_key",
   ApiKeyVehicle.HEADER, 
   "Authorization", 
   "," /*scope separator*/);
}

当我打开 swagger-ui.htm 页面的控制台时,我可以看到id_token响应 / oauth / token 请求,但我不知道我不知道如何将这个标记放在招摇的标题中。

有人可以帮我解决这个问题吗?

0 个答案:

没有答案