Browse Source

Authy

hkremer/rebranding
Gregory Rudolph 3 years ago
parent
commit
0a2dc22837
Signed by: rudi
GPG Key ID: EF64F3CBD1A1EBDD
  1. 20
      auth.go
  2. 2
      site-api.go
  3. 11
      types.go

20
auth.go

@ -77,16 +77,16 @@ func usePassword(user string, pass string, ip string) bool { @@ -77,16 +77,16 @@ func usePassword(user string, pass string, ip string) bool {
log.LogInfo("%+v", toks)
tok := toks[user]
delete(toks, user)
if time.Since(tok.timestamp) > (time.Minute * 5) {
log.LogWarn(fmt.Sprintf("%s attempted to use expired token. %+v", user, time.Since(tok.timestamp)))
if time.Since(tok.Timestamp) > (time.Minute * 5) {
log.LogWarn(fmt.Sprintf("%s attempted to use expired token. %+v", user, time.Since(tok.Timestamp)))
return false
}
if tok.ip != ip {
if tok.IP != ip {
log.LogWarn(fmt.Sprintf("%s attempted to use an improper IP.", user))
return false
}
if tok.password != pass {
log.LogWarn(fmt.Sprintf("%s attempted to use an improper password. %s vs %s", user, tok.password, pass))
if tok.Password != pass {
log.LogWarn(fmt.Sprintf("%s attempted to use an improper password. %s vs %s", user, tok.Password, pass))
return false
}
@ -113,11 +113,11 @@ func sendPassword(user string, ipaddr string) { @@ -113,11 +113,11 @@ func sendPassword(user string, ipaddr string) {
if err != nil {
log.LogErrorType(err)
}
toks[m.User.Username] = tokens{
username: user,
ip: ipaddr,
password: str,
timestamp: time.Now(),
toks[m.Nick] = Tokens{
Username: user,
IP: ipaddr,
Password: str,
Timestamp: time.Now(),
}
pmChann, err := dg.UserChannelCreate(user)
if err != nil {

2
site-api.go

@ -14,7 +14,7 @@ import ( @@ -14,7 +14,7 @@ import (
var (
store = sessions.NewCookieStore([]byte(os.Getenv("SESSION_KEY")))
toks = make(map[string]tokens)
toks = make(map[string]Tokens)
acctLinks = make(map[string]linkedAccount)
)

11
types.go

@ -41,9 +41,10 @@ type linkedAccount struct { @@ -41,9 +41,10 @@ type linkedAccount struct {
sigHash string
}
type tokens struct {
username string
ip string
password string
timestamp time.Time
// Tokens are the Login Token struct
type Tokens struct {
Username string
IP string
Password string
Timestamp time.Time
}

Loading…
Cancel
Save