mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
parent
fa2c044522
commit
a929e3f2cf
@ -11,14 +11,12 @@ type AuthInfoService interface {
|
|||||||
LookupAndUpdate(ctx context.Context, query *GetUserByAuthInfoQuery) (*user.User, error)
|
LookupAndUpdate(ctx context.Context, query *GetUserByAuthInfoQuery) (*user.User, error)
|
||||||
GetAuthInfo(ctx context.Context, query *GetAuthInfoQuery) (*UserAuth, error)
|
GetAuthInfo(ctx context.Context, query *GetAuthInfoQuery) (*UserAuth, error)
|
||||||
GetUserLabels(ctx context.Context, query GetUserLabelsQuery) (map[int64]string, error)
|
GetUserLabels(ctx context.Context, query GetUserLabelsQuery) (map[int64]string, error)
|
||||||
GetExternalUserInfoByLogin(ctx context.Context, query *GetExternalUserInfoByLoginQuery) (*ExternalUserInfo, error)
|
|
||||||
SetAuthInfo(ctx context.Context, cmd *SetAuthInfoCommand) error
|
SetAuthInfo(ctx context.Context, cmd *SetAuthInfoCommand) error
|
||||||
UpdateAuthInfo(ctx context.Context, cmd *UpdateAuthInfoCommand) error
|
UpdateAuthInfo(ctx context.Context, cmd *UpdateAuthInfoCommand) error
|
||||||
DeleteUserAuthInfo(ctx context.Context, userID int64) error
|
DeleteUserAuthInfo(ctx context.Context, userID int64) error
|
||||||
}
|
}
|
||||||
|
|
||||||
type Store interface {
|
type Store interface {
|
||||||
GetExternalUserInfoByLogin(ctx context.Context, query *GetExternalUserInfoByLoginQuery) (*ExternalUserInfo, error)
|
|
||||||
GetAuthInfo(ctx context.Context, query *GetAuthInfoQuery) (*UserAuth, error)
|
GetAuthInfo(ctx context.Context, query *GetAuthInfoQuery) (*UserAuth, error)
|
||||||
GetUserLabels(ctx context.Context, query GetUserLabelsQuery) (map[int64]string, error)
|
GetUserLabels(ctx context.Context, query GetUserLabelsQuery) (map[int64]string, error)
|
||||||
SetAuthInfo(ctx context.Context, cmd *SetAuthInfoCommand) error
|
SetAuthInfo(ctx context.Context, cmd *SetAuthInfoCommand) error
|
||||||
|
@ -34,31 +34,6 @@ func ProvideAuthInfoStore(sqlStore db.DB, secretsService secrets.Service, userSe
|
|||||||
return store
|
return store
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *AuthInfoStore) GetExternalUserInfoByLogin(ctx context.Context, query *login.GetExternalUserInfoByLoginQuery) (*login.ExternalUserInfo, error) {
|
|
||||||
userQuery := user.GetUserByLoginQuery{LoginOrEmail: query.LoginOrEmail}
|
|
||||||
usr, err := s.userService.GetByLogin(ctx, &userQuery)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
authInfoQuery := &login.GetAuthInfoQuery{UserId: usr.ID}
|
|
||||||
authInfo, err := s.GetAuthInfo(ctx, authInfoQuery)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
result := &login.ExternalUserInfo{
|
|
||||||
UserId: usr.ID,
|
|
||||||
Login: usr.Login,
|
|
||||||
Email: usr.Email,
|
|
||||||
Name: usr.Name,
|
|
||||||
IsDisabled: usr.IsDisabled,
|
|
||||||
AuthModule: authInfo.AuthModule,
|
|
||||||
AuthId: authInfo.AuthId,
|
|
||||||
}
|
|
||||||
return result, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetAuthInfo returns the auth info for a user
|
// GetAuthInfo returns the auth info for a user
|
||||||
// It will return the latest auth info for a user
|
// It will return the latest auth info for a user
|
||||||
func (s *AuthInfoStore) GetAuthInfo(ctx context.Context, query *login.GetAuthInfoQuery) (*login.UserAuth, error) {
|
func (s *AuthInfoStore) GetAuthInfo(ctx context.Context, query *login.GetAuthInfoQuery) (*login.UserAuth, error) {
|
||||||
|
@ -201,10 +201,6 @@ func (s *Implementation) SetAuthInfo(ctx context.Context, cmd *login.SetAuthInfo
|
|||||||
return s.authInfoStore.SetAuthInfo(ctx, cmd)
|
return s.authInfoStore.SetAuthInfo(ctx, cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Implementation) GetExternalUserInfoByLogin(ctx context.Context, query *login.GetExternalUserInfoByLoginQuery) (*login.ExternalUserInfo, error) {
|
|
||||||
return s.authInfoStore.GetExternalUserInfoByLogin(ctx, query)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *Implementation) DeleteUserAuthInfo(ctx context.Context, userID int64) error {
|
func (s *Implementation) DeleteUserAuthInfo(ctx context.Context, userID int64) error {
|
||||||
return s.authInfoStore.DeleteUserAuthInfo(ctx, userID)
|
return s.authInfoStore.DeleteUserAuthInfo(ctx, userID)
|
||||||
}
|
}
|
||||||
|
@ -520,9 +520,6 @@ func newFakeAuthInfoStore() *FakeAuthInfoStore {
|
|||||||
return &FakeAuthInfoStore{}
|
return &FakeAuthInfoStore{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FakeAuthInfoStore) GetExternalUserInfoByLogin(ctx context.Context, query *login.GetExternalUserInfoByLoginQuery) (*login.ExternalUserInfo, error) {
|
|
||||||
return nil, f.ExpectedError
|
|
||||||
}
|
|
||||||
func (f *FakeAuthInfoStore) GetAuthInfo(ctx context.Context, query *login.GetAuthInfoQuery) (*login.UserAuth, error) {
|
func (f *FakeAuthInfoStore) GetAuthInfo(ctx context.Context, query *login.GetAuthInfoQuery) (*login.UserAuth, error) {
|
||||||
return f.ExpectedOAuth, f.ExpectedError
|
return f.ExpectedOAuth, f.ExpectedError
|
||||||
}
|
}
|
||||||
|
@ -54,10 +54,6 @@ func (a *AuthInfoServiceFake) UpdateAuthInfo(ctx context.Context, cmd *login.Upd
|
|||||||
return a.ExpectedError
|
return a.ExpectedError
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *AuthInfoServiceFake) GetExternalUserInfoByLogin(ctx context.Context, query *login.GetExternalUserInfoByLoginQuery) (*login.ExternalUserInfo, error) {
|
|
||||||
return a.ExpectedExternalUser, a.ExpectedError
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a *AuthInfoServiceFake) DeleteUserAuthInfo(ctx context.Context, userID int64) error {
|
func (a *AuthInfoServiceFake) DeleteUserAuthInfo(ctx context.Context, userID int64) error {
|
||||||
return a.ExpectedError
|
return a.ExpectedError
|
||||||
}
|
}
|
||||||
|
@ -135,10 +135,6 @@ type UserLookupParams struct {
|
|||||||
Login *string // if set, will try to find the user by login
|
Login *string // if set, will try to find the user by login
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetExternalUserInfoByLoginQuery struct {
|
|
||||||
LoginOrEmail string
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetAuthInfoQuery struct {
|
type GetAuthInfoQuery struct {
|
||||||
UserId int64
|
UserId int64
|
||||||
AuthModule string
|
AuthModule string
|
||||||
|
@ -250,10 +250,6 @@ type FakeAuthInfoStore struct {
|
|||||||
ExpectedLoginStats login.LoginStats
|
ExpectedLoginStats login.LoginStats
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FakeAuthInfoStore) GetExternalUserInfoByLogin(ctx context.Context, query *login.GetExternalUserInfoByLoginQuery) (*login.ExternalUserInfo, error) {
|
|
||||||
return nil, f.ExpectedError
|
|
||||||
}
|
|
||||||
|
|
||||||
func (f *FakeAuthInfoStore) GetAuthInfo(ctx context.Context, query *login.GetAuthInfoQuery) (*login.UserAuth, error) {
|
func (f *FakeAuthInfoStore) GetAuthInfo(ctx context.Context, query *login.GetAuthInfoQuery) (*login.UserAuth, error) {
|
||||||
return f.ExpectedOAuth, f.ExpectedError
|
return f.ExpectedOAuth, f.ExpectedError
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user