Azure: Use SSO settings in plugin context (#112058)
* Bump grafana-azure-sdk-go * Set override values * Add Azure settings helper covering SSO cases * Ensure Azure settings are correctly created - Add mock for sso settings service - Add tests - Update wire * Minor improvements * Test updates * Move fake implementation * add interface to limit leakage * rename * work sync * Fix wire * Add fake provider * Update tests * Actually fix the workspace * More go dependency fixes * Update tests * Update workspace, again * Add missing tests * Fix dependencies * These dependencies.. * More dependency things * Okay now dependencies really are fixed * Lint * Update pkg/services/pluginsintegration/pluginconfig/request.go Co-authored-by: Misi <mgyongyosi@users.noreply.github.com> --------- Co-authored-by: Will Browne <wbrowne@tcd.ie> Co-authored-by: Misi <mgyongyosi@users.noreply.github.com>
This commit is contained in:
co-authored by
Misi
Will Browne
parent
59459560c2
commit
fa9d6be255
@@ -0,0 +1,41 @@
|
||||
package pluginsso
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/grafana/grafana/pkg/services/ssosettings"
|
||||
)
|
||||
|
||||
// SettingsProvider is used to get the SSO settings for a given provider.
|
||||
type SettingsProvider interface {
|
||||
GetForProvider(ctx context.Context, provider string) (*Settings, error)
|
||||
}
|
||||
|
||||
type Settings struct {
|
||||
Values map[string]any
|
||||
}
|
||||
|
||||
// DefaultSettingsProvider is the default implementation of the SettingsProvider interface.
|
||||
// It uses the SSO settings service to get the settings for a given provider.
|
||||
type DefaultSettingsProvider struct {
|
||||
ssoSettings ssosettings.Service
|
||||
}
|
||||
|
||||
func ProvideDefaultSettingsProvider(ssoSettings ssosettings.Service) *DefaultSettingsProvider {
|
||||
return &DefaultSettingsProvider{
|
||||
ssoSettings: ssoSettings,
|
||||
}
|
||||
}
|
||||
|
||||
// GetForProvider returns the SSO settings for a given provider.
|
||||
// The settings are fetched from the cache if available, otherwise they are fetched from the database.
|
||||
func (p *DefaultSettingsProvider) GetForProvider(ctx context.Context, provider string) (*Settings, error) {
|
||||
settings, err := p.ssoSettings.GetForProviderFromCache(ctx, provider)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &Settings{
|
||||
Values: settings.Settings,
|
||||
}, nil
|
||||
}
|
||||
Reference in New Issue
Block a user