Mercurial > gemma
comparison auth/session.go @ 326:a7b2db8b3d18
Added type for roles.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Thu, 02 Aug 2018 18:39:01 +0200 |
parents | f345edb409b2 |
children | e48da6f427c8 |
comparison
equal
deleted
inserted
replaced
325:c23eb0f34e39 | 326:a7b2db8b3d18 |
---|---|
5 "encoding/base64" | 5 "encoding/base64" |
6 "io" | 6 "io" |
7 "time" | 7 "time" |
8 ) | 8 ) |
9 | 9 |
10 type Roles []string | |
11 | |
10 type Session struct { | 12 type Session struct { |
11 ExpiresAt int64 `json:"expires"` | 13 ExpiresAt int64 `json:"expires"` |
12 User string `json:"user"` | 14 User string `json:"user"` |
13 Password string `json:"password"` | 15 Password string `json:"password"` |
14 Roles []string `json:"roles"` | 16 Roles Roles `json:"roles"` |
17 } | |
18 | |
19 func (r Roles) Has(role string) bool { | |
20 for _, x := range r { | |
21 if x == role { | |
22 return true | |
23 } | |
24 } | |
25 return false | |
15 } | 26 } |
16 | 27 |
17 const ( | 28 const ( |
18 sessionKeyLength = 20 | 29 sessionKeyLength = 20 |
19 maxTokenValid = time.Hour * 3 | 30 maxTokenValid = time.Hour * 3 |