This commit is contained in:
david 2024-09-17 21:57:37 +08:00
parent 84d6a9d034
commit 0be9490840
1 changed files with 6 additions and 5 deletions

View File

@ -2,9 +2,9 @@ package service
import (
"context"
"encoding/json"
"strings"
"git.apinb.com/bsm-sdk/engine/encipher"
"git.apinb.com/bsm-sdk/engine/exception"
"git.apinb.com/bsm-sdk/engine/types"
"google.golang.org/grpc/metadata"
@ -23,14 +23,15 @@ func ParseMetaCtx(ctx context.Context, opts *ParseOptions) (*types.JwtClaims, er
return nil, exception.ErrAuthNotFound
}
var Authorizations []string = md.Get("authorization")
var Authorizations []string = md.Get("authorization_claims")
if len(Authorizations) == 0 || Authorizations[0] == "" {
return nil, exception.ErrAuthNotFound
}
claims, err := encipher.ParseTokenAes(Authorizations[0])
var claims types.JwtClaims
err := json.Unmarshal([]byte(Authorizations[0]), &claims)
if err != nil {
return nil, err
return nil, exception.ErrAuthParseFail
}
if opts != nil {
@ -39,6 +40,6 @@ func ParseMetaCtx(ctx context.Context, opts *ParseOptions) (*types.JwtClaims, er
}
}
return claims, nil
return &claims, nil
}