Files

18 lines
578 B
Python
Raw Permalink Normal View History

2026-05-29 15:58:00 +08:00
"""drf-spectacular 扩展:注册自定义认证类的 OpenAPI 映射。"""
from drf_spectacular.extensions import OpenApiAuthenticationExtension
class RedisBlacklistJWTScheme(OpenApiAuthenticationExtension):
"""让 drf-spectacular 将 RedisBlacklistJWTAuthentication 识别为 Bearer JWT。"""
target_class = 'apps.user.authentication.RedisBlacklistJWTAuthentication'
name = 'jwtAuth'
def get_security_definition(self, auto_schema):
return {
'type': 'http',
'scheme': 'bearer',
'bearerFormat': 'JWT',
}