Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrInvalidToken = errors.New("authenticator: invalid token")
)
Functions ¶
Types ¶
type AuthenticateResponse ¶
type AuthenticationInfo ¶
type AuthenticationInfo struct {
UserID string
}
type Authenticator ¶
type Authenticator interface {
Authenticate(token string) (*AuthenticationInfo, error)
GenerateToken(info *AuthenticationInfo) (string, error)
}
type HTTPAuthenticator ¶
type HTTPAuthenticator struct {
Url string
}
func NewHTTPAuthenticator ¶
func NewHTTPAuthenticator(url string) *HTTPAuthenticator
func (*HTTPAuthenticator) Authenticate ¶
func (ha *HTTPAuthenticator) Authenticate(token string) (*AuthenticationInfo, error)
func (*HTTPAuthenticator) GenerateToken ¶
func (ha *HTTPAuthenticator) GenerateToken(info *AuthenticationInfo) (string, error)
func (*HTTPAuthenticator) UpdateUrl ¶
func (ha *HTTPAuthenticator) UpdateUrl(url string)
type HTTPClaims ¶
type HTTPClaims struct {
jwt.StandardClaims
UserID string `json:"user_id"`
}
type JWTAuthenticator ¶
type JWTAuthenticator struct {
Secret []byte
}
func NewJWTAuthenticator ¶
func NewJWTAuthenticator(secret string) *JWTAuthenticator
func (*JWTAuthenticator) Authenticate ¶
func (ja *JWTAuthenticator) Authenticate(token string) (*AuthenticationInfo, error)
func (*JWTAuthenticator) GenerateToken ¶
func (ja *JWTAuthenticator) GenerateToken(info *AuthenticationInfo) (string, error)
func (*JWTAuthenticator) UpdateSecret ¶
func (ja *JWTAuthenticator) UpdateSecret(secret string)
type JWTClaims ¶
type JWTClaims struct {
jwt.StandardClaims
UserID string `json:"user_id"`
}
type Option ¶
type Option func(*AuthRPC)
func WithAuthenticator ¶
func WithAuthenticator(a Authenticator) Option
func WithHTTPAuthenticator ¶
func WithHTTPAuthenticator() Option
func WithJWTAuthenticator ¶
func WithJWTAuthenticator() Option
type Params ¶
type Params struct {
fx.In
Lifecycle fx.Lifecycle
Logger *zap.Logger
HTTPServer *http_server.HTTPServer
WebSocketServer *websocket_server.WebSocketServer
}
Click to show internal directories.
Click to hide internal directories.