common

package
v2.6.4-rc2 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2021 License: MIT Imports: 7 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func APIKeyFromContext

func APIKeyFromContext(ctx context.Context) (string, bool)

APIKeyFromContext returns an API key from a context.

func APIKeyFromMD

func APIKeyFromMD(ctx context.Context) (key string, ok bool)

APIKeyFromMD returns an API key from context metadata.

func APISigFromContext

func APISigFromContext(ctx context.Context) (msg string, sig []byte, ok bool)

APISigFromContext returns a message and signature from a context.

func APISigFromMD

func APISigFromMD(ctx context.Context) (msg string, sig []byte, ok bool)

APISigFromMD returns a message and signature from context metadata.

func CreateAPISigContext

func CreateAPISigContext(ctx context.Context, date time.Time, secret string) (context.Context, error)

CreateAPISigContext creates an HMAC signature and adds it to a context, with secret as the key and SHA256 as the hash algorithm. An RFC 3339 date string is used as the message. Date must be sometime in the future. Dates closer to now are more secure.

func NewAPIKeyContext

func NewAPIKeyContext(ctx context.Context, key string) context.Context

NewAPIKeyContext adds an API key to a context.

func NewAPISigContext

func NewAPISigContext(ctx context.Context, msg string, sig []byte) context.Context

NewAPISigContext adds an API key signature to a context.

func NewOrgSlugContext

func NewOrgSlugContext(ctx context.Context, slug string) context.Context

NewOrgSlugContext adds an org name to a context.

func NewSessionContext

func NewSessionContext(ctx context.Context, session string) context.Context

NewSessionContext adds a session to a context.

func NewThreadIDContext

func NewThreadIDContext(ctx context.Context, id thread.ID) context.Context

NewThreadIDContext adds a thread ID to a context.

func NewThreadNameContext

func NewThreadNameContext(ctx context.Context, name string) context.Context

NewThreadNameContext adds a thread name to a context, which is used to name threads and dbs during creation. Thread names may be useful for some app logic, but are not required.

func OrgSlugFromContext

func OrgSlugFromContext(ctx context.Context) (string, bool)

OrgSlugFromContext returns an org name from a context.

func OrgSlugFromMD

func OrgSlugFromMD(ctx context.Context) (slug string, ok bool)

OrgSlugFromMD returns an org name from context metadata.

func SessionFromContext

func SessionFromContext(ctx context.Context) (string, bool)

SessionFromContext returns a session from a context.

func SessionFromMD

func SessionFromMD(ctx context.Context) (session string, ok bool)

SessionFromMD returns a session from context metadata.

func ThreadIDFromContext

func ThreadIDFromContext(ctx context.Context) (thread.ID, bool)

ThreadIDFromContext returns a thread ID from a context.

func ThreadIDFromMD

func ThreadIDFromMD(ctx context.Context) (id thread.ID, ok bool)

ThreadIDFromMD returns a thread ID from context metadata.

func ThreadNameFromContext

func ThreadNameFromContext(ctx context.Context) (string, bool)

ThreadNameFromContext returns a thread name from a context.

func ThreadNameFromMD

func ThreadNameFromMD(ctx context.Context) (name string, ok bool)

ThreadNameFromMD returns a thread name from context metadata.

func ValidateAPISigContext

func ValidateAPISigContext(ctx context.Context, secret string) bool

ValidateAPISigContext re-computes the hash from a context using secret as key. This method returns true only if the hashes are equal and the message is a valid RFC 3339 date string sometime in the future.

Types

type Credentials

type Credentials struct {
	Secure bool
}

Credentials implements grpc.PerRPCCredentials.

func (Credentials) GetRequestMetadata

func (c Credentials) GetRequestMetadata(ctx context.Context, _ ...string) (map[string]string, error)

func (Credentials) RequireTransportSecurity

func (c Credentials) RequireTransportSecurity() bool

Jump to

Keyboard shortcuts

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