auth

package
v0.0.0-...-73717b0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package auth credentials.go - the credentials data structure definition

Package auth signer.go - implement the specific sign algorithm of Attains Cloud V1 protocol

Index

Constants

This section is empty.

Variables

View Source
var (
	AttainsAuthVersion   = "attains-auth-v1"
	SignJoiner           = "\n"
	SignHeaderJoiner     = ";"
	DefaultExpireSeconds = 1800
	DefaultHeadersToSign = map[string]struct{}{
		strings.ToLower(metadata.RequestKeyHost):          {},
		strings.ToLower(metadata.RequestKeyContentLength): {},
		strings.ToLower(metadata.RequestKeyContentType):   {},
		strings.ToLower(metadata.RequestKeyContentMd5):    {},
	}
)

Functions

This section is empty.

Types

type AttainsCredentials

type AttainsCredentials struct {
	AccessKeyId     string // access key id to the service
	SecretAccessKey string // secret access key to the service
}

AttainsCredentials define the data structure for authorization

func NewAttainsCredentials

func NewAttainsCredentials(ak, sk string) (*AttainsCredentials, error)

func (*AttainsCredentials) String

func (a *AttainsCredentials) String() string

type AttainsV1Signer

type AttainsV1Signer struct{}

AttainsV1Signer implements the v1 sign algorithm

func (*AttainsV1Signer) Sign

Sign - generate the authorization string from the AttainsCredentials and SignOptions

PARAMS:

  • req: *http.Request for this sign
  • cred: *AttainsCredentials to access the service
  • opt: *SignOptions for this sign algorithm

type SignOptions

type SignOptions struct {
	HeadersToSign map[string]struct{}
	Timestamp     int64
	ExpireSeconds int
}

SignOptions defines the data structure used by Signer

func (*SignOptions) String

func (opt *SignOptions) String() string

type Signer

type Signer interface {
	// Sign the given Request with the Credentials and SignOptions
	Sign(*http.Request, logger.Interface, *AttainsCredentials, *SignOptions) error
}

Signer abstracts the entity that implements the `Sign` method

Jump to

Keyboard shortcuts

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