springfox.documentation.service.AuthorizationScope Java Examples

The following examples show how to use springfox.documentation.service.AuthorizationScope. 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: Swagger2.java    From gpmall with Apache License 2.0 7 votes vote down vote up
List<SecurityReference> defaultAuth() {
    AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
    AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
    authorizationScopes[0] = authorizationScope;
    return new ArrayList() {{
        add(new SecurityReference("Authorization", authorizationScopes));
    }};
}
 
Example #2
Source File: SwaggerConfig.java    From angularjs-springmvc-sample-boot with Apache License 2.0 6 votes vote down vote up
@Bean
public Docket userApi() {
    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 = Lists.newArrayList(
            SecurityContext.builder()
                    .securityReferences(Lists.newArrayList(securityReference))
                    .build()
    );
    return new Docket(DocumentationType.SWAGGER_2)
            .directModelSubstitute(LocalDateTime.class, String.class)
            .ignoredParameterTypes(User.class)
            .securitySchemes(Lists.newArrayList(new BasicAuth("test")))
            .securityContexts(securityContexts)
            .apiInfo(apiInfo())
            .select()
            .paths(apiPaths())
            .build();
}
 
Example #3
Source File: Application.java    From springfox-demos with Apache License 2.0 6 votes vote down vote up
@Bean
public Docket userApi() {
  AuthorizationScope[] authScopes = new AuthorizationScope[1];
  authScopes[0] = new AuthorizationScopeBuilder()
      .scope("read")
      .description("read access")
      .build();
  SecurityReference securityReference = SecurityReference.builder()
      .reference("test")
      .scopes(authScopes)
      .build();

  List<SecurityContext> securityContexts =
      Collections.singletonList(
          SecurityContext.builder()
              .securityReferences(Collections.singletonList(securityReference))
              .build());
  return new Docket(DocumentationType.SWAGGER_2)
      .securitySchemes(Collections.singletonList(new BasicAuth("test")))
      .securityContexts(securityContexts)
      .groupName("user-api")
      .apiInfo(apiInfo())
      .select()
      .paths(input -> input.contains("user"))
      .build();
}
 
Example #4
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 #5
Source File: Swagger2Config.java    From mall-learning with Apache License 2.0 5 votes vote down vote up
private List<SecurityReference> defaultAuth() {
    List<SecurityReference> result = new ArrayList<>();
    AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
    AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
    authorizationScopes[0] = authorizationScope;
    result.add(new SecurityReference("Authorization", authorizationScopes));
    return result;
}
 
Example #6
Source File: Swagger2Config.java    From mall-learning with Apache License 2.0 5 votes vote down vote up
private List<SecurityReference> defaultAuth() {
    List<SecurityReference> result = new ArrayList<>();
    AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
    AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
    authorizationScopes[0] = authorizationScope;
    result.add(new SecurityReference("Authorization", authorizationScopes));
    return result;
}
 
Example #7
Source File: Swagger2Config.java    From mall-learning with Apache License 2.0 5 votes vote down vote up
private List<SecurityReference> defaultAuth() {
    List<SecurityReference> result = new ArrayList<>();
    AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
    AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
    authorizationScopes[0] = authorizationScope;
    result.add(new SecurityReference("Authorization", authorizationScopes));
    return result;
}
 
Example #8
Source File: Swagger2Config.java    From mall-learning with Apache License 2.0 5 votes vote down vote up
private List<SecurityReference> defaultAuth() {
    List<SecurityReference> result = new ArrayList<>();
    AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
    AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
    authorizationScopes[0] = authorizationScope;
    result.add(new SecurityReference("Authorization", authorizationScopes));
    return result;
}
 
Example #9
Source File: Swagger2Config.java    From mall-learning with Apache License 2.0 5 votes vote down vote up
private List<SecurityReference> defaultAuth() {
    List<SecurityReference> result = new ArrayList<>();
    AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
    AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
    authorizationScopes[0] = authorizationScope;
    result.add(new SecurityReference("Authorization", authorizationScopes));
    return result;
}
 
Example #10
Source File: Swagger2Config.java    From mall-learning with Apache License 2.0 5 votes vote down vote up
private List<SecurityReference> defaultAuth() {
    List<SecurityReference> result = new ArrayList<>();
    AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
    AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
    authorizationScopes[0] = authorizationScope;
    result.add(new SecurityReference("Authorization", authorizationScopes));
    return result;
}
 
Example #11
Source File: Swagger2Config.java    From mall-swarm with Apache License 2.0 5 votes vote down vote up
private List<SecurityReference> defaultAuth() {
    List<SecurityReference> result = new ArrayList<>();
    AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
    AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
    authorizationScopes[0] = authorizationScope;
    result.add(new SecurityReference("Authorization", authorizationScopes));
    return result;
}
 
Example #12
Source File: Swagger2Config.java    From mall-swarm with Apache License 2.0 5 votes vote down vote up
private List<SecurityReference> defaultAuth() {
    List<SecurityReference> result = new ArrayList<>();
    AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
    AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
    authorizationScopes[0] = authorizationScope;
    result.add(new SecurityReference("Authorization", authorizationScopes));
    return result;
}
 
Example #13
Source File: Swagger2Config.java    From mall-swarm with Apache License 2.0 5 votes vote down vote up
private List<SecurityReference> defaultAuth() {
    List<SecurityReference> result = new ArrayList<>();
    AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
    AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
    authorizationScopes[0] = authorizationScope;
    result.add(new SecurityReference("Authorization", authorizationScopes));
    return result;
}
 
Example #14
Source File: Swagger2Config.java    From macrozheng with Apache License 2.0 5 votes vote down vote up
private List<SecurityReference> defaultAuth() {
    List<SecurityReference> result = new ArrayList<>();
    AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
    AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
    authorizationScopes[0] = authorizationScope;
    result.add(new SecurityReference("Authorization", authorizationScopes));
    return result;
}
 
Example #15
Source File: Application.java    From springfox-demos with Apache License 2.0 5 votes vote down vote up
@Bean
SecurityContext securityContext() {
  AuthorizationScope readScope = new AuthorizationScope("read:pets", "read your pets");
  AuthorizationScope[] scopes = new AuthorizationScope[1];
  scopes[0] = readScope;
  SecurityReference securityReference = SecurityReference.builder()
      .reference("petstore_auth")
      .scopes(scopes)
      .build();

  return SecurityContext.builder()
      .securityReferences(Collections.singletonList(securityReference))
      .forPaths(ant("/api/pet.*"))
      .build();
}
 
Example #16
Source File: Swagger2Config.java    From mall-learning with Apache License 2.0 5 votes vote down vote up
private List<SecurityReference> defaultAuth() {
    List<SecurityReference> result = new ArrayList<>();
    AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
    AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
    authorizationScopes[0] = authorizationScope;
    result.add(new SecurityReference("Authorization", authorizationScopes));
    return result;
}
 
Example #17
Source File: Swagger2Config.java    From mall with Apache License 2.0 5 votes vote down vote up
private List<SecurityReference> defaultAuth() {
    List<SecurityReference> result = new ArrayList<>();
    AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
    AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
    authorizationScopes[0] = authorizationScope;
    result.add(new SecurityReference("Authorization", authorizationScopes));
    return result;
}
 
Example #18
Source File: Swagger2Config.java    From mall with Apache License 2.0 5 votes vote down vote up
private List<SecurityReference> defaultAuth() {
    List<SecurityReference> result = new ArrayList<>();
    AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
    AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
    authorizationScopes[0] = authorizationScope;
    result.add(new SecurityReference("Authorization", authorizationScopes));
    return result;
}
 
Example #19
Source File: SwaggerAutoConfiguration.java    From Taroco with Apache License 2.0 5 votes vote down vote up
private List<SecurityReference> defaultAuth() {
    AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
    AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
    authorizationScopes[0] = authorizationScope;
    List<SecurityReference> references = new ArrayList<>(1);
    references.add(new SecurityReference("Authorization", authorizationScopes));
    return references;
}
 
Example #20
Source File: SwaggerConfig.java    From DimpleBlog with Apache License 2.0 5 votes vote down vote up
private List<SecurityReference> defaultAuth() {
    AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
    AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
    authorizationScopes[0] = authorizationScope;
    List<SecurityReference> securityReferences = new ArrayList<>();
    securityReferences.add(new SecurityReference("Authorization", authorizationScopes));
    return securityReferences;
}
 
Example #21
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<SecurityReference> defaultAuth() {
	AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
	AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
	authorizationScopes[0] = authorizationScope;
	return List.of(new SecurityReference(security.getJwt().getTokenPrefix(), authorizationScopes));
}
 
Example #22
Source File: SwaggerConfiguration.java    From iotplatform with Apache License 2.0 5 votes vote down vote up
List<SecurityReference> defaultAuth() {
      AuthorizationScope[] authorizationScopes = new AuthorizationScope[3];
      authorizationScopes[0] = new AuthorizationScope(Authority.SYS_ADMIN.name(), "System administrator");
      authorizationScopes[1] = new AuthorizationScope(Authority.TENANT_ADMIN.name(), "Tenant administrator");
      authorizationScopes[2] = new AuthorizationScope(Authority.CUSTOMER_USER.name(), "Customer");
      return newArrayList(
              new SecurityReference("X-Authorization", authorizationScopes));
}
 
Example #23
Source File: SwaggerConfig.java    From springfox-oath2-demo with Apache License 2.0 5 votes vote down vote up
private List<AuthorizationScope> scopes() {
List<AuthorizationScope> list = new ArrayList();
list.add(new AuthorizationScope("read_scope","Grants read access"));
list.add(new AuthorizationScope("write_scope","Grants write access"));
list.add(new AuthorizationScope("admin_scope","Grants read write and delete access"));
return list;
  }
 
Example #24
Source File: MainController.java    From steady with Apache License 2.0 5 votes vote down vote up
/**
 * <p>userApi.</p>
 *
 * @return a {@link springfox.documentation.spring.web.plugins.Docket} object.
 */
@Bean
public Docket userApi() {
	AuthorizationScope[] authScopes = new AuthorizationScope[1];
	
	authScopes[0] = new AuthorizationScopeBuilder()
               .scope("read")
               .description("read access")
               .build();
	
	SecurityReference securityReference1 = SecurityReference.builder()
               .reference("tenant")
               .scopes(authScopes)
               .build();                
       
	SecurityReference securityReference2 = SecurityReference.builder()
               .reference("space")
               .scopes(authScopes)
               .build();   
	
       ArrayList<SecurityContext> securityContexts = newArrayList(SecurityContext.builder().securityReferences
               (newArrayList(securityReference1, securityReference2)).build());
	
	return new Docket(DocumentationType.SWAGGER_2)
			.groupName("user-api")
			.apiInfo(this.getApiInfo())
			.select()
			//.apis(RequestHandlerSelectors.any())
			.paths(this.userPaths())
			.build()
			//.pathMapping("/")
			.securitySchemes(newArrayList(this.tenantKey(), this.spaceKey()))
               .securityContexts(securityContexts)
			;
}
 
Example #25
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 #26
Source File: OAuthServerConfiguration.java    From microservices-basics-spring-boot with Apache License 2.0 5 votes vote down vote up
private OAuth securitySchema() {
	List<AuthorizationScope> authorizationScopeList = new ArrayList<>();
	authorizationScopeList.add(new AuthorizationScope(OAUTH2_CLIENT_SCOPE, "Access for open id  default"));

	List<GrantType> grantTypes = new ArrayList<>();
	ResourceOwnerPasswordCredentialsGrant passwordOwnerGrant = new ResourceOwnerPasswordCredentialsGrant(
			"/userauth/oauth/token");

	grantTypes.add(passwordOwnerGrant);

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

	return oAuth;
}
 
Example #27
Source File: OAuthServerConfiguration.java    From microservices-basics-spring-boot with Apache License 2.0 5 votes vote down vote up
List<SecurityReference> defaultAuth() {
	AuthorizationScope authorizationScope = new AuthorizationScope(OAUTH2_CLIENT_SCOPE,
			"Access for open id  default");
	AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
	authorizationScopes[0] = authorizationScope;
	return Lists.newArrayList(new SecurityReference(AUTHORIZATION_HEADER, authorizationScopes));
}
 
Example #28
Source File: Swagger2Config.java    From mall-learning with Apache License 2.0 5 votes vote down vote up
private List<SecurityReference> defaultAuth() {
    List<SecurityReference> result = new ArrayList<>();
    AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
    AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
    authorizationScopes[0] = authorizationScope;
    result.add(new SecurityReference("Authorization", authorizationScopes));
    return result;
}
 
Example #29
Source File: Swagger2Config.java    From BigDataPlatform with GNU General Public License v3.0 5 votes vote down vote up
private List<SecurityReference> defaultAuth() {
    List<SecurityReference> result = new ArrayList<>();
    AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
    AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
    authorizationScopes[0] = authorizationScope;
    result.add(new SecurityReference("Authorization", authorizationScopes));
    return result;
}
 
Example #30
Source File: Swagger2.java    From stone with GNU General Public License v3.0 5 votes vote down vote up
List<SecurityReference> defaultAuth() {
    AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
    AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
    authorizationScopes[0] = authorizationScope;
    return newArrayList(
            new SecurityReference("token", authorizationScopes));
}