Plugins: Rename externalServiceAuthentication to iam (#78686)

Plugins: Rename externalServiceAuthentication to iam
This commit is contained in:
Gabriel MABILLE
2023-12-04 13:14:21 +01:00
committed by GitHub
parent 0825b63b79
commit 5b70130e6c
14 changed files with 53 additions and 66 deletions
+1 -1
View File
@@ -14,6 +14,6 @@ type ExternalService struct {
type ExternalServiceRegistry interface {
HasExternalService(ctx context.Context, pluginID string) (bool, error)
RegisterExternalService(ctx context.Context, pluginID string, pType plugindef.Type, svc *plugindef.ExternalServiceRegistration) (*ExternalService, error)
RegisterExternalService(ctx context.Context, pluginID string, pType plugindef.Type, svc *plugindef.IAM) (*ExternalService, error)
RemoveExternalService(ctx context.Context, pluginID string) error
}
+2 -2
View File
@@ -529,8 +529,8 @@ func TestInitializer_authEnvVars(t *testing.T) {
t.Run("backend datasource with auth registration", func(t *testing.T) {
p := &plugins.Plugin{
JSONData: plugins.JSONData{
ID: "test",
ExternalServiceRegistration: &plugindef.ExternalServiceRegistration{},
ID: "test",
IAM: &plugindef.IAM{},
},
ExternalService: &auth.ExternalService{
ClientID: "clientID",
+1 -1
View File
@@ -441,7 +441,7 @@ func (f *FakeAuthService) HasExternalService(ctx context.Context, pluginID strin
return f.Result != nil, nil
}
func (f *FakeAuthService) RegisterExternalService(ctx context.Context, pluginID string, pType plugindef.Type, svc *plugindef.ExternalServiceRegistration) (*auth.ExternalService, error) {
func (f *FakeAuthService) RegisterExternalService(ctx context.Context, pluginID string, pType plugindef.Type, svc *plugindef.IAM) (*auth.ExternalService, error) {
return f.Result, nil
}
@@ -17,7 +17,7 @@
"updated": "2023-08-03",
"version": "1.0.0"
},
"externalServiceRegistration": {
"iam": {
"permissions" : [
{
"action": "read",
@@ -17,7 +17,7 @@
"updated": "2023-08-03",
"version": "1.0.0"
},
"externalServiceRegistration": {
"iam": {
"impersonation": {
"groups" : true,
"permissions" : [
+5 -4
View File
@@ -410,12 +410,13 @@ schemas: [{
params: [string]: string
}
// External service registration information
externalServiceRegistration: #ExternalServiceRegistration
// Identity and Access Management information.
// Allows the plugin to define the permissions it requires to have on Grafana.
iam: #IAM
// ExternalServiceRegistration allows the service to get a service account token
// IAM allows the plugin to get a service account with tailored permissions and a token
// (or to use the client_credentials grant if the token provider is the OAuth2 Server)
#ExternalServiceRegistration: {
#IAM: {
// Permissions are the permissions that the external service needs its associated service account to have.
permissions?: [...#Permission]
+13 -13
View File
@@ -122,15 +122,6 @@ type Dependency struct {
// DependencyType defines model for Dependency.Type.
type DependencyType string
// ExternalServiceRegistration allows the service to get a service account token
// (or to use the client_credentials grant if the token provider is the OAuth2 Server)
type ExternalServiceRegistration struct {
Impersonation *Impersonation `json:"impersonation,omitempty"`
// Permissions are the permissions that the external service needs its associated service account to have.
Permissions []Permission `json:"permissions,omitempty"`
}
// Header describes an HTTP header that is forwarded with a proxied request for
// a plugin route.
type Header struct {
@@ -138,6 +129,15 @@ type Header struct {
Name string `json:"name"`
}
// IAM allows the plugin to get a service account with tailored permissions and a token
// (or to use the client_credentials grant if the token provider is the OAuth2 Server)
type IAM struct {
Impersonation *Impersonation `json:"impersonation,omitempty"`
// Permissions are the permissions that the external service needs its associated service account to have.
Permissions []Permission `json:"permissions,omitempty"`
}
// Impersonation defines model for Impersonation.
type Impersonation struct {
// Groups allows the service to list the impersonated user's teams.
@@ -315,14 +315,14 @@ type PluginDef struct {
// https://golang.org/doc/install/source#environment.
Executable *string `json:"executable,omitempty"`
// ExternalServiceRegistration allows the service to get a service account token
// (or to use the client_credentials grant if the token provider is the OAuth2 Server)
ExternalServiceRegistration ExternalServiceRegistration `json:"externalServiceRegistration"`
// [internal only] Excludes the plugin from listings in Grafana's UI. Only
// allowed for `builtIn` plugins.
HideFromList bool `json:"hideFromList"`
// IAM allows the plugin to get a service account with tailored permissions and a token
// (or to use the client_credentials grant if the token provider is the OAuth2 Server)
Iam IAM `json:"iam"`
// Unique name of the plugin. If the plugin is published on
// grafana.com, then the plugin `id` has to follow the naming
// conventions.
+1 -1
View File
@@ -118,7 +118,7 @@ type JSONData struct {
Executable string `json:"executable,omitempty"`
// App Service Auth Registration
ExternalServiceRegistration *plugindef.ExternalServiceRegistration `json:"externalServiceRegistration,omitempty"`
IAM *plugindef.IAM `json:"iam,omitempty"`
}
func ReadPluginJSON(reader io.Reader) (JSONData, error) {