mirror of
https://github.com/boringproxy/boringproxy.git
synced 2025-02-25 18:55:29 -06:00
Also changed order that extractToken looks for tokens. Used to be cookies then headers then query. Now in reverse, to make it easier to override, ie for replacing cookies during login.
34 lines
489 B
Go
34 lines
489 B
Go
package main
|
|
|
|
import (
|
|
"sync"
|
|
)
|
|
|
|
type Auth struct {
|
|
db *Database
|
|
pendingRequests map[string]*LoginRequest
|
|
mutex *sync.Mutex
|
|
}
|
|
|
|
type LoginRequest struct {
|
|
Email string
|
|
}
|
|
|
|
func NewAuth(db *Database) *Auth {
|
|
|
|
pendingRequests := make(map[string]*LoginRequest)
|
|
mutex := &sync.Mutex{}
|
|
|
|
return &Auth{db, pendingRequests, mutex}
|
|
}
|
|
|
|
func (a *Auth) Authorized(token string) bool {
|
|
_, exists := a.db.GetTokenData(token)
|
|
|
|
if exists {
|
|
return true
|
|
}
|
|
|
|
return false
|
|
}
|