diff --git a/src/main/java/com/mytiki/l0_storage/features/latest/report/ReportController.java b/src/main/java/com/mytiki/l0_storage/features/latest/report/ReportController.java index 8a08914..f1bc046 100644 --- a/src/main/java/com/mytiki/l0_storage/features/latest/report/ReportController.java +++ b/src/main/java/com/mytiki/l0_storage/features/latest/report/ReportController.java @@ -5,18 +5,12 @@ package com.mytiki.l0_storage.features.latest.report; -import com.mytiki.l0_storage.utilities.Constants; import com.mytiki.spring_rest_api.ApiConstants; import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.security.SecurityRequirement; -import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.annotation.security.RolesAllowed; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.*; -@Tag(name = "STORAGE") @RestController @RequestMapping(value = ReportController.PATH_CONTROLLER) public class ReportController { @@ -29,13 +23,7 @@ public ReportController(ReportService service) { } @RolesAllowed("REMOTE") - @Operation(operationId = Constants.PROJECT_DASH_PATH + "-report-post", - summary = "Report Usage", - description = "Submit a usage report (handled automatically by Upload)", - security = @SecurityRequirement(name = "remote"), - responses = { - @ApiResponse(responseCode = "204", description = "No Content", content = @Content), - @ApiResponse(responseCode = "403", description = "Forbidden", content = @Content)}) + @Operation(hidden = true) @RequestMapping(method = RequestMethod.POST) @ResponseStatus(value = HttpStatus.NO_CONTENT) public void post(@RequestBody ReportAOReq body){ diff --git a/src/main/java/com/mytiki/l0_storage/features/latest/token/TokenController.java b/src/main/java/com/mytiki/l0_storage/features/latest/token/TokenController.java index b27c2ad..961273b 100644 --- a/src/main/java/com/mytiki/l0_storage/features/latest/token/TokenController.java +++ b/src/main/java/com/mytiki/l0_storage/features/latest/token/TokenController.java @@ -10,9 +10,6 @@ import com.mytiki.spring_rest_api.ApiConstants; import com.mytiki.spring_rest_api.ApiExceptionBuilder; import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.tags.Tag; import org.springframework.http.HttpStatus; @@ -25,7 +22,7 @@ import java.security.Principal; -@Tag(name = "STORAGE") +@Tag(name = "") @RestController @RequestMapping(value = TokenController.PATH_CONTROLLER) public class TokenController { @@ -41,13 +38,7 @@ public TokenController(TokenService service) { @Operation(operationId = Constants.PROJECT_DASH_PATH + "-token-post", summary = "Request Access Token", description = "Request an access token for uploading to storage bucket", - security = @SecurityRequirement(name = "jwt"), - responses = { - @ApiResponse(responseCode = "200", description = "OK", - content = @Content(schema = @Schema(implementation = TokenAORsp.class))), - @ApiResponse(responseCode = "400", description = "Bad Request", content = @Content), - @ApiResponse(responseCode = "403", description = "Forbidden", content = @Content), - @ApiResponse(responseCode = "417", description = "Expectation Failed", content = @Content)}) + security = @SecurityRequirement(name = "oauth")) @RequestMapping(method = RequestMethod.POST) public TokenAORsp post( Authentication authentication, diff --git a/src/main/java/com/mytiki/l0_storage/main/AppConfig.java b/src/main/java/com/mytiki/l0_storage/main/AppConfig.java index 4636b32..3b92ecd 100644 --- a/src/main/java/com/mytiki/l0_storage/main/AppConfig.java +++ b/src/main/java/com/mytiki/l0_storage/main/AppConfig.java @@ -23,7 +23,7 @@ import io.swagger.v3.oas.models.parameters.RequestBody; import io.swagger.v3.oas.models.responses.ApiResponse; import io.swagger.v3.oas.models.responses.ApiResponses; -import io.swagger.v3.oas.models.security.SecurityScheme; +import io.swagger.v3.oas.models.security.*; import io.swagger.v3.oas.models.servers.Server; import jakarta.annotation.PostConstruct; import org.bouncycastle.jce.provider.BouncyCastleProvider; @@ -33,6 +33,7 @@ import java.security.Security; import java.util.Collections; +import java.util.List; import java.util.TimeZone; @Import({ @@ -54,7 +55,7 @@ public OpenAPI oenAPI(@Value("${springdoc.version}") String appVersion) { return new OpenAPI() .info(new Info() .title("L0 Storage") - .description("Long-term immutable storage") + .description("Immutable Storage Service") .version(appVersion) .license(new License() .name("MIT") @@ -63,43 +64,29 @@ public OpenAPI oenAPI(@Value("${springdoc.version}") String appVersion) { new Server() .url("https://storage.l0.mytiki.com"))) .components(new Components() - .addSecuritySchemes("remote", - new SecurityScheme() - .type(SecurityScheme.Type.HTTP) - .scheme("basic")) - .addSecuritySchemes("jwt", - new SecurityScheme() - .type(SecurityScheme.Type.HTTP) - .scheme("bearer") - .bearerFormat("JWT"))) - .path("/api/latest/upload", - new PathItem().post( - new Operation() - .tags(Collections.singletonList("STORAGE")) - .operationId(Constants.PROJECT_DASH_PATH + "-upload-post") - .summary("Upload Content") - .description("Upload a block/pub.key to storage bucket") - .requestBody(new RequestBody() - .content(new Content() - .addMediaType("application/json", - new MediaType() - .schema(new JsonSchema() - .type("object") - .addProperty("key", new StringSchema()) - .addProperty("content", new StringSchema()) - )))) - .responses(new ApiResponses() - .addApiResponse("201", - new ApiResponse().description("Created")) - .addApiResponse("400", - new ApiResponse().description("Bad Request")) - .addApiResponse("401", - new ApiResponse().description("Unauthorized")) - .addApiResponse("405", - new ApiResponse().description("Method Not Allowed")) - .addApiResponse("413", - new ApiResponse().description("Payload Too Large")) - .addApiResponse("424", - new ApiResponse().description("Failed Dependency"))))); + .addSecuritySchemes("oauth", new SecurityScheme() + .type(SecurityScheme.Type.OAUTH2) + .flows(new OAuthFlows() + .clientCredentials(new OAuthFlow() + .tokenUrl("https://auth.l0.mytiki.com/api/latest/oauth/token") + .refreshUrl("https://auth.l0.mytiki.com/api/latest/oauth/token") + .scopes(new Scopes().addString("storage","this service"))))) + .addSecuritySchemes("jwt", new SecurityScheme() + .type(SecurityScheme.Type.HTTP) + .scheme("bearer") + .bearerFormat("JWT"))) + .path("/api/latest/upload", new PathItem().post(new Operation() + .tags(Collections.singletonList("")) + .operationId(Constants.PROJECT_DASH_PATH + "-upload-post") + .summary("Upload Content") + .security(List.of(new SecurityRequirement().addList("jwt"))) + .description("Upload a block/pub.key to storage bucket") + .requestBody(new RequestBody().content(new Content() + .addMediaType("application/json", new MediaType() + .schema(new JsonSchema().type("object") + .addProperty("key", new StringSchema()) + .addProperty("content", new StringSchema()))))) + .responses(new ApiResponses() + .addApiResponse("201", new ApiResponse().description("Created"))))); } } \ No newline at end of file