Swagger 2.0 YAML中的AWS授权

问题描述

我正在使用Swagger UI查询企业S3实例,需要使用AccessKey和SecretKey中的AWS签名。在Postman中,这将产生以下格式的授权标头:

“授权:AWS4-HMAC-SHA256 凭据= <... accesskey ...> // us-east-1 / execute-api / aws4_request,SignedHeaders = host; x-amz-date,Signature = <......>“

如果我正在使用Swagger YAML(如下所示),该如何完成以下两项操作?

  1. 定义“安全性”和“ securityDeFinitions”以允许用户通过和进行身份验证

  1. 生成签名并使用带有内置凭据的Authorization标头进行身份验证

**我会注意到,该YAML正在进行中,是从Postman集合中生成/转换的,因此这就是为什么不充实响应类型的原因

swagger: '2.0'
info:
  version: '1.0'
  title: POC
  contact: 
    name: 
    email: 
host: <s3 endpoint>
basePath: /<bucket>
schemes:
- https
consumes:
- application/json
produces:
- application/json
securityDeFinitions:
  ????
paths:
  /{resource}:
    put:
      summary: PUT in Bucket
      tags:
      - Misc
      operationId: PUTinBucket
      deprecated: false
      produces:
      - application/json
      consumes:
      - multipart/form-data
      parameters:
      - name: File
        in: formData
        required: true
        type: file
        format: file
        description: ''
      - name: resource
        type: string
        required: true
        in: path
        description: Identifier/Name of the resource to upload
      responses:
        200:
          description: ''
          headers: {}
    get:
      summary: GET Object from Bucket
      tags:
      - Misc
      operationId: GetobjectfromBucket
      deprecated: false
      produces:
      - application/json
      parameters: 
      - name: resource
        type: string
        required: true
        in: path
        description: Identifier/Name of the resource to download
      responses:
        200:
          description: ''
          headers: {}
    delete:
      summary: DELETE Object from Bucket
      tags:
      - Misc
      operationId: DELETEObjectfromBucket
      deprecated: false
      produces:
      - application/json
      parameters:
      - name: resource
        type: string
        required: true
        in: path
        description: Identifier/Name of the resource to delete
      responses:
        200:
          description: ''
          headers: {}
tags:
- name: Misc
  description: ''
security:
- ???: []

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)