ocisign

package
v1.5.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 18, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package ocisign signs HTTP requests for the OCI API with the draft-cavage "Signature" scheme, using only the standard library.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Headers

func Headers(method string) []string

Headers returns the signed header list for a method. Body methods add the three body headers, in the order OCI documents.

func KeyID

func KeyID(tenancyOCID, userOCID, fingerprint string) string

KeyID builds the keyId field: tenancy/user/fingerprint.

func SigningString

func SigningString(req *http.Request) string

SigningString builds the text the signature covers for req. The body headers must already be set on req for POST, PUT and PATCH.

Types

type Signer

type Signer struct {
	KeyID         string
	Key           *rsa.PrivateKey
	Now           func() time.Time
	AllowInsecure bool
}

Signer holds one API key. AllowInsecure exists so tests can use a plain httptest server.

func (Signer) Sign

func (s Signer) Sign(req *http.Request, body []byte) error

Sign sets Date and Authorization, and for POST, PUT and PATCH also the body headers. body must be the exact bytes to send: a stream would make the hash and length unknown. Call it again on every retry so the Date is fresh.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL