Authz: Remove legacy API Key permissions (#110860)

* remove API key roles

* remove API key gen

* remove frontend and doc mentions

* restore legacy keygen

* restore codeowners

* prettier

* update swagger

* remove permissions including apikeys

* add migrator for removing deprecated permissions

* add tracing

* update openapi3

* simplify migrator for now

* accesscontrol/migrator: remove batching for deprecated permissions deletion
This commit is contained in:
Jo
2025-09-12 13:59:37 +02:00
committed by GitHub
parent 1f7afc6b6a
commit edcd113054
26 changed files with 346 additions and 189 deletions
+3 -5
View File
@@ -3,13 +3,11 @@ package apikeygen
import (
"encoding/base64"
"encoding/json"
"errors"
"github.com/grafana/grafana/pkg/components/satokengen"
"github.com/grafana/grafana/pkg/util"
)
var ErrInvalidApiKey = errors.New("invalid API key")
type KeyGenResult struct {
HashedKey string
ClientSecret string
@@ -50,13 +48,13 @@ func New(orgId int64, name string) (KeyGenResult, error) {
func Decode(keyString string) (*ApiKeyJson, error) {
jsonString, err := base64.StdEncoding.DecodeString(keyString)
if err != nil {
return nil, ErrInvalidApiKey
return nil, satokengen.ErrInvalidApiKey
}
var keyObj ApiKeyJson
err = json.Unmarshal(jsonString, &keyObj)
if err != nil {
return nil, ErrInvalidApiKey
return nil, satokengen.ErrInvalidApiKey
}
return &keyObj, nil
-14
View File
@@ -1,14 +0,0 @@
package satokengen
import "github.com/grafana/grafana/pkg/components/apikeygen"
type ErrInvalidApiKey struct {
}
func (e *ErrInvalidApiKey) Error() string {
return "invalid API key"
}
func (e *ErrInvalidApiKey) Unwrap() error {
return apikeygen.ErrInvalidApiKey
}
+6 -3
View File
@@ -2,6 +2,7 @@ package satokengen
import (
"encoding/hex"
"errors"
"hash/crc32"
"strings"
@@ -10,6 +11,8 @@ import (
const GrafanaPrefix = "gl"
var ErrInvalidApiKey = errors.New("invalid API key")
type KeyGenResult struct {
HashedKey string
ClientSecret string
@@ -72,12 +75,12 @@ func New(serviceID string) (KeyGenResult, error) {
func Decode(keyString string) (*PrefixedKey, error) {
if !strings.HasPrefix(keyString, GrafanaPrefix) {
return nil, &ErrInvalidApiKey{}
return nil, ErrInvalidApiKey
}
parts := strings.Split(keyString, "_")
if len(parts) != 3 {
return nil, &ErrInvalidApiKey{}
return nil, ErrInvalidApiKey
}
key := &PrefixedKey{
@@ -86,7 +89,7 @@ func Decode(keyString string) (*PrefixedKey, error) {
Checksum: parts[2],
}
if key.CalculateChecksum() != key.Checksum {
return nil, &ErrInvalidApiKey{}
return nil, ErrInvalidApiKey
}
return key, nil