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