Documentation ¶
Index ¶
- func APIKeyFromContext(ctx context.Context) (string, bool)
- func APIKeyFromMD(ctx context.Context) (key string, ok bool)
- func APISigFromContext(ctx context.Context) (msg string, sig []byte, ok bool)
- func APISigFromMD(ctx context.Context) (msg string, sig []byte, ok bool)
- func CreateAPISigContext(ctx context.Context, date time.Time, secret string) (context.Context, error)
- func NewAPIKeyContext(ctx context.Context, key string) context.Context
- func NewAPISigContext(ctx context.Context, msg string, sig []byte) context.Context
- func NewOrgSlugContext(ctx context.Context, slug string) context.Context
- func NewSessionContext(ctx context.Context, session string) context.Context
- func NewThreadIDContext(ctx context.Context, id thread.ID) context.Context
- func NewThreadNameContext(ctx context.Context, name string) context.Context
- func OrgSlugFromContext(ctx context.Context) (string, bool)
- func OrgSlugFromMD(ctx context.Context) (slug string, ok bool)
- func SessionFromContext(ctx context.Context) (string, bool)
- func SessionFromMD(ctx context.Context) (session string, ok bool)
- func ThreadIDFromContext(ctx context.Context) (thread.ID, bool)
- func ThreadIDFromMD(ctx context.Context) (id thread.ID, ok bool)
- func ThreadNameFromContext(ctx context.Context) (string, bool)
- func ThreadNameFromMD(ctx context.Context) (name string, ok bool)
- func ValidateAPISigContext(ctx context.Context, secret string) bool
- type Credentials
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func APIKeyFromContext ¶
APIKeyFromContext returns an API key from a context.
func APIKeyFromMD ¶
APIKeyFromMD returns an API key from context metadata.
func APISigFromContext ¶
APISigFromContext returns a message and signature from a context.
func APISigFromMD ¶
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 ¶
NewAPIKeyContext adds an API key to a context.
func NewAPISigContext ¶
NewAPISigContext adds an API key signature to a context.
func NewOrgSlugContext ¶
NewOrgSlugContext adds an org name to a context.
func NewSessionContext ¶
NewSessionContext adds a session to a context.
func NewThreadIDContext ¶
NewThreadIDContext adds a thread ID to a context.
func NewThreadNameContext ¶
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 ¶
OrgSlugFromContext returns an org name from a context.
func OrgSlugFromMD ¶
OrgSlugFromMD returns an org name from context metadata.
func SessionFromContext ¶
SessionFromContext returns a session from a context.
func SessionFromMD ¶
SessionFromMD returns a session from context metadata.
func ThreadIDFromContext ¶
ThreadIDFromContext returns a thread ID from a context.
func ThreadIDFromMD ¶
ThreadIDFromMD returns a thread ID from context metadata.
func ThreadNameFromContext ¶
ThreadNameFromContext returns a thread name from a context.
func ThreadNameFromMD ¶
ThreadNameFromMD returns a thread name from context metadata.
func ValidateAPISigContext ¶
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 (Credentials) RequireTransportSecurity ¶
func (c Credentials) RequireTransportSecurity() bool