/
types.go
40 lines (31 loc) · 958 Bytes
/
types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package session
import (
"net/http"
"k8s.io/apiserver/pkg/authentication/authenticator"
"k8s.io/apiserver/pkg/authentication/user"
"github.com/openshift/origin/pkg/oauthserver/oauth/handlers"
)
// Store abstracts HTTP session storage of Values
type Store interface {
// Get and decode the Values associated with the given request
Get(r *http.Request) Values
// Put encodes and writes the given Values to the response
Put(w http.ResponseWriter, v Values) error
}
type Values map[interface{}]interface{}
func (v Values) GetString(key string) (string, bool) {
str, _ := v[key].(string)
return str, len(str) != 0
}
func (v Values) GetInt64(key string) (int64, bool) {
i, _ := v[key].(int64)
return i, i != 0
}
type SessionInvalidator interface {
InvalidateAuthentication(w http.ResponseWriter, user user.Info) error
}
type SessionAuthenticator interface {
authenticator.Request
handlers.AuthenticationSuccessHandler
SessionInvalidator
}