mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Authn: external identity sync (#73461)
* Authn: Add interface for external identity sync This interface is implemented by authnimpl.Service and just triggers PostAuthHooks and skipping last seen update by default * Authn: Add SyncIdentity to fake and add a new mock
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
)
|
||||
|
||||
var _ authn.Service = new(FakeService)
|
||||
var _ authn.IdentitySynchronizer = new(FakeService)
|
||||
|
||||
type FakeService struct {
|
||||
ExpectedErr error
|
||||
@@ -67,6 +68,10 @@ func (f *FakeService) RedirectURL(ctx context.Context, client string, r *authn.R
|
||||
|
||||
func (f *FakeService) RegisterClient(c authn.Client) {}
|
||||
|
||||
func (f *FakeService) SyncIdentity(ctx context.Context, identity *authn.Identity) error {
|
||||
return f.ExpectedErr
|
||||
}
|
||||
|
||||
var _ authn.ContextAwareClient = new(FakeClient)
|
||||
|
||||
type FakeClient struct {
|
||||
|
||||
@@ -6,6 +6,44 @@ import (
|
||||
"github.com/grafana/grafana/pkg/services/authn"
|
||||
)
|
||||
|
||||
var _ authn.Service = new(MockService)
|
||||
var _ authn.IdentitySynchronizer = new(MockService)
|
||||
|
||||
type MockService struct {
|
||||
SyncIdentityFunc func(ctx context.Context, identity *authn.Identity) error
|
||||
}
|
||||
|
||||
func (m *MockService) Authenticate(ctx context.Context, r *authn.Request) (*authn.Identity, error) {
|
||||
panic("unimplemented")
|
||||
}
|
||||
|
||||
func (m *MockService) Login(ctx context.Context, client string, r *authn.Request) (*authn.Identity, error) {
|
||||
panic("unimplemented")
|
||||
}
|
||||
|
||||
func (m *MockService) RedirectURL(ctx context.Context, client string, r *authn.Request) (*authn.Redirect, error) {
|
||||
panic("unimplemented")
|
||||
}
|
||||
|
||||
func (m *MockService) RegisterClient(c authn.Client) {
|
||||
panic("unimplemented")
|
||||
}
|
||||
|
||||
func (m *MockService) RegisterPostAuthHook(hook authn.PostAuthHookFn, priority uint) {
|
||||
panic("unimplemented")
|
||||
}
|
||||
|
||||
func (m *MockService) RegisterPostLoginHook(hook authn.PostLoginHookFn, priority uint) {
|
||||
panic("unimplemented")
|
||||
}
|
||||
|
||||
func (m *MockService) SyncIdentity(ctx context.Context, identity *authn.Identity) error {
|
||||
if m.SyncIdentityFunc != nil {
|
||||
return m.SyncIdentityFunc(ctx, identity)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
var _ authn.HookClient = new(MockClient)
|
||||
var _ authn.ContextAwareClient = new(MockClient)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user