forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 1
/
interfaces.go
42 lines (31 loc) · 1.11 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 authenticator
import (
"k8s.io/apiserver/pkg/authentication/user"
"github.com/openshift/origin/pkg/auth/api"
"github.com/openshift/origin/pkg/oauth/apis/oauth"
userapi "github.com/openshift/origin/pkg/user/apis/user"
)
type Assertion interface {
AuthenticateAssertion(assertionType, data string) (user.Info, bool, error)
}
type Client interface {
AuthenticateClient(client api.Client) (user.Info, bool, error)
}
type OAuthTokenValidator interface {
Validate(token *oauth.OAuthAccessToken, user *userapi.User) error
}
var _ OAuthTokenValidator = OAuthTokenValidatorFunc(nil)
type OAuthTokenValidatorFunc func(token *oauth.OAuthAccessToken, user *userapi.User) error
func (f OAuthTokenValidatorFunc) Validate(token *oauth.OAuthAccessToken, user *userapi.User) error {
return f(token, user)
}
var _ OAuthTokenValidator = OAuthTokenValidators(nil)
type OAuthTokenValidators []OAuthTokenValidator
func (v OAuthTokenValidators) Validate(token *oauth.OAuthAccessToken, user *userapi.User) error {
for _, validator := range v {
if err := validator.Validate(token, user); err != nil {
return err
}
}
return nil
}