未验证 提交 b83b3232 编写于 作者: H hongming

remove useless log output

Signed-off-by: Nhongming <talonwan@yunify.com>
上级 8ca0c86b
...@@ -47,7 +47,7 @@ func NewTokenAuthenticator(tokenOperator auth.TokenManagementInterface, userList ...@@ -47,7 +47,7 @@ func NewTokenAuthenticator(tokenOperator auth.TokenManagementInterface, userList
func (t *tokenAuthenticator) AuthenticateToken(ctx context.Context, token string) (*authenticator.Response, bool, error) { func (t *tokenAuthenticator) AuthenticateToken(ctx context.Context, token string) (*authenticator.Response, bool, error) {
providedUser, err := t.tokenOperator.Verify(token) providedUser, err := t.tokenOperator.Verify(token)
if err != nil { if err != nil {
klog.Error(err) klog.Warning(err)
return nil, false, err return nil, false, err
} }
......
...@@ -49,7 +49,7 @@ func (s *jwtTokenIssuer) Verify(tokenString string) (user.Info, TokenType, error ...@@ -49,7 +49,7 @@ func (s *jwtTokenIssuer) Verify(tokenString string) (user.Info, TokenType, error
// verify token signature and expiration time // verify token signature and expiration time
_, err := jwt.ParseWithClaims(tokenString, clm, s.keyFunc) _, err := jwt.ParseWithClaims(tokenString, clm, s.keyFunc)
if err != nil { if err != nil {
klog.Error(err) klog.V(4).Info(err)
return nil, "", err return nil, "", err
} }
return &user.DefaultInfo{Name: clm.Username, Groups: clm.Groups, Extra: clm.Extra}, clm.TokenType, nil return &user.DefaultInfo{Name: clm.Username, Groups: clm.Groups, Extra: clm.Extra}, clm.TokenType, nil
...@@ -77,9 +77,8 @@ func (s *jwtTokenIssuer) IssueTo(user user.Info, tokenType TokenType, expiresIn ...@@ -77,9 +77,8 @@ func (s *jwtTokenIssuer) IssueTo(user user.Info, tokenType TokenType, expiresIn
token := jwt.NewWithClaims(jwt.SigningMethodHS256, clm) token := jwt.NewWithClaims(jwt.SigningMethodHS256, clm)
tokenString, err := token.SignedString(s.secret) tokenString, err := token.SignedString(s.secret)
if err != nil { if err != nil {
klog.Error(err) klog.V(4).Info(err)
return "", err return "", err
} }
......
...@@ -137,7 +137,7 @@ func (r *RBACAuthorizer) Authorize(requestAttributes authorizer.Attributes) (aut ...@@ -137,7 +137,7 @@ func (r *RBACAuthorizer) Authorize(requestAttributes authorizer.Attributes) (aut
scope = "global-wide" scope = "global-wide"
} }
klog.Infof("RBAC: no rules authorize user %q with groups %q to %s %s", requestAttributes.GetUser().GetName(), requestAttributes.GetUser().GetGroups(), operation, scope) klog.V(4).Infof("RBAC: no rules authorize user %q with groups %q to %s %s", requestAttributes.GetUser().GetName(), requestAttributes.GetUser().GetGroups(), operation, scope)
} }
reason := "" reason := ""
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
package auth package auth
import ( import (
"errors"
"fmt" "fmt"
"k8s.io/apiserver/pkg/authentication/user" "k8s.io/apiserver/pkg/authentication/user"
"k8s.io/klog" "k8s.io/klog"
...@@ -54,7 +55,6 @@ func NewTokenOperator(cache cache.Interface, options *authoptions.Authentication ...@@ -54,7 +55,6 @@ func NewTokenOperator(cache cache.Interface, options *authoptions.Authentication
func (t tokenOperator) Verify(tokenStr string) (user.Info, error) { func (t tokenOperator) Verify(tokenStr string) (user.Info, error) {
authenticated, tokenType, err := t.issuer.Verify(tokenStr) authenticated, tokenType, err := t.issuer.Verify(tokenStr)
if err != nil { if err != nil {
klog.Error(err)
return nil, err return nil, err
} }
if t.options.OAuthOptions.AccessTokenMaxAge == 0 || if t.options.OAuthOptions.AccessTokenMaxAge == 0 ||
...@@ -62,7 +62,6 @@ func (t tokenOperator) Verify(tokenStr string) (user.Info, error) { ...@@ -62,7 +62,6 @@ func (t tokenOperator) Verify(tokenStr string) (user.Info, error) {
return authenticated, nil return authenticated, nil
} }
if err := t.tokenCacheValidate(authenticated.GetName(), tokenStr); err != nil { if err := t.tokenCacheValidate(authenticated.GetName(), tokenStr); err != nil {
klog.Error(err)
return nil, err return nil, err
} }
return authenticated, nil return authenticated, nil
...@@ -131,7 +130,9 @@ func (t tokenOperator) tokenCacheValidate(username, token string) error { ...@@ -131,7 +130,9 @@ func (t tokenOperator) tokenCacheValidate(username, token string) error {
if exist, err := t.cache.Exists(key); err != nil { if exist, err := t.cache.Exists(key); err != nil {
return err return err
} else if !exist { } else if !exist {
return fmt.Errorf("token not found in cache") err = errors.New("token not found in cache")
klog.V(4).Info(fmt.Errorf("%s: %s", err, token))
return err
} }
return nil return nil
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册