Skip to content

docs: Create guide for signing requests to the Admin API #3690

@brad-dow

Description

@brad-dow

This issue comes from Max's feedback on the initial multi-tenancy docs update:

I think we also need a guide on how to sign requests to the Admin API, basically doing the inverse of the signature verification:

  const timestamp = Date.now()
  const version = process.env.SIGNATURE_VERSION

  const { query, variables, operationName } = request
  const formattedRequest = {
    variables,
    operationName,
    query: print(query)
  }

  const payload = `${timestamp}.${canonicalize(formattedRequest)}`
  const hmac = createHmac(
    'sha256',
    process.env.API_SECRET
  )
  hmac.update(payload)
  const digest = hmac.digest('hex')

  headers['signature'] = `t=${timestamp}, v${version}=${digest}`
  headers['tenant-id'] = process.env.OPERATOR_TENANT_ID

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Backlog

Status

In Progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions