mirror of https://github.com/halo-dev/halo
Fix swagger security builder error
parent
259a47e238
commit
059054c425
|
@ -63,11 +63,13 @@ public class SwaggerConfiguration {
|
|||
|
||||
@Bean
|
||||
public Docket haloDefaultApi() {
|
||||
log.debug("Doc disabled: [{}]", haloProperties.isDocDisabled());
|
||||
// TODO Build with different security configuration
|
||||
if (haloProperties.isDocDisabled()) {
|
||||
log.debug("Doc has been disabled");
|
||||
}
|
||||
|
||||
return buildApiDocket("run.halo.app.content.api",
|
||||
"run.halo.app.controller.content.api",
|
||||
"/api/**")
|
||||
"/api/portal/**")
|
||||
.securitySchemes(portalApiKeys())
|
||||
.securityContexts(portalSecurityContext())
|
||||
.enable(!haloProperties.isDocDisabled());
|
||||
|
@ -75,8 +77,10 @@ public class SwaggerConfiguration {
|
|||
|
||||
@Bean
|
||||
public Docket haloAdminApi() {
|
||||
log.debug("Doc disabled: [{}]", haloProperties.isDocDisabled());
|
||||
// TODO Build with different security configuration
|
||||
if (haloProperties.isDocDisabled()) {
|
||||
log.debug("Doc has been disabled");
|
||||
}
|
||||
|
||||
return buildApiDocket("run.halo.app.admin",
|
||||
"run.halo.app.controller.admin",
|
||||
"/api/admin/**")
|
||||
|
@ -129,7 +133,7 @@ public class SwaggerConfiguration {
|
|||
return Collections.singletonList(
|
||||
SecurityContext.builder()
|
||||
.securityReferences(defaultAuth())
|
||||
.forPaths(PathSelectors.ant("/api/admin/**"))
|
||||
.forPaths(PathSelectors.regex("/api/admin/.*"))
|
||||
.build()
|
||||
);
|
||||
}
|
||||
|
@ -145,17 +149,17 @@ public class SwaggerConfiguration {
|
|||
return Collections.singletonList(
|
||||
SecurityContext.builder()
|
||||
.securityReferences(defaultAuth())
|
||||
.forPaths(PathSelectors.ant("/api/**"))
|
||||
.forPaths(PathSelectors.regex("/api/portal/.*"))
|
||||
.build()
|
||||
);
|
||||
}
|
||||
|
||||
private List<SecurityReference> defaultAuth() {
|
||||
AuthorizationScope[] authorizationScopes = {new AuthorizationScope("global", "accessEverything")};
|
||||
return Collections.singletonList(new SecurityReference("TOKEN ACCESS", authorizationScopes));
|
||||
return Arrays.asList(new SecurityReference("Token from header", authorizationScopes),
|
||||
new SecurityReference("Token from query", authorizationScopes));
|
||||
}
|
||||
|
||||
|
||||
private ApiInfo apiInfo() {
|
||||
return new ApiInfoBuilder()
|
||||
.title("Halo API Documentation")
|
||||
|
|
|
@ -16,7 +16,7 @@ import java.util.List;
|
|||
* @date 4/2/19
|
||||
*/
|
||||
@RestController("ApiContentArchiveController")
|
||||
@RequestMapping("/api/archives")
|
||||
@RequestMapping("/api/portal/archives")
|
||||
public class ArchiveController {
|
||||
|
||||
private final PostService postService;
|
||||
|
|
|
@ -21,7 +21,7 @@ import static org.springframework.data.domain.Sort.Direction.DESC;
|
|||
* @date 19-4-26
|
||||
*/
|
||||
@RestController("PortalJournalController")
|
||||
@RequestMapping("/api/journals")
|
||||
@RequestMapping("/api/portal/journals")
|
||||
public class JournalController {
|
||||
|
||||
private final JournalService journalService;
|
||||
|
|
|
@ -18,7 +18,7 @@ import java.util.List;
|
|||
* @date 4/3/19
|
||||
*/
|
||||
@RestController("ApiContentLinkController")
|
||||
@RequestMapping("/api/links")
|
||||
@RequestMapping("/api/portal/links")
|
||||
public class LinkController {
|
||||
|
||||
private final LinkService linkService;
|
||||
|
|
|
@ -20,7 +20,7 @@ import static org.springframework.data.domain.Sort.Direction.DESC;
|
|||
* @date 4/3/19
|
||||
*/
|
||||
@RestController("ApiContentMenuController")
|
||||
@RequestMapping("/api/menus")
|
||||
@RequestMapping("/api/portal/menus")
|
||||
public class MenuController {
|
||||
|
||||
private final MenuService menuService;
|
||||
|
|
|
@ -18,7 +18,7 @@ import java.util.Map;
|
|||
* @date 4/3/19
|
||||
*/
|
||||
@RestController("ApiContentOptionController")
|
||||
@RequestMapping("/api/options")
|
||||
@RequestMapping("/api/portal/options")
|
||||
public class OptionController {
|
||||
|
||||
private final OptionService optionService;
|
||||
|
|
|
@ -29,7 +29,7 @@ import static org.springframework.data.domain.Sort.Direction.DESC;
|
|||
* @date 4/2/19
|
||||
*/
|
||||
@RestController("ApiContentPostController")
|
||||
@RequestMapping("/api/posts")
|
||||
@RequestMapping("/api/portal/posts")
|
||||
public class PostController {
|
||||
|
||||
private final PostService postService;
|
||||
|
|
|
@ -23,7 +23,7 @@ import static org.springframework.data.domain.Sort.Direction.DESC;
|
|||
* @date 19-4-26
|
||||
*/
|
||||
@RestController("PortalSheetController")
|
||||
@RequestMapping("/api/sheets")
|
||||
@RequestMapping("/api/portal/sheets")
|
||||
public class SheetController {
|
||||
|
||||
private final SheetService sheetService;
|
||||
|
|
|
@ -27,7 +27,7 @@ import static org.springframework.data.domain.Sort.Direction.DESC;
|
|||
* @date 4/2/19
|
||||
*/
|
||||
@RestController("ApiContentTagController")
|
||||
@RequestMapping("/api/tags")
|
||||
@RequestMapping("/api/portal/tags")
|
||||
public class TagController {
|
||||
|
||||
private final TagService tagService;
|
||||
|
|
|
@ -14,7 +14,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|||
* @date 4/3/19
|
||||
*/
|
||||
@RestController("ApiContentUserController")
|
||||
@RequestMapping("/api/users")
|
||||
@RequestMapping("/api/portal/users")
|
||||
public class UserController {
|
||||
|
||||
private final UserService userService;
|
||||
|
|
Loading…
Reference in New Issue