forked from openshift/origin
/
interfaces.go
42 lines (33 loc) · 1.39 KB
/
interfaces.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
41
42
package handlers
import (
"net/http"
"github.com/openshift/origin/pkg/auth/api"
)
type AuthenticationHandler interface {
AuthenticationNeeded(w http.ResponseWriter, req *http.Request)
AuthenticationError(err error, w http.ResponseWriter, req *http.Request)
}
type AuthenticationSuccessHandler interface {
AuthenticationSucceeded(user api.UserInfo, state string, w http.ResponseWriter, req *http.Request) error
}
type AuthenticationErrorHandler interface {
AuthenticationError(err error, w http.ResponseWriter, req *http.Request)
}
type GrantChecker interface {
HasAuthorizedClient(client api.Client, user api.UserInfo, grant *api.Grant) (bool, error)
}
type GrantHandler interface {
GrantNeeded(client api.Client, user api.UserInfo, grant *api.Grant, w http.ResponseWriter, req *http.Request)
GrantError(err error, w http.ResponseWriter, req *http.Request)
}
// AuthenticationSuccessHandlers combines multiple AuthenticationSuccessHandler objects into a chain.
// On success, each handler is called. If any handler returns an error, the chain is aborted.
type AuthenticationSuccessHandlers []AuthenticationSuccessHandler
func (all AuthenticationSuccessHandlers) AuthenticationSucceeded(user api.UserInfo, state string, w http.ResponseWriter, req *http.Request) error {
for _, h := range all {
if err := h.AuthenticationSucceeded(user, state, w, req); err != nil {
return err
}
}
return nil
}