From 002b5c1dad9ba24baa4b54edab586c5f49136152 Mon Sep 17 00:00:00 2001 From: Kristoffer Dalby Date: Fri, 29 Oct 2021 17:08:21 +0000 Subject: [PATCH] Add grpc token auth struct --- cmd/headscale/cli/utils.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/cmd/headscale/cli/utils.go b/cmd/headscale/cli/utils.go index 0768e1eb..30d5d83a 100644 --- a/cmd/headscale/cli/utils.go +++ b/cmd/headscale/cli/utils.go @@ -312,3 +312,18 @@ func HasJsonOutputFlag() bool { } return false } + +type tokenAuth struct { + token string +} + +// Return value is mapped to request headers. +func (t tokenAuth) GetRequestMetadata(ctx context.Context, in ...string) (map[string]string, error) { + return map[string]string{ + "authorization": "Bearer " + t.token, + }, nil +} + +func (tokenAuth) RequireTransportSecurity() bool { + return true +}