知识卡片

普通读书笔记卡 · 3487.h

认证方案写入OpenAPI

理解等级:中级

受保护 API 的 OpenAPI 文档应说明客户端如何认证和授权。components.securitySchemes 定义可用方案,例如 OpenID Connect、OAuth2 或 bearer;方案中再写发现地址、取令牌地址或凭证格式等必要信息。它描述接入要求,不会自动替代服务端鉴权实现。

这张卡片看不懂?

已有反馈 · 0 / 10 条

    还没有人提交反馈。

    原书出处

    参考来源

    - 位置:《Microservice APIs》第 5 章《Documenting REST APIs with OpenAPI》(源文件:_epub-src/OEBPS/Text/05.htm) - 结论依据:原文说明受保护 API 需在文档中描述认证授权方式,并用 securitySchemes 下的 OIDC、OAuth2 和 bearer 示例给出配置字段。 - 原始内容:If our API is protected, the API specification must describe how users need to authenticate and authorize their requests. ... The security definitions of the API go within the components section of the specification, under the securitySchemes header. With OpenAPI, we can describe different security schemes, such as HTTP-based authentication, key-based authentication, Open Authorization 2 (OAuth2 ), and OpenID Connect.