mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Plugins: Automatic service account (and token) setup (#76473)
* Update cue to have an AuthProvider entry * Cable the new auth provider * Add feature flag check to the accesscontrol service * Fix test * Change the structure of externalServiceRegistration (#76673)
This commit is contained in:
@@ -38,23 +38,26 @@ func (s *Service) RegisterExternalService(ctx context.Context, svcName string, s
|
||||
}
|
||||
|
||||
self := extsvcauth.SelfCfg{}
|
||||
if svc.Self != nil {
|
||||
self.Permissions = toAccessControlPermissions(svc.Self.Permissions)
|
||||
if svc.Self.Enabled != nil {
|
||||
self.Enabled = *svc.Self.Enabled
|
||||
} else {
|
||||
self.Enabled = true
|
||||
}
|
||||
if len(svc.Permissions) > 0 {
|
||||
self.Permissions = toAccessControlPermissions(svc.Permissions)
|
||||
self.Enabled = true
|
||||
}
|
||||
|
||||
extSvc, err := s.os.SaveExternalService(ctx, &extsvcauth.ExternalServiceRegistration{
|
||||
Name: svcName,
|
||||
Impersonation: impersonation,
|
||||
Self: self,
|
||||
AuthProvider: extsvcauth.OAuth2Server,
|
||||
OAuthProviderCfg: &extsvcauth.OAuthProviderCfg{Key: &extsvcauth.KeyOption{Generate: true}},
|
||||
})
|
||||
if err != nil {
|
||||
registration := &extsvcauth.ExternalServiceRegistration{
|
||||
Name: svcName,
|
||||
Impersonation: impersonation,
|
||||
Self: self,
|
||||
}
|
||||
|
||||
// Default authProvider now is ServiceAccounts
|
||||
registration.AuthProvider = extsvcauth.ServiceAccounts
|
||||
if svc.Impersonation != nil {
|
||||
registration.AuthProvider = extsvcauth.OAuth2Server
|
||||
registration.OAuthProviderCfg = &extsvcauth.OAuthProviderCfg{Key: &extsvcauth.KeyOption{Generate: true}}
|
||||
}
|
||||
|
||||
extSvc, err := s.os.SaveExternalService(ctx, registration)
|
||||
if err != nil || extSvc == nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user