Files
grafana/pkg/services/auth/id.go
T
Karl Persson 43b6b6b2a4 IDForwarding: add "authenticatedBy" to id token (#80622)
* IDForwading: Set authenticated by for users
2024-01-17 09:52:05 +01:00

31 lines
795 B
Go

package auth
import (
"context"
"github.com/go-jose/go-jose/v3/jwt"
"github.com/grafana/grafana/pkg/services/auth/identity"
"github.com/grafana/grafana/pkg/services/datasources"
)
type IDService interface {
// SignIdentity signs a id token for provided identity that can be forwarded to plugins and external services
SignIdentity(ctx context.Context, identity identity.Requester) (string, error)
}
type IDSigner interface {
SignIDToken(ctx context.Context, claims *IDClaims) (string, error)
}
type IDClaims struct {
jwt.Claims
AuthenticatedBy string `json:"authenticatedBy,omitempty"`
}
const settingsKey = "forwardGrafanaIdToken"
func IsIDForwardingEnabledForDataSource(ds *datasources.DataSource) bool {
return ds.JsonData != nil && ds.JsonData.Get(settingsKey).MustBool()
}