Documentation ¶
Index ¶
- Constants
- type AppContext
- type AuthHandler
- type AuthManager
- func (am *AuthManager) CreateNewToken(entityID *models.EntityID, deviceID string, ...) (*JWTCustomClaims, string, error)
- func (am *AuthManager) HandleSimpleAuth(username string, pass string) (string, *JWTCustomClaims, error)
- func (am *AuthManager) ValidateToken(tokenString string) (*JWTCustomClaims, error)
- type C2SMessageHandler
- type Config
- type JWTCustomClaims
- type Router
- type Session
- type SessionManager
- type UserManager
- type WebsocketServer
Constants ¶
View Source
const ( SigningKeyBytesAmount = 4096 TokenExpireTimeDuration = 24 * time.Hour )
View Source
const (
UsersCollectionName = "users"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AppContext ¶
type AppContext struct {
// contains filtered or unexported fields
}
func NewAppContext ¶
func NewAppContext(cfg *Config) *AppContext
func (*AppContext) Run ¶
func (ac *AppContext) Run() error
type AuthHandler ¶
type AuthHandler struct {
// contains filtered or unexported fields
}
func NewAuthHandler ¶
func NewAuthHandler(am *AuthManager, serverID string) *AuthHandler
func (*AuthHandler) HandleMessage ¶
func (ah *AuthHandler) HandleMessage(s *Session, message models.BaseMessage)
func (*AuthHandler) HandlingType ¶
func (ah *AuthHandler) HandlingType() string
func (*AuthHandler) IsAuthorizationRequired ¶
func (ah *AuthHandler) IsAuthorizationRequired() bool
type AuthManager ¶
type AuthManager struct {
// contains filtered or unexported fields
}
func NewAuthManager ¶
func NewAuthManager(um *UserManager, serverID string, r *Router) (*AuthManager, error)
func (*AuthManager) CreateNewToken ¶
func (am *AuthManager) CreateNewToken(entityID *models.EntityID, deviceID string, tokenExpireTimeDuration time.Duration) (*JWTCustomClaims, string, error)
func (*AuthManager) HandleSimpleAuth ¶
func (am *AuthManager) HandleSimpleAuth(username string, pass string) (string, *JWTCustomClaims, error)
func (*AuthManager) ValidateToken ¶
func (am *AuthManager) ValidateToken(tokenString string) (*JWTCustomClaims, error)
type C2SMessageHandler ¶
type C2SMessageHandler interface { HandleMessage(s *Session, message models.BaseMessage) IsAuthorizationRequired() bool HandlingType() string }
type JWTCustomClaims ¶
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
func NewRouter ¶
func NewRouter(ctx *AppContext) (*Router, error)
func (*Router) RegisterC2SHandler ¶
func (r *Router) RegisterC2SHandler(c C2SMessageHandler)
func (*Router) RouteMessage ¶
func (r *Router) RouteMessage(origin *Session, message models.BaseMessage)
type Session ¶
type Session struct { Claims *JWTCustomClaims // contains filtered or unexported fields }
type SessionManager ¶
type SessionManager struct {
// contains filtered or unexported fields
}
func NewSessionManager ¶
func NewSessionManager(r *Router, domains []string) *SessionManager
func (*SessionManager) HandleNewConnection ¶
func (sm *SessionManager) HandleNewConnection(wsocket *websocket.Conn)
type UserManager ¶
type UserManager struct {
// contains filtered or unexported fields
}
func NewUserManager ¶
func NewUserManager(db *mongo.Database) (*UserManager, error)
func (*UserManager) GetByUsername ¶
func (um *UserManager) GetByUsername(username string) (*models.User, error)
type WebsocketServer ¶
type WebsocketServer struct {
// contains filtered or unexported fields
}
func NewWebsocketServer ¶
func NewWebsocketServer(cfg *Config, sessionManager *SessionManager) *WebsocketServer
func (*WebsocketServer) Run ¶
func (wss *WebsocketServer) Run() error
Source Files ¶
Click to show internal directories.
Click to hide internal directories.