feat: support multiple user groups (#555)

This commit is contained in:
Noah Perks Sloan
2025-04-08 20:31:55 +00:00
committed by GitHub
parent 2fcc0a63a0
commit b742bd89c4
5 changed files with 128 additions and 5 deletions
+6 -2
View File
@@ -55,8 +55,7 @@ func parseRequestMetadata(ctx context.Context, req *http.Request) metadata.MD {
sid := ""
if cfg.AuthJwtHeader != "" {
// JWTs in the Authorization header are usually prefixed with "Bearer " which is not part of the JWT token.
username, usergroup = parseJwt(strings.TrimPrefix(req.Header.Get(cfg.AuthJwtHeader), "Bearer "))
username, usergroup = parseJwtHeader(req)
provider = "jwt-header"
}
@@ -92,6 +91,11 @@ func parseRequestMetadata(ctx context.Context, req *http.Request) metadata.MD {
return md
}
func parseJwtHeader(req *http.Request) (string, string) {
// JWTs in the Authorization header are usually prefixed with "Bearer " which is not part of the JWT token.
return parseJwt(strings.TrimPrefix(req.Header.Get(cfg.AuthJwtHeader), "Bearer "))
}
func forwardResponseHandler(ctx context.Context, w http.ResponseWriter, msg protoreflect.ProtoMessage) error {
md, ok := runtime.ServerMetadataFromContext(ctx)