Documentation ¶
Index ¶
- Constants
- Variables
- func SetupExternalCreds(ctx context.Context, log hclog.Logger, token string) (credentials.PerRPCCredentials, error)
- func StripCreds(tt *pb.TokenTransport) (string, error)
- func TokenDecode(token string) (*pb.TokenTransport, *pb.Token, error)
- func TokenFromContext(ctx context.Context) string
- func TokenWithContext(ctx context.Context, t string) context.Context
- type ContextToken
- type StaticToken
- type TokenAndAuth
Constants ¶
const MetadataKey = "waypoint-token"
const ( // TokenMagic is used as a byte sequence prepended to the encoded TokenTransport to identify // the token as valid before attempting to decode it. This is mostly a nicity to improve // understanding of the token data and error messages. TokenMagic = "wp24" )
Variables ¶
var (
ErrInvalidToken = errors.New("invalid token detected")
)
Functions ¶
func SetupExternalCreds ¶
func SetupExternalCreds(ctx context.Context, log hclog.Logger, token string) (credentials.PerRPCCredentials, error)
func StripCreds ¶
func StripCreds(tt *pb.TokenTransport) (string, error)
StripCreds removes the credentials from the given TokenTransport and repackages it up as a string. This doesn't invalidate the signature, because the signature is only against the body field of the transport.
func TokenDecode ¶
TokenDecode provides the ability to decode a waypoint token into the embedded protobuf. WARNING: This function is unable to verify the token, only the server that generate the server can do that.
func TokenFromContext ¶
TokenFromContext extracts a token (if any) from the given context.
Types ¶
type ContextToken ¶
type ContextToken string
ContextToken implements grpc.WithPerRPCCredentials and extracts the token from the context or otherwise falls back to a default string value (which might be empty).
func (ContextToken) GetRequestMetadata ¶
func (ContextToken) RequireTransportSecurity ¶
func (t ContextToken) RequireTransportSecurity() bool
type StaticToken ¶
type StaticToken string
This is a weird type that only exists to satisify the interface required by grpc.WithPerRPCCredentials. That api is designed to incorporate things like OAuth but in our case, we really just want to send this static token through, but we still need to the dance.
func (StaticToken) GetRequestMetadata ¶
func (StaticToken) RequireTransportSecurity ¶
func (t StaticToken) RequireTransportSecurity() bool
type TokenAndAuth ¶
type TokenAndAuth struct { credentials.PerRPCCredentials Token string }
TokenAndAuth is a special version of PerRPCCredentials that lets us pass the authorization metadata as well as the waypoint token in a separate field