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
-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