Auth: use IdentityType from authlib (#91763)
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
|
||||
"github.com/grafana/authlib/claims"
|
||||
authnClients "github.com/grafana/grafana/pkg/services/authn/clients"
|
||||
|
||||
"github.com/grafana/grafana/pkg/api/response"
|
||||
@@ -157,9 +158,9 @@ func (h *ContextHandler) addIDHeaderEndOfRequestFunc(ident identity.Requester) w
|
||||
id := ident.GetID()
|
||||
if !identity.IsIdentityType(
|
||||
id,
|
||||
identity.TypeUser,
|
||||
identity.TypeServiceAccount,
|
||||
identity.TypeAPIKey,
|
||||
claims.TypeUser,
|
||||
claims.TypeServiceAccount,
|
||||
claims.TypeAPIKey,
|
||||
) || id.ID() == "0" {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/grafana/authlib/claims"
|
||||
"github.com/grafana/grafana/pkg/api/routing"
|
||||
"github.com/grafana/grafana/pkg/apimachinery/identity"
|
||||
"github.com/grafana/grafana/pkg/infra/tracing"
|
||||
@@ -43,7 +44,7 @@ func TestContextHandler(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("should set identity on successful authentication", func(t *testing.T) {
|
||||
id := &authn.Identity{ID: identity.NewTypedID(identity.TypeUser, 1), OrgID: 1}
|
||||
id := &authn.Identity{ID: identity.NewTypedID(claims.TypeUser, 1), OrgID: 1}
|
||||
handler := contexthandler.ProvideService(
|
||||
setting.NewCfg(),
|
||||
tracing.InitializeTracerForTest(),
|
||||
|
||||
Reference in New Issue
Block a user