feat: auth handlers and session management
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"encoding/hex"
|
||||
"sync"
|
||||
"time"
|
||||
"yoresee_dropbox/internal/store"
|
||||
)
|
||||
|
||||
type Server struct {
|
||||
store *store.Store
|
||||
accessToken string
|
||||
sessions map[string]int64
|
||||
shareSessions map[string]string
|
||||
loginAttempts map[string]int
|
||||
loginLockout map[string]time.Time
|
||||
mu sync.Mutex
|
||||
workspace string
|
||||
}
|
||||
|
||||
func New(store *store.Store, accessToken string, workspace string) *Server {
|
||||
return &Server{
|
||||
store: store,
|
||||
accessToken: accessToken,
|
||||
sessions: make(map[string]int64),
|
||||
shareSessions: make(map[string]string),
|
||||
loginAttempts: make(map[string]int),
|
||||
loginLockout: make(map[string]time.Time),
|
||||
workspace: workspace,
|
||||
}
|
||||
}
|
||||
|
||||
func generateUUID() string {
|
||||
b := make([]byte, 16)
|
||||
rand.Read(b)
|
||||
return hex.EncodeToString(b)
|
||||
}
|
||||
Reference in New Issue
Block a user