This commit is contained in:
laodaming 2023-06-25 11:31:37 +08:00
parent 1a48387e92
commit cd8a578dfe
7 changed files with 21 additions and 0 deletions

View File

@ -31,6 +31,9 @@ func NewServiceContext(c config.Config) *ServiceContext {
func (svcCtx *ServiceContext) ParseJwtToken(r *http.Request) (jwt.MapClaims, error) { func (svcCtx *ServiceContext) ParseJwtToken(r *http.Request) (jwt.MapClaims, error) {
AuthKey := r.Header.Get("Authorization") AuthKey := r.Header.Get("Authorization")
if AuthKey == "" {
return nil, nil
}
if len(AuthKey) <= 50 { if len(AuthKey) <= 50 {
return nil, errors.New(fmt.Sprint("Error parsing token, len:", len(AuthKey))) return nil, errors.New(fmt.Sprint("Error parsing token, len:", len(AuthKey)))
} }

View File

@ -31,6 +31,9 @@ func NewServiceContext(c config.Config) *ServiceContext {
func (svcCtx *ServiceContext) ParseJwtToken(r *http.Request) (jwt.MapClaims, error) { func (svcCtx *ServiceContext) ParseJwtToken(r *http.Request) (jwt.MapClaims, error) {
AuthKey := r.Header.Get("Authorization") AuthKey := r.Header.Get("Authorization")
if AuthKey == "" {
return nil, nil
}
if len(AuthKey) <= 50 { if len(AuthKey) <= 50 {
return nil, errors.New(fmt.Sprint("Error parsing token, len:", len(AuthKey))) return nil, errors.New(fmt.Sprint("Error parsing token, len:", len(AuthKey)))
} }

View File

@ -31,6 +31,9 @@ func NewServiceContext(c config.Config) *ServiceContext {
func (svcCtx *ServiceContext) ParseJwtToken(r *http.Request) (jwt.MapClaims, error) { func (svcCtx *ServiceContext) ParseJwtToken(r *http.Request) (jwt.MapClaims, error) {
AuthKey := r.Header.Get("Authorization") AuthKey := r.Header.Get("Authorization")
if AuthKey == "" {
return nil, nil
}
if len(AuthKey) <= 50 { if len(AuthKey) <= 50 {
return nil, errors.New(fmt.Sprint("Error parsing token, len:", len(AuthKey))) return nil, errors.New(fmt.Sprint("Error parsing token, len:", len(AuthKey)))
} }

View File

@ -31,6 +31,9 @@ func NewServiceContext(c config.Config) *ServiceContext {
func (svcCtx *ServiceContext) ParseJwtToken(r *http.Request) (jwt.MapClaims, error) { func (svcCtx *ServiceContext) ParseJwtToken(r *http.Request) (jwt.MapClaims, error) {
AuthKey := r.Header.Get("Authorization") AuthKey := r.Header.Get("Authorization")
if AuthKey == "" {
return nil, nil
}
if len(AuthKey) <= 50 { if len(AuthKey) <= 50 {
return nil, errors.New(fmt.Sprint("Error parsing token, len:", len(AuthKey))) return nil, errors.New(fmt.Sprint("Error parsing token, len:", len(AuthKey)))
} }

View File

@ -31,6 +31,9 @@ func NewServiceContext(c config.Config) *ServiceContext {
func (svcCtx *ServiceContext) ParseJwtToken(r *http.Request) (jwt.MapClaims, error) { func (svcCtx *ServiceContext) ParseJwtToken(r *http.Request) (jwt.MapClaims, error) {
AuthKey := r.Header.Get("Authorization") AuthKey := r.Header.Get("Authorization")
if AuthKey == "" {
return nil, nil
}
if len(AuthKey) <= 50 { if len(AuthKey) <= 50 {
return nil, errors.New(fmt.Sprint("Error parsing token, len:", len(AuthKey))) return nil, errors.New(fmt.Sprint("Error parsing token, len:", len(AuthKey)))
} }

View File

@ -31,6 +31,9 @@ func NewServiceContext(c config.Config) *ServiceContext {
func (svcCtx *ServiceContext) ParseJwtToken(r *http.Request) (jwt.MapClaims, error) { func (svcCtx *ServiceContext) ParseJwtToken(r *http.Request) (jwt.MapClaims, error) {
AuthKey := r.Header.Get("Authorization") AuthKey := r.Header.Get("Authorization")
if AuthKey == "" {
return nil, nil
}
if len(AuthKey) <= 50 { if len(AuthKey) <= 50 {
return nil, errors.New(fmt.Sprint("Error parsing token, len:", len(AuthKey))) return nil, errors.New(fmt.Sprint("Error parsing token, len:", len(AuthKey)))
} }

View File

@ -31,6 +31,9 @@ func NewServiceContext(c config.Config) *ServiceContext {
func (svcCtx *ServiceContext) ParseJwtToken(r *http.Request) (jwt.MapClaims, error) { func (svcCtx *ServiceContext) ParseJwtToken(r *http.Request) (jwt.MapClaims, error) {
AuthKey := r.Header.Get("Authorization") AuthKey := r.Header.Get("Authorization")
if AuthKey == "" {
return nil, nil
}
if len(AuthKey) <= 50 { if len(AuthKey) <= 50 {
return nil, errors.New(fmt.Sprint("Error parsing token, len:", len(AuthKey))) return nil, errors.New(fmt.Sprint("Error parsing token, len:", len(AuthKey)))
} }