Skip to content

Commit

Permalink
make goimports and add annotations
Browse files Browse the repository at this point in the history
Signed-off-by: wenhaozhou <wenhaozhou@yunify.com>
  • Loading branch information
zhou1203 committed Feb 24, 2023
1 parent 3e198ae commit d026477
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pkg/apiserver/authentication/authenticators/basic/basic.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func NewBasicAuthenticator(authenticator auth.PasswordAuthenticator, loginRecord
}

func (t *basicAuthenticator) AuthenticatePassword(ctx context.Context, username, password string) (*authenticator.Response, bool, error) {
authenticated, provider, err := t.authenticator.Authenticate(ctx, username, password)
authenticated, provider, err := t.authenticator.Authenticate(ctx, "", username, password)
if err != nil {
if t.loginRecorder != nil && err == auth.IncorrectPasswordError {
var sourceIP, userAgent string
Expand Down
1 change: 0 additions & 1 deletion pkg/kapis/oauth/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ import (
)

const (
ldapProvider = "LDAPIdentityProvider"
KindTokenReview = "TokenReview"
grantTypePassword = "password"
grantTypeRefreshToken = "refresh_token"
Expand Down
3 changes: 2 additions & 1 deletion pkg/models/auth/authenticator.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ var (
)

// PasswordAuthenticator is an interface implemented by authenticator which take a
// username and password.
// username and password. provider refers to the identity provider`s name,
// if the provider is empty, authenticate from kubesphere account
type PasswordAuthenticator interface {
Authenticate(ctx context.Context, provider, username, password string) (authuser.Info, string, error)
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/models/auth/password.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"k8s.io/klog/v2"

iamv1alpha2 "kubesphere.io/api/iam/v1alpha2"

"kubesphere.io/kubesphere/pkg/apiserver/authentication"
"kubesphere.io/kubesphere/pkg/apiserver/authentication/identityprovider"
"kubesphere.io/kubesphere/pkg/apiserver/authentication/oauth"
Expand Down Expand Up @@ -63,6 +64,7 @@ func (p *passwordAuthenticator) Authenticate(_ context.Context, provider, userna
return p.accountAuthenticate(username, password)
}

// accountAuthenticate authenticate the kubesphere account
func (p *passwordAuthenticator) accountAuthenticate(username, password string) (authuser.Info, string, error) {
user, err := p.userGetter.findUser(username)
if err != nil {
Expand Down

0 comments on commit d026477

Please sign in to comment.