auth_rpc

package
v0.0.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 17, 2024 License: Apache-2.0 Imports: 13 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidToken = errors.New("authenticator: invalid token")
)

Functions

func Module

func Module(scope string, uri string, opts ...Option) fx.Option

Types

type AuthRPC

type AuthRPC struct {
	// contains filtered or unexported fields
}

type AuthenticateResponse

type AuthenticateResponse struct {
	Success bool                   `json:"success"`
	Message bool                   `json:"message,omitempty"`
	Data    map[string]interface{} `json:"data,omitempty"`
}

type AuthenticationInfo

type AuthenticationInfo struct {
	Data map[string]interface{}
}

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 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
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL