3
0
corteza/pkg/auth/interfaces.go
Vivek Patel 54cbfe20d8 Adds JWT token generation methods
- Generates token encoded with user and save it to store
- Updated token generation method usage in Corredor and Impersonalization
2021-09-22 21:09:55 +02:00

38 lines
734 B
Go

package auth
import (
"context"
"github.com/dgrijalva/jwt-go"
"net/http"
)
type (
Identifiable interface {
Identity() uint64
Roles() []uint64
Valid() bool
String() string
}
TokenEncoder interface {
Encode(identity Identifiable, scope ...string) string
}
TokenGenerator interface {
Generate(ctx context.Context, identity Identifiable) (string, error)
}
TokenHandler interface {
TokenEncoder
TokenGenerator
Authenticate(token string) (jwt.MapClaims, error)
HttpVerifier() func(http.Handler) http.Handler
HttpAuthenticator() func(http.Handler) http.Handler
}
Signer interface {
Sign(userID uint64, pp ...interface{}) string
Verify(signature string, userID uint64, pp ...interface{}) bool
}
)