Skip to content

Commit

Permalink
internal/auth: remove authn annotator
Browse files Browse the repository at this point in the history
gRPC Gateway performs this automatically.

Signed-off-by: Jimmy Zelinskie <jimmy@zelinskie.com>
  • Loading branch information
jzelinskie committed Oct 25, 2021
1 parent c36faef commit 536b4a2
Showing 1 changed file with 0 additions and 15 deletions.
15 changes: 0 additions & 15 deletions internal/auth/presharedkey.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ import (
"crypto/subtle"
"errors"
"fmt"
"net/http"

grpcauth "github.com/grpc-ecosystem/go-grpc-middleware/auth"
"google.golang.org/grpc/metadata"
)

const errInvalidPresharedKey = "invalid preshared key: %w"
Expand All @@ -31,16 +29,3 @@ func RequirePresharedKey(presharedKey string) grpcauth.AuthFunc {
return ctx, nil
}
}

// PresharedKeyAnnotator copies the Authorization header from an HTTP request
// and sets it on the gRPC context.
func PresharedKeyAnnotator(ctx context.Context, r *http.Request) metadata.MD {
md, ok := metadata.FromIncomingContext(ctx)
if ok {
md = md.Copy()
} else {
md = metadata.New(map[string]string{})
}
md.Append("authorization", r.Header.Get("Authorization"))
return md
}

0 comments on commit 536b4a2

Please sign in to comment.