Auth: support JWT Authentication (#29995)

This commit is contained in:
Vladimir Kochnev
2021-03-31 15:40:44 +00:00
committed by GitHub
parent 1446d094b8
commit 39a3b0d0b0
22 changed files with 1444 additions and 4 deletions
+31
View File
@@ -0,0 +1,31 @@
package models
import (
"context"
)
type JWTClaims map[string]interface{}
type JWTService interface {
Verify(ctx context.Context, strToken string) (JWTClaims, error)
}
type FakeJWTService struct {
VerifyProvider func(context.Context, string) (JWTClaims, error)
}
func (s *FakeJWTService) Verify(ctx context.Context, token string) (JWTClaims, error) {
return s.VerifyProvider(ctx, token)
}
func (s *FakeJWTService) Init() error {
return nil
}
func NewFakeJWTService() *FakeJWTService {
return &FakeJWTService{
VerifyProvider: func(ctx context.Context, token string) (JWTClaims, error) {
return JWTClaims{}, nil
},
}
}