Add security ApiBearerAuth annonation

This commit is contained in:
Sambo Chea 2021-12-11 12:44:05 +07:00
parent 4561e68c28
commit bba03096a5
Signed by: sombochea
GPG Key ID: 3C7CF22A05D95490
2 changed files with 10 additions and 3 deletions

View File

@ -0,0 +1,8 @@
package com.cubetiqs.web.annotation
import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.security.SecurityRequirement
@Retention(AnnotationRetention.RUNTIME)
@Operation(security = [SecurityRequirement(name = "bearerAuth")])
annotation class ApiBearerAuth()

View File

@ -1,9 +1,8 @@
package com.cubetiqs.web.controller.admin
import com.cubetiqs.web.annotation.ApiBearerAuth
import com.cubetiqs.web.controller.BaseController
import com.cubetiqs.web.util.RouteConstants
import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.security.SecurityRequirement
import io.swagger.v3.oas.annotations.tags.Tag
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RequestMapping
@ -13,7 +12,7 @@ import org.springframework.web.bind.annotation.RestController
@RestController
@RequestMapping(RouteConstants.ADMIN)
class AdminController : BaseController {
@Operation(security = [SecurityRequirement(name = "bearerAuth")])
@ApiBearerAuth
@GetMapping
fun getAdmin(): String {
return "Admin"