mirror of
https://github.com/OliveTin/OliveTin
synced 2026-09-27 04:05:44 +00:00
feat: support multiple user groups (#555)
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user