-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Expand file tree
/
Copy pathidentitymapper.go
More file actions
30 lines (23 loc) · 844 Bytes
/
identitymapper.go
File metadata and controls
30 lines (23 loc) · 844 Bytes
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
package identitymapper
import (
"fmt"
"k8s.io/apiserver/pkg/authentication/user"
"github.com/golang/glog"
"github.com/openshift/origin/pkg/oauthserver/api"
)
// UserFor bridges the UserIdentityMapper interface with the authenticator.{Password|Request} interfaces
func UserFor(mapper api.UserIdentityMapper, identity api.UserIdentityInfo) (user.Info, bool, error) {
user, err := mapper.UserFor(identity)
if err != nil {
logf("error creating or updating mapping for: %#v due to %v", identity, err)
return nil, false, err
}
logf("got userIdentityMapping: %#v", user)
return user, true, nil
}
// logf(...) is the same as glog.V(4).Infof(...) except it reports the caller as the line number
func logf(format string, args ...interface{}) {
if glog.V(4) {
glog.InfoDepth(2, fmt.Sprintf("identitymapper: "+format, args...))
}
}