29 lines
469 B
Go
29 lines
469 B
Go
package handler
|
|
|
|
import (
|
|
"github.com/google/uuid"
|
|
"github.com/gorilla/securecookie"
|
|
)
|
|
|
|
const (
|
|
AuthorizeCookie = "authorize"
|
|
ContextUser ctxKey = "context_user"
|
|
)
|
|
|
|
var secureCookie *securecookie.SecureCookie
|
|
|
|
type ctxKey string
|
|
|
|
type Authorize struct {
|
|
ID string `json:"id"`
|
|
Name string `json:"name"`
|
|
}
|
|
|
|
func genId() string {
|
|
return uuid.Must(uuid.NewRandom()).String()
|
|
}
|
|
|
|
func SetSecureCookie(sc *securecookie.SecureCookie) {
|
|
secureCookie = sc
|
|
}
|