Add session management for user authentication
This commit is contained in:
parent
e235e3d8a8
commit
ab662bd4b8
3 changed files with 45 additions and 4 deletions
19
auth/token.go
Normal file
19
auth/token.go
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
package auth
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"encoding/base64"
|
||||
"time"
|
||||
)
|
||||
|
||||
type token struct {
|
||||
userName string
|
||||
created time.Time
|
||||
lastAccess time.Time
|
||||
}
|
||||
|
||||
func generateKey() string {
|
||||
key := [32]byte{}
|
||||
rand.Read(key[:])
|
||||
return base64.StdEncoding.EncodeToString(key[:])
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue