18 lines
578 B
Python
18 lines
578 B
Python
|
|
"""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',
|
||
|
|
}
|