Quarkus with Swagger UI apply global authorization

Viewed 2097

I have configured OpenAPI using @OpenAPIDefinition annotation to show the authorize (button) on the Swagger UI, but currently it has no functinality, when I try to authenticate it does nothing (no request is performed).

What I want to achieve is authenticate via the authorize button on the Swagger UI; then extract the token and pass it as a Authorization header on all endpoints.

How to configure and utilize the authorize functionality and then make it available globaly for all endpoints?

My application is secured using the HTTP with Bearer method.

Current config of the Swagger UI authentication

@OpenAPIDefinition(
    info = @Info(
            title = "My API",
            version = "1.0.0"
    ),
    components = @Components(
            securitySchemes = {
                    @SecurityScheme(
                            securitySchemeName = "bearerAuth",
                            type = SecuritySchemeType.HTTP,
                            scheme = "bearer",
                            bearerFormat = "JWT"
                    ),
                    @SecurityScheme(
                            securitySchemeName = "basic",
                            type = SecuritySchemeType.HTTP,
                            scheme = "basic"
                    )
            }
    ),
    security = {
            @SecurityRequirement(name = "bearerAuth"),
            @SecurityRequirement(name = "basic")
    }
)
public class CustomApi extends Application { }
1 Answers
Related