Documentation
¶
Index ¶
- type LoginRequest
- type LoginResponse
- type LogoutRequest
- type MegaportAuthResponse
- type Server
- type Session
- type SessionManager
- func (sm *SessionManager) CreateSession(accessKey, secretKey string) (*Session, error)
- func (sm *SessionManager) DeleteSession(sessionID string)
- func (sm *SessionManager) GetSession(sessionID string) *Session
- func (sm *SessionManager) GetSessionCount() int
- func (sm *SessionManager) UpdateActivity(sessionID string)
- func (sm *SessionManager) UpdateMegaportToken(sessionID, token string, expiry time.Time)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LoginRequest ¶
type LoginRequest struct {
AccessKey string `json:"accessKey"`
SecretKey string `json:"secretKey"`
Environment string `json:"environment"` // staging, production, dev
}
LoginRequest represents the login credentials
type LoginResponse ¶
type LoginResponse struct {
SessionToken string `json:"sessionToken"`
ExpiresIn int64 `json:"expiresIn"` // seconds
Environment string `json:"environment"`
}
LoginResponse represents the login response
type LogoutRequest ¶
type LogoutRequest struct {
SessionToken string `json:"sessionToken"`
}
LogoutRequest represents the logout request
type MegaportAuthResponse ¶
type MegaportAuthResponse struct {
AccessToken string `json:"access_token"`
ExpiresIn int `json:"expires_in"`
TokenType string `json:"token_type"`
}
MegaportAuthResponse represents Megaport API token response
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server represents the WASM HTTP server with session management
func (*Server) GetSessionManager ¶
func (s *Server) GetSessionManager() *SessionManager
GetSessionManager returns the session manager
func (*Server) HandleLogin ¶
func (s *Server) HandleLogin(w http.ResponseWriter, r *http.Request)
HandleLogin handles customer login requests
func (*Server) HandleLogout ¶
func (s *Server) HandleLogout(w http.ResponseWriter, r *http.Request)
HandleLogout handles customer logout requests
func (*Server) HandleSessionCheck ¶
func (s *Server) HandleSessionCheck(w http.ResponseWriter, r *http.Request)
HandleSessionCheck checks if a session is valid
type Session ¶
type Session struct {
ID string
AccessKey string
SecretKey string
MegaportToken string
TokenExpiry time.Time
CreatedAt time.Time
ExpiresAt time.Time
LastActivity time.Time
}
Session represents a customer's authenticated session
type SessionManager ¶
type SessionManager struct {
// contains filtered or unexported fields
}
SessionManager manages customer sessions
func NewSessionManager ¶
func NewSessionManager(sessionDuration time.Duration) *SessionManager
NewSessionManager creates a new session manager
func (*SessionManager) CreateSession ¶
func (sm *SessionManager) CreateSession(accessKey, secretKey string) (*Session, error)
CreateSession creates a new session for a customer
func (*SessionManager) DeleteSession ¶
func (sm *SessionManager) DeleteSession(sessionID string)
DeleteSession removes a session (logout)
func (*SessionManager) GetSession ¶
func (sm *SessionManager) GetSession(sessionID string) *Session
GetSession retrieves a session by ID
func (*SessionManager) GetSessionCount ¶
func (sm *SessionManager) GetSessionCount() int
GetSessionCount returns the number of active sessions
func (*SessionManager) UpdateActivity ¶
func (sm *SessionManager) UpdateActivity(sessionID string)
UpdateActivity updates the last activity time for a session
func (*SessionManager) UpdateMegaportToken ¶
func (sm *SessionManager) UpdateMegaportToken(sessionID, token string, expiry time.Time)
UpdateMegaportToken updates the Megaport API token for a session