login record CRD (#2565)

* Signed-off-by: hongming <talonwan@yunify.com>

support ldap identity provider

Signed-off-by: hongming <talonwan@yunify.com>

* add login record

Signed-off-by: Jeff <zw0948@gmail.com>

Co-authored-by: hongming <talonwan@yunify.com>
This commit is contained in:
zryfish
2020-07-23 22:10:39 +08:00
committed by GitHub
parent 50a6c7b2b5
commit 3d74bb0589
51 changed files with 2163 additions and 548 deletions

View File

@@ -29,18 +29,18 @@ import (
// and group from user.AllUnauthenticated. This helps requests be passed along the handler chain,
// because some resources are public accessible.
type basicAuthenticator struct {
im im.IdentityManagementInterface
authenticator im.PasswordAuthenticator
}
func NewBasicAuthenticator(im im.IdentityManagementInterface) authenticator.Password {
func NewBasicAuthenticator(authenticator im.PasswordAuthenticator) authenticator.Password {
return &basicAuthenticator{
im: im,
authenticator: authenticator,
}
}
func (t *basicAuthenticator) AuthenticatePassword(ctx context.Context, username, password string) (*authenticator.Response, bool, error) {
providedUser, err := t.im.Authenticate(username, password)
providedUser, err := t.authenticator.Authenticate(username, password)
if err != nil {
return nil, false, err
@@ -49,7 +49,7 @@ func (t *basicAuthenticator) AuthenticatePassword(ctx context.Context, username,
return &authenticator.Response{
User: &user.DefaultInfo{
Name: providedUser.GetName(),
UID: string(providedUser.GetUID()),
UID: providedUser.GetUID(),
Groups: []string{user.AllAuthenticated},
},
}, true, nil