Skip to content

Commit 969e6a1

Browse files
authored
Plugins: Rename oauth package to auth (grafana#75611)
* Plugins: Rename oauth package to auth * Missed one comment
1 parent bfdcfa8 commit 969e6a1

File tree

12 files changed

+37
-37
lines changed

12 files changed

+37
-37
lines changed

pkg/plugins/oauth/models.go renamed to pkg/plugins/auth/models.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package oauth
1+
package auth
22

33
import (
44
"context"

pkg/plugins/envvars/envvars.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import (
1414
"github.com/grafana/grafana-plugin-sdk-go/experimental/featuretoggles"
1515

1616
"github.com/grafana/grafana/pkg/plugins"
17+
"github.com/grafana/grafana/pkg/plugins/auth"
1718
"github.com/grafana/grafana/pkg/plugins/config"
18-
"github.com/grafana/grafana/pkg/plugins/oauth"
1919
)
2020

2121
const (
@@ -74,7 +74,7 @@ func (s *Service) Get(ctx context.Context, p *plugins.Plugin) []string {
7474
}
7575

7676
// GetConfigMap returns a map of configuration that should be passed in a plugin request.
77-
func (s *Service) GetConfigMap(ctx context.Context, _ string, _ *oauth.ExternalService) map[string]string {
77+
func (s *Service) GetConfigMap(ctx context.Context, _ string, _ *auth.ExternalService) map[string]string {
7878
m := make(map[string]string)
7979

8080
// TODO add support via plugin SDK

pkg/plugins/envvars/envvars_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import (
99
"github.com/stretchr/testify/require"
1010

1111
"github.com/grafana/grafana/pkg/plugins"
12+
"github.com/grafana/grafana/pkg/plugins/auth"
1213
"github.com/grafana/grafana/pkg/plugins/config"
1314
"github.com/grafana/grafana/pkg/plugins/manager/fakes"
14-
"github.com/grafana/grafana/pkg/plugins/oauth"
1515
"github.com/grafana/grafana/pkg/plugins/plugindef"
1616
"github.com/grafana/grafana/pkg/services/featuremgmt"
1717
"github.com/grafana/grafana/pkg/setting"
@@ -313,7 +313,7 @@ func TestInitializer_oauthEnvVars(t *testing.T) {
313313
ID: "test",
314314
ExternalServiceRegistration: &plugindef.ExternalServiceRegistration{},
315315
},
316-
ExternalService: &oauth.ExternalService{
316+
ExternalService: &auth.ExternalService{
317317
ClientID: "clientID",
318318
ClientSecret: "clientSecret",
319319
PrivateKey: "privatePem",

pkg/plugins/manager/fakes/fakes.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import (
1010
"github.com/grafana/grafana-plugin-sdk-go/backend"
1111

1212
"github.com/grafana/grafana/pkg/plugins"
13+
"github.com/grafana/grafana/pkg/plugins/auth"
1314
"github.com/grafana/grafana/pkg/plugins/backendplugin"
1415
"github.com/grafana/grafana/pkg/plugins/log"
15-
"github.com/grafana/grafana/pkg/plugins/oauth"
1616
"github.com/grafana/grafana/pkg/plugins/plugindef"
1717
"github.com/grafana/grafana/pkg/plugins/repo"
1818
"github.com/grafana/grafana/pkg/plugins/storage"
@@ -425,11 +425,11 @@ func (f *FakePluginFileStore) File(ctx context.Context, pluginID, filename strin
425425
return nil, nil
426426
}
427427

428-
type FakeOauthService struct {
429-
Result *oauth.ExternalService
428+
type FakeAuthService struct {
429+
Result *auth.ExternalService
430430
}
431431

432-
func (f *FakeOauthService) RegisterExternalService(ctx context.Context, name string, svc *plugindef.ExternalServiceRegistration) (*oauth.ExternalService, error) {
432+
func (f *FakeAuthService) RegisterExternalService(ctx context.Context, name string, svc *plugindef.ExternalServiceRegistration) (*auth.ExternalService, error) {
433433
return f.Result, nil
434434
}
435435

pkg/plugins/plugins.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ import (
1414

1515
"github.com/grafana/grafana-plugin-sdk-go/backend"
1616

17+
"github.com/grafana/grafana/pkg/plugins/auth"
1718
"github.com/grafana/grafana/pkg/plugins/backendplugin"
1819
"github.com/grafana/grafana/pkg/plugins/backendplugin/pluginextensionv2"
1920
"github.com/grafana/grafana/pkg/plugins/backendplugin/secretsmanagerplugin"
2021
"github.com/grafana/grafana/pkg/plugins/log"
21-
"github.com/grafana/grafana/pkg/plugins/oauth"
2222
"github.com/grafana/grafana/pkg/plugins/plugindef"
2323
"github.com/grafana/grafana/pkg/services/org"
2424
"github.com/grafana/grafana/pkg/util"
@@ -56,7 +56,7 @@ type Plugin struct {
5656

5757
AngularDetected bool
5858

59-
ExternalService *oauth.ExternalService
59+
ExternalService *auth.ExternalService
6060

6161
Renderer pluginextensionv2.RendererPlugin
6262
SecretsManager secretsmanagerplugin.SecretsManagerPlugin
@@ -112,7 +112,7 @@ type JSONData struct {
112112
// Backend (Datasource + Renderer + SecretsManager)
113113
Executable string `json:"executable,omitempty"`
114114

115-
// Oauth App Service Registration
115+
// App Service Auth Registration
116116
ExternalServiceRegistration *plugindef.ExternalServiceRegistration `json:"externalServiceRegistration,omitempty"`
117117
}
118118

pkg/services/pluginsintegration/loader/loader_test.go

+10-10
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"github.com/stretchr/testify/require"
1313

1414
"github.com/grafana/grafana/pkg/plugins"
15+
"github.com/grafana/grafana/pkg/plugins/auth"
1516
"github.com/grafana/grafana/pkg/plugins/backendplugin"
1617
"github.com/grafana/grafana/pkg/plugins/config"
1718
"github.com/grafana/grafana/pkg/plugins/log"
@@ -23,7 +24,6 @@ import (
2324
"github.com/grafana/grafana/pkg/plugins/manager/registry"
2425
"github.com/grafana/grafana/pkg/plugins/manager/signature"
2526
"github.com/grafana/grafana/pkg/plugins/manager/sources"
26-
"github.com/grafana/grafana/pkg/plugins/oauth"
2727
"github.com/grafana/grafana/pkg/plugins/plugindef"
2828
"github.com/grafana/grafana/pkg/plugins/pluginscdn"
2929
"github.com/grafana/grafana/pkg/services/featuremgmt"
@@ -555,7 +555,7 @@ func TestLoader_Load_ExternalRegistration(t *testing.T) {
555555
Signature: plugins.SignatureStatusUnsigned,
556556
Module: "/public/plugins/grafana-test-datasource/module.js",
557557
BaseURL: "/public/plugins/grafana-test-datasource",
558-
ExternalService: &oauth.ExternalService{
558+
ExternalService: &auth.ExternalService{
559559
ClientID: "client-id",
560560
ClientSecret: "secretz",
561561
PrivateKey: "priv@t3",
@@ -576,8 +576,8 @@ func TestLoader_Load_ExternalRegistration(t *testing.T) {
576576
}
577577

578578
l := newLoaderWithOpts(t, cfg, loaderDepOpts{
579-
oauthServiceRegistry: &fakes.FakeOauthService{
580-
Result: &oauth.ExternalService{
579+
authServiceRegistry: &fakes.FakeAuthService{
580+
Result: &auth.ExternalService{
581581
ClientID: "client-id",
582582
ClientSecret: "secretz",
583583
PrivateKey: "priv@t3",
@@ -1468,7 +1468,7 @@ func TestLoader_Load_NestedPlugins(t *testing.T) {
14681468

14691469
type loaderDepOpts struct {
14701470
angularInspector angularinspector.Inspector
1471-
oauthServiceRegistry oauth.ExternalServiceRegistry
1471+
authServiceRegistry auth.ExternalServiceRegistry
14721472
backendFactoryProvider plugins.BackendFactoryProvider
14731473
}
14741474

@@ -1484,7 +1484,7 @@ func newLoader(t *testing.T, cfg *config.Cfg, reg registry.Service, proc process
14841484
return ProvideService(pipeline.ProvideDiscoveryStage(cfg, finder.NewLocalFinder(false), reg),
14851485
pipeline.ProvideBootstrapStage(cfg, signature.DefaultCalculator(cfg), assets),
14861486
pipeline.ProvideValidationStage(cfg, signature.NewValidator(signature.NewUnsignedAuthorizer(cfg)), angularInspector, sigErrTracker),
1487-
pipeline.ProvideInitializationStage(cfg, reg, lic, backendFactory, proc, &fakes.FakeOauthService{}, fakes.NewFakeRoleRegistry()),
1487+
pipeline.ProvideInitializationStage(cfg, reg, lic, backendFactory, proc, &fakes.FakeAuthService{}, fakes.NewFakeRoleRegistry()),
14881488
terminate)
14891489
}
14901490

@@ -1503,9 +1503,9 @@ func newLoaderWithOpts(t *testing.T, cfg *config.Cfg, opts loaderDepOpts) *Loade
15031503
angularInspector = angularinspector.NewStaticInspector()
15041504
}
15051505

1506-
oauthServiceRegistry := opts.oauthServiceRegistry
1507-
if oauthServiceRegistry == nil {
1508-
oauthServiceRegistry = &fakes.FakeOauthService{}
1506+
authServiceRegistry := opts.authServiceRegistry
1507+
if authServiceRegistry == nil {
1508+
authServiceRegistry = &fakes.FakeAuthService{}
15091509
}
15101510

15111511
backendFactoryProvider := opts.backendFactoryProvider
@@ -1516,7 +1516,7 @@ func newLoaderWithOpts(t *testing.T, cfg *config.Cfg, opts loaderDepOpts) *Loade
15161516
return ProvideService(pipeline.ProvideDiscoveryStage(cfg, finder.NewLocalFinder(false), reg),
15171517
pipeline.ProvideBootstrapStage(cfg, signature.DefaultCalculator(cfg), assets),
15181518
pipeline.ProvideValidationStage(cfg, signature.NewValidator(signature.NewUnsignedAuthorizer(cfg)), angularInspector, sigErrTracker),
1519-
pipeline.ProvideInitializationStage(cfg, reg, lic, backendFactoryProvider, proc, oauthServiceRegistry, fakes.NewFakeRoleRegistry()),
1519+
pipeline.ProvideInitializationStage(cfg, reg, lic, backendFactoryProvider, proc, authServiceRegistry, fakes.NewFakeRoleRegistry()),
15201520
terminate)
15211521
}
15221522

pkg/services/pluginsintegration/pipeline/pipeline.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55

66
"github.com/grafana/grafana/pkg/plugins"
7+
"github.com/grafana/grafana/pkg/plugins/auth"
78
"github.com/grafana/grafana/pkg/plugins/config"
89
"github.com/grafana/grafana/pkg/plugins/envvars"
910
"github.com/grafana/grafana/pkg/plugins/manager/loader/angular/angularinspector"
@@ -17,7 +18,6 @@ import (
1718
"github.com/grafana/grafana/pkg/plugins/manager/process"
1819
"github.com/grafana/grafana/pkg/plugins/manager/registry"
1920
"github.com/grafana/grafana/pkg/plugins/manager/signature"
20-
"github.com/grafana/grafana/pkg/plugins/oauth"
2121
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginerrs"
2222
)
2323

@@ -59,7 +59,7 @@ func ProvideValidationStage(cfg *config.Cfg, sv signature.Validator, ai angulari
5959
}
6060

6161
func ProvideInitializationStage(cfg *config.Cfg, pr registry.Service, l plugins.Licensing,
62-
bp plugins.BackendFactoryProvider, pm process.Manager, externalServiceRegistry oauth.ExternalServiceRegistry,
62+
bp plugins.BackendFactoryProvider, pm process.Manager, externalServiceRegistry auth.ExternalServiceRegistry,
6363
roleRegistry plugins.RoleRegistry) *initialization.Initialize {
6464
return initialization.New(cfg, initialization.Opts{
6565
InitializeFuncs: []initialization.InitializeFunc{

pkg/services/pluginsintegration/pipeline/steps.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,29 @@ import (
66

77
"github.com/grafana/grafana/pkg/infra/metrics"
88
"github.com/grafana/grafana/pkg/plugins"
9+
"github.com/grafana/grafana/pkg/plugins/auth"
910
"github.com/grafana/grafana/pkg/plugins/config"
1011
"github.com/grafana/grafana/pkg/plugins/log"
1112
"github.com/grafana/grafana/pkg/plugins/manager/pipeline/initialization"
1213
"github.com/grafana/grafana/pkg/plugins/manager/pipeline/validation"
1314
"github.com/grafana/grafana/pkg/plugins/manager/signature"
14-
"github.com/grafana/grafana/pkg/plugins/oauth"
1515
"github.com/grafana/grafana/pkg/services/featuremgmt"
1616
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginerrs"
1717
)
1818

1919
// ExternalServiceRegistration implements an InitializeFunc for registering external services.
2020
type ExternalServiceRegistration struct {
2121
cfg *config.Cfg
22-
externalServiceRegistry oauth.ExternalServiceRegistry
22+
externalServiceRegistry auth.ExternalServiceRegistry
2323
log log.Logger
2424
}
2525

2626
// ExternalServiceRegistrationStep returns an InitializeFunc for registering external services.
27-
func ExternalServiceRegistrationStep(cfg *config.Cfg, externalServiceRegistry oauth.ExternalServiceRegistry) initialization.InitializeFunc {
27+
func ExternalServiceRegistrationStep(cfg *config.Cfg, externalServiceRegistry auth.ExternalServiceRegistry) initialization.InitializeFunc {
2828
return newExternalServiceRegistration(cfg, externalServiceRegistry).Register
2929
}
3030

31-
func newExternalServiceRegistration(cfg *config.Cfg, serviceRegistry oauth.ExternalServiceRegistry) *ExternalServiceRegistration {
31+
func newExternalServiceRegistration(cfg *config.Cfg, serviceRegistry auth.ExternalServiceRegistry) *ExternalServiceRegistration {
3232
return &ExternalServiceRegistration{
3333
cfg: cfg,
3434
externalServiceRegistry: serviceRegistry,

pkg/services/pluginsintegration/pluginsintegration.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55

66
"github.com/grafana/grafana/pkg/infra/tracing"
77
"github.com/grafana/grafana/pkg/plugins"
8+
"github.com/grafana/grafana/pkg/plugins/auth"
89
"github.com/grafana/grafana/pkg/plugins/backendplugin/coreplugin"
910
"github.com/grafana/grafana/pkg/plugins/backendplugin/provider"
1011
pCfg "github.com/grafana/grafana/pkg/plugins/config"
@@ -25,7 +26,6 @@ import (
2526
"github.com/grafana/grafana/pkg/plugins/manager/registry"
2627
"github.com/grafana/grafana/pkg/plugins/manager/signature"
2728
"github.com/grafana/grafana/pkg/plugins/manager/sources"
28-
"github.com/grafana/grafana/pkg/plugins/oauth"
2929
"github.com/grafana/grafana/pkg/plugins/pluginscdn"
3030
"github.com/grafana/grafana/pkg/plugins/repo"
3131
"github.com/grafana/grafana/pkg/services/caching"
@@ -114,7 +114,7 @@ var WireSet = wire.NewSet(
114114
keyretriever.ProvideService,
115115
dynamic.ProvideService,
116116
serviceregistration.ProvideService,
117-
wire.Bind(new(oauth.ExternalServiceRegistry), new(*serviceregistration.Service)),
117+
wire.Bind(new(auth.ExternalServiceRegistry), new(*serviceregistration.Service)),
118118
)
119119

120120
// WireExtensionSet provides a wire.ProviderSet of plugin providers that can be

pkg/services/pluginsintegration/pluginstore/plugins.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"github.com/grafana/grafana-plugin-sdk-go/backend"
55

66
"github.com/grafana/grafana/pkg/plugins"
7-
"github.com/grafana/grafana/pkg/plugins/oauth"
7+
"github.com/grafana/grafana/pkg/plugins/auth"
88
)
99

1010
type Plugin struct {
@@ -35,7 +35,7 @@ type Plugin struct {
3535
// This will be moved to plugin.json when we have general support in gcom
3636
Alias string
3737

38-
ExternalService *oauth.ExternalService
38+
ExternalService *auth.ExternalService
3939
}
4040

4141
func (p Plugin) SupportsStreaming() bool {

pkg/services/pluginsintegration/serviceregistration/serviceregistration.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package serviceregistration
33
import (
44
"context"
55

6-
"github.com/grafana/grafana/pkg/plugins/oauth"
6+
"github.com/grafana/grafana/pkg/plugins/auth"
77
"github.com/grafana/grafana/pkg/plugins/plugindef"
88
"github.com/grafana/grafana/pkg/services/accesscontrol"
99
"github.com/grafana/grafana/pkg/services/oauthserver"
@@ -21,7 +21,7 @@ func ProvideService(os oauthserver.OAuth2Server) *Service {
2121
}
2222

2323
// RegisterExternalService is a simplified wrapper around SaveExternalService for the plugin use case.
24-
func (s *Service) RegisterExternalService(ctx context.Context, svcName string, svc *plugindef.ExternalServiceRegistration) (*oauth.ExternalService, error) {
24+
func (s *Service) RegisterExternalService(ctx context.Context, svcName string, svc *plugindef.ExternalServiceRegistration) (*auth.ExternalService, error) {
2525
impersonation := oauthserver.ImpersonationCfg{}
2626
if svc.Impersonation != nil {
2727
impersonation.Permissions = toAccessControlPermissions(svc.Impersonation.Permissions)
@@ -56,7 +56,7 @@ func (s *Service) RegisterExternalService(ctx context.Context, svcName string, s
5656
return nil, err
5757
}
5858

59-
return &oauth.ExternalService{
59+
return &auth.ExternalService{
6060
ClientID: extSvc.ID,
6161
ClientSecret: extSvc.Secret,
6262
PrivateKey: extSvc.KeyResult.PrivatePem,

pkg/services/pluginsintegration/test_helper.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func CreateIntegrationTestCtx(t *testing.T, cfg *setting.Cfg, coreRegistry *core
5454
disc := pipeline.ProvideDiscoveryStage(pCfg, finder.NewLocalFinder(true), reg)
5555
boot := pipeline.ProvideBootstrapStage(pCfg, signature.ProvideService(pCfg, statickey.New()), assetpath.ProvideService(pCfg, cdn))
5656
valid := pipeline.ProvideValidationStage(pCfg, signature.NewValidator(signature.NewUnsignedAuthorizer(pCfg)), angularInspector, errTracker)
57-
init := pipeline.ProvideInitializationStage(pCfg, reg, fakes.NewFakeLicensingService(), provider.ProvideService(coreRegistry), proc, &fakes.FakeOauthService{}, fakes.NewFakeRoleRegistry())
57+
init := pipeline.ProvideInitializationStage(pCfg, reg, fakes.NewFakeLicensingService(), provider.ProvideService(coreRegistry), proc, &fakes.FakeAuthService{}, fakes.NewFakeRoleRegistry())
5858
term, err := pipeline.ProvideTerminationStage(pCfg, reg, proc)
5959
require.NoError(t, err)
6060

@@ -100,7 +100,7 @@ func CreateTestLoader(t *testing.T, cfg *pluginsCfg.Cfg, opts LoaderOpts) *loade
100100
if opts.Initializer == nil {
101101
reg := registry.ProvideService()
102102
coreRegistry := coreplugin.NewRegistry(make(map[string]backendplugin.PluginFactoryFunc))
103-
opts.Initializer = pipeline.ProvideInitializationStage(cfg, reg, fakes.NewFakeLicensingService(), provider.ProvideService(coreRegistry), process.ProvideService(), &fakes.FakeOauthService{}, fakes.NewFakeRoleRegistry())
103+
opts.Initializer = pipeline.ProvideInitializationStage(cfg, reg, fakes.NewFakeLicensingService(), provider.ProvideService(coreRegistry), process.ProvideService(), &fakes.FakeAuthService{}, fakes.NewFakeRoleRegistry())
104104
}
105105

106106
if opts.Terminator == nil {

0 commit comments

Comments
 (0)