最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

python - How to change drf-spectacular scheme in one microservice(DRF) to use JWT token from another microservice(FastAPI)? - St

programmeradmin3浏览0评论

This scheme uses a built-in JWT auth part for Swagger and I need to input token in Authorize form, but how to connect microservices so that the one microservice(DRF) used the JWT token from another microservice(FastAPI) without Authorize form?

from drf_spectacular.extensions import OpenApiAuthenticationExtension
from drf_spectacular.plumbing import build_bearer_security_scheme_object


class JWTAuthScheme(OpenApiAuthenticationExtension):
    target_class = "app.auth.JWTAuthentication"
    name = "JWTAuth"

    def get_security_definition(self, auto_schema):
        return build_bearer_security_scheme_object(
            header_name="Authorization", token_prefix="Bearer"
        )

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论