mirror of https://github.com/halo-dev/halo
Fix content api authentication in swagger
parent
74349a11e2
commit
e171344cd1
|
@ -147,18 +147,24 @@ public class SwaggerConfiguration {
|
||||||
private List<SecurityContext> contentSecurityContext() {
|
private List<SecurityContext> contentSecurityContext() {
|
||||||
return Collections.singletonList(
|
return Collections.singletonList(
|
||||||
SecurityContext.builder()
|
SecurityContext.builder()
|
||||||
.securityReferences(defaultAuth())
|
.securityReferences(contentApiAuth())
|
||||||
.forPaths(PathSelectors.regex("/api/content/.*"))
|
.forPaths(PathSelectors.regex("/api/content/.*"))
|
||||||
.build()
|
.build()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<SecurityReference> defaultAuth() {
|
private List<SecurityReference> defaultAuth() {
|
||||||
AuthorizationScope[] authorizationScopes = {new AuthorizationScope("global", "accessEverything")};
|
AuthorizationScope[] authorizationScopes = {new AuthorizationScope("Admin api", "Access admin api")};
|
||||||
return Arrays.asList(new SecurityReference("Token from header", authorizationScopes),
|
return Arrays.asList(new SecurityReference("Token from header", authorizationScopes),
|
||||||
new SecurityReference("Token from query", authorizationScopes));
|
new SecurityReference("Token from query", authorizationScopes));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<SecurityReference> contentApiAuth() {
|
||||||
|
AuthorizationScope[] authorizationScopes = {new AuthorizationScope("content api", "Access content api")};
|
||||||
|
return Arrays.asList(new SecurityReference("Access key from header", authorizationScopes),
|
||||||
|
new SecurityReference("Access key from query", authorizationScopes));
|
||||||
|
}
|
||||||
|
|
||||||
private ApiInfo apiInfo() {
|
private ApiInfo apiInfo() {
|
||||||
return new ApiInfoBuilder()
|
return new ApiInfoBuilder()
|
||||||
.title("Halo API Documentation")
|
.title("Halo API Documentation")
|
||||||
|
|
Loading…
Reference in New Issue