Auth: Add access token to in-proc communication and ServiceIdentity (#98926)

Use fake access token for in-proc grpc and add ServiceIdentity 
---------

Co-authored-by: gamab <gabriel.mabille@grafana.com>
Co-authored-by: Karl Persson <23356117+kalleep@users.noreply.github.com>
This commit is contained in:
Misi
2025-01-24 14:03:23 +01:00
committed by GitHub
co-authored by gamab Karl Persson
parent eb2d276a42
commit 437b7a565d
12 changed files with 193 additions and 179 deletions
+2 -6
View File
@@ -6,7 +6,6 @@ import (
"github.com/stretchr/testify/assert"
claims "github.com/grafana/authlib/types"
"github.com/grafana/grafana/pkg/apimachinery/identity"
)
@@ -16,11 +15,8 @@ func TestIDTokenExtractor(t *testing.T) {
assert.Error(t, err)
assert.Empty(t, token)
})
t.Run("should return an empty token for static requester of type service account as grafana admin ", func(t *testing.T) {
ctx := identity.WithRequester(context.Background(), &identity.StaticRequester{
Type: claims.TypeServiceAccount,
IsGrafanaAdmin: true,
})
t.Run("should return an empty token when grafana identity is set", func(t *testing.T) {
ctx, _ := identity.WithServiceIdentitiy(context.Background(), 0)
token, err := idTokenExtractor(ctx)
assert.NoError(t, err)
assert.Empty(t, token)