springfox.documentation.spi.service.contexts.SecurityContext Java Examples

The following examples show how to use springfox.documentation.spi.service.contexts.SecurityContext. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SwaggerAutoConfiguration.java    From Taroco with Apache License 2.0 5 votes vote down vote up
private List<SecurityContext> securityContexts() {
    List<SecurityContext> contexts = new ArrayList<>(1);
    SecurityContext securityContext = SecurityContext.builder()
            .securityReferences(defaultAuth())
            //.forPaths(PathSelectors.regex("^(?!auth).*$"))
            .build();
    contexts.add(securityContext);
    return contexts;
}
 
Example #2
Source File: Swagger2.java    From stone with GNU General Public License v3.0 5 votes vote down vote up
private List<SecurityContext> securityContexts() {
    return newArrayList(
            SecurityContext.builder()
                    .securityReferences(defaultAuth())
                    .forPaths(PathSelectors.regex("^(?!auth).*$"))
                    .build()
    );
}
 
Example #3
Source File: SwaggerAutoConfiguration.java    From microservices-platform with Apache License 2.0 5 votes vote down vote up
private List<SecurityContext> securityContexts() {
    List<SecurityContext> contexts = new ArrayList<>(1);
    SecurityContext securityContext = SecurityContext.builder()
            .securityReferences(defaultAuth())
            //.forPaths(PathSelectors.regex("^(?!auth).*$"))
            .build();
    contexts.add(securityContext);
    return contexts;
}
 
Example #4
Source File: SwaggerConfiguration.java    From halo with GNU General Public License v3.0 5 votes vote down vote up
private List<SecurityContext> adminSecurityContext() {
    return Collections.singletonList(
        SecurityContext.builder()
            .securityReferences(defaultAuth())
            .forPaths(PathSelectors.regex("/api/admin/.*"))
            .build()
    );
}
 
Example #5
Source File: Swagger2Config.java    From BigDataPlatform with GNU General Public License v3.0 5 votes vote down vote up
private List<SecurityContext> securityContexts() {
    //设置需要登录认证的路径
    List<SecurityContext> result = new ArrayList<>();
    result.add(getContextByPath("/brand/.*"));
    result.add(getContextByPath("/product/.*"));
    result.add(getContextByPath("/productCategory/.*"));
    return result;
}
 
Example #6
Source File: PaverSwaggerConfiguration.java    From data-highway with Apache License 2.0 5 votes vote down vote up
private SecurityContext securityContext() {
  return SecurityContext
      .builder()
      .securityReferences(defaultAuth())
      .forPaths(PathSelectors.regex("/paver.*"))
      .build();
}
 
Example #7
Source File: SwaggerConfiguration.java    From mica with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * 配置默认的全局鉴权策略的开关,以及通过正则表达式进行匹配;默认 ^.*$ 匹配所有URL
 * 其中 securityReferences 为配置启用的鉴权策略
 *
 * @return {SecurityContext}
 */
private SecurityContext securityContext(MicaSwaggerProperties properties) {
	return SecurityContext.builder()
		.securityReferences(defaultAuth(properties))
		.forPaths(PathSelectors.regex(properties.getAuthorization().getAuthRegex()))
		.build();
}
 
Example #8
Source File: SwaggerAutoConfiguration.java    From blade-tool with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * 配置默认的全局鉴权策略的开关,通过正则表达式进行匹配;默认匹配所有URL
 *
 * @return
 */
private SecurityContext securityContext() {
	return SecurityContext.builder()
		.securityReferences(defaultAuth())
		.forPaths(PathSelectors.regex(swaggerProperties().getAuthorization().getAuthRegex()))
		.build();
}
 
Example #9
Source File: Swagger2Config.java    From HIS with Apache License 2.0 5 votes vote down vote up
private List<SecurityContext> securityContexts() {
    //设置需要登录认证的路径
    List<SecurityContext> result = new ArrayList<>();
    result.add(getContextByPath("/brand/.*"));

    return result;
}
 
Example #10
Source File: Swagger2Config.java    From APIExample with MIT License 5 votes vote down vote up
private List<SecurityContext> securityContexts() {
    return Lists.newArrayList(
            SecurityContext.builder()
                    .securityReferences(defaultAuth())
                    .forPaths(PathSelectors.regex("^(?!auth).*$"))
                    .build()
    );
}
 
Example #11
Source File: MainController.java    From steady with Apache License 2.0 5 votes vote down vote up
/**
 * <p>adminApi.</p>
 *
 * @return a {@link springfox.documentation.spring.web.plugins.Docket} object.
 */
@Bean
public Docket adminApi() {
	AuthorizationScope[] authScopes = new AuthorizationScope[1];
       
	authScopes[0] = new AuthorizationScopeBuilder()
               .scope("read")
               .description("read access")
               .build();
       
       SecurityReference securityReference = SecurityReference.builder()
               .reference("test")
               .scopes(authScopes)
               .build();                
               
       ArrayList<SecurityContext> securityContexts = newArrayList(SecurityContext.builder().securityReferences
               (newArrayList(securityReference)).build());
       
	return new Docket(DocumentationType.SWAGGER_2)
               .apiInfo(this.getApiInfo())
               .groupName("config-api")
			.select()
			//.apis(RequestHandlerSelectors.any())
			.paths(this.configPaths())
			.build()
			//.pathMapping("/")
			.securitySchemes(newArrayList(new BasicAuth("test")))
               .securityContexts(securityContexts)
               ;
	
			/*.directModelSubstitute(LocalDate.class, String.class).genericModelSubstitutes(ResponseEntity.class)
			.alternateTypeRules(newRule(typeResolver.resolve(DeferredResult.class, typeResolver.resolve(ResponseEntity.class, WildcardType.class)), typeResolver.resolve(WildcardType.class)))
			.useDefaultResponseMessages(false)
			.globalResponseMessage(RequestMethod.GET, newArrayList(new ResponseMessageBuilder().code(500).message("500 message").responseModel(new ModelRef("Error")).build()))
			.securitySchemes(newArrayList(this.tenantKey())).securityContexts(newArrayList(securityContext()));*/
}
 
Example #12
Source File: SwaggerConfig.java    From BlogManagePlatform with Apache License 2.0 5 votes vote down vote up
/**
 * 配置访问路径
 * @author Frodez
 * @date 2019-01-06
 */
private List<SecurityContext> securityContext() {
	// 注意要与RestfulAPI路径一致
	SecurityContextBuilder builder = SecurityContext.builder();
	builder.securityReferences(defaultAuth());
	builder.forPaths(PathSelectors.regex(PropertyUtil.get(PropertyKey.Web.BASE_PATH)));
	return List.of(builder.build());
}
 
Example #13
Source File: SwaggerConfiguration.java    From halo with GNU General Public License v3.0 5 votes vote down vote up
private List<SecurityContext> contentSecurityContext() {
    return Collections.singletonList(
        SecurityContext.builder()
            .securityReferences(contentApiAuth())
            .forPaths(PathSelectors.regex("/api/content/.*"))
            .build()
    );
}
 
Example #14
Source File: OnrampSwaggerConfiguration.java    From data-highway with Apache License 2.0 5 votes vote down vote up
private SecurityContext securityContext() {
  return SecurityContext
      .builder()
      .securityReferences(defaultAuth())
      .forPaths(PathSelectors.regex("/onramp.*"))
      .build();
}
 
Example #15
Source File: Swagger2Config.java    From mall with Apache License 2.0 5 votes vote down vote up
private List<SecurityContext> securityContexts() {
    //设置需要登录认证的路径
    List<SecurityContext> result = new ArrayList<>();
    result.add(getContextByPath("/brand/.*"));
    result.add(getContextByPath("/product/.*"));
    result.add(getContextByPath("/productCategory/.*"));
    return result;
}
 
Example #16
Source File: Swagger2Configuration.java    From oauth2-resource with MIT License 5 votes vote down vote up
private List<SecurityContext> securityContexts() {
    return Arrays.asList(
        SecurityContext.builder()
            .securityReferences(defaultAuth())
            .forPaths(PathSelectors.regex("^(?!auth).*$"))
            .build()
    );
}
 
Example #17
Source File: Swagger2Config.java    From mall with Apache License 2.0 5 votes vote down vote up
private List<SecurityContext> securityContexts() {
    //设置需要登录认证的路径
    List<SecurityContext> result = new ArrayList<>();
    result.add(getContextByPath("/member/.*"));
    result.add(getContextByPath("/cart/.*"));
    result.add(getContextByPath("/order/.*"));
    result.add(getContextByPath("/returnApply/.*"));
    return result;
}
 
Example #18
Source File: SwaggerConfig.java    From pacbot with Apache License 2.0 5 votes vote down vote up
@Bean
SecurityContext securityContext() {
	AuthorizationScope readScope = new AuthorizationScope(scope, scopeDesc);
	AuthorizationScope[] scopes = new AuthorizationScope[1];
	scopes[0] = readScope;
	SecurityReference securityReference = SecurityReference.builder().reference(state).scopes(scopes)
			.build();

	return SecurityContext.builder().securityReferences(newArrayList(securityReference)).forPaths(PathSelectors.any())
			.build();
}
 
Example #19
Source File: Swagger2Config.java    From macrozheng with Apache License 2.0 5 votes vote down vote up
private List<SecurityContext> securityContexts() {
    //设置需要登录认证的路径
    List<SecurityContext> result = new ArrayList<>();
    result.add(getContextByPath("/brand/.*"));
    result.add(getContextByPath("/product/.*"));
    result.add(getContextByPath("/productCategory/.*"));
    return result;
}
 
Example #20
Source File: Swagger2Config.java    From mall-swarm with Apache License 2.0 5 votes vote down vote up
private List<SecurityContext> securityContexts() {
    //设置需要登录认证的路径
    List<SecurityContext> result = new ArrayList<>();
    result.add(getContextByPath("/brand/.*"));
    result.add(getContextByPath("/product/.*"));
    result.add(getContextByPath("/productCategory/.*"));
    return result;
}
 
Example #21
Source File: Swagger2Config.java    From mall-swarm with Apache License 2.0 5 votes vote down vote up
private List<SecurityContext> securityContexts() {
    //设置需要登录认证的路径
    List<SecurityContext> result = new ArrayList<>();
    result.add(getContextByPath("/feign/admin/getBrandList"));
    result.add(getContextByPath("/feign/portal/cartList"));
    return result;
}
 
Example #22
Source File: Swagger2Configuration.java    From spring-cloud-gray with Apache License 2.0 5 votes vote down vote up
private SecurityContext securityContext() {
        return SecurityContext.builder()
                .securityReferences(defaultAuth())
//                .forPaths(PathSelectors.regex("/anyPath.*"))
                .forPaths(PathSelectors.regex("^(?!auth).*$"))
                .build();
    }
 
Example #23
Source File: Swagger2Config.java    From HIS with Apache License 2.0 5 votes vote down vote up
private List<SecurityContext> securityContexts() {
    //设置需要登录认证的路径
    List<SecurityContext> result = new ArrayList<>();
    result.add(getContextByPath("/brand/.*"));

    return result;
}
 
Example #24
Source File: Swagger2Config.java    From mall-learning with Apache License 2.0 4 votes vote down vote up
private SecurityContext getContextByPath(String pathRegex){
    return SecurityContext.builder()
            .securityReferences(defaultAuth())
            .forPaths(PathSelectors.regex(pathRegex))
            .build();
}
 
Example #25
Source File: Swagger2Config.java    From mall-learning with Apache License 2.0 4 votes vote down vote up
private List<SecurityContext> securityContexts() {
    //设置需要登录认证的路径
    List<SecurityContext> result = new ArrayList<>();
    result.add(getContextByPath("/brand/.*"));
    return result;
}
 
Example #26
Source File: Swagger2Config.java    From mall-tiny with Apache License 2.0 4 votes vote down vote up
private SecurityContext getContextByPath(String pathRegex){
    return SecurityContext.builder()
            .securityReferences(defaultAuth())
            .forPaths(PathSelectors.regex(pathRegex))
            .build();
}
 
Example #27
Source File: Swagger2Config.java    From mall-learning with Apache License 2.0 4 votes vote down vote up
private List<SecurityContext> securityContexts() {
    //设置需要登录认证的路径
    List<SecurityContext> result = new ArrayList<>();
    result.add(getContextByPath("/brand/.*"));
    return result;
}
 
Example #28
Source File: Swagger2Config.java    From mall-learning with Apache License 2.0 4 votes vote down vote up
private SecurityContext getContextByPath(String pathRegex){
    return SecurityContext.builder()
            .securityReferences(defaultAuth())
            .forPaths(PathSelectors.regex(pathRegex))
            .build();
}
 
Example #29
Source File: Swagger2Config.java    From mall-learning with Apache License 2.0 4 votes vote down vote up
private List<SecurityContext> securityContexts() {
    //设置需要登录认证的路径
    List<SecurityContext> result = new ArrayList<>();
    result.add(getContextByPath("/brand/.*"));
    return result;
}
 
Example #30
Source File: Swagger2Config.java    From mall-learning with Apache License 2.0 4 votes vote down vote up
private List<SecurityContext> securityContexts() {
    //设置需要登录认证的路径
    List<SecurityContext> result = new ArrayList<>();
    result.add(getContextByPath("/brand/.*"));
    return result;
}