ad327bedb1
* Satellite signs proofs * wip * remove direct apikey usage from pdbclient * adjusting unit tests * fix linter errors * unit tests * linter errors * remove usless interface * remove unused code * improve unit tests * signature generation * code review changes * code review comments * back to satellite-id signature generation * remove go-grpc-middlewar dependency * small step back * linter fixes * fix tests * packages reorganization * Move TestAPIKeyInjector to grpcauth package
25 lines
617 B
Go
25 lines
617 B
Go
// Copyright (C) 2018 Storj Labs, Inc.
|
|
// See LICENSE for copying information.
|
|
|
|
package auth
|
|
|
|
import "context"
|
|
|
|
// The key type is unexported to prevent collisions with context keys defined in
|
|
// other packages.
|
|
type key int
|
|
|
|
// apiKey is the context key for the user API Key
|
|
const apiKey key = 0
|
|
|
|
// WithAPIKey creates context with api key
|
|
func WithAPIKey(ctx context.Context, key []byte) context.Context {
|
|
return context.WithValue(ctx, apiKey, key)
|
|
}
|
|
|
|
// GetAPIKey returns api key from context is exists
|
|
func GetAPIKey(ctx context.Context) ([]byte, bool) {
|
|
key, ok := ctx.Value(apiKey).([]byte)
|
|
return key, ok
|
|
}
|