Auth: Use claims.AuthInfo in requester (#91739)

This commit is contained in:
Ryan McKinley
2024-08-09 19:46:56 +03:00
committed by GitHub
parent d52626be3f
commit 243c0935fc
19 changed files with 207 additions and 207 deletions
+14
View File
@@ -4,6 +4,7 @@ import (
"fmt"
authnlib "github.com/grafana/authlib/authn"
"github.com/grafana/authlib/claims"
)
var _ Requester = &StaticRequester{}
@@ -35,6 +36,19 @@ type StaticRequester struct {
CacheKey string
}
// Access implements Requester.
func (u *StaticRequester) GetAccess() claims.AccessClaims {
return &IDClaimsWrapper{Source: u}
}
// Identity implements Requester.
func (u *StaticRequester) GetIdentity() claims.IdentityClaims {
if u.IDTokenClaims != nil {
return authnlib.NewIdentityClaims(*u.IDTokenClaims)
}
return &IDClaimsWrapper{Source: u}
}
// GetRawIdentifier implements Requester.
func (u *StaticRequester) GetUID() string {
return fmt.Sprintf("%s:%s", u.Type, u.UserUID)