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
@@ -5,6 +5,7 @@ import (
"time"
"github.com/grafana/authlib/authn"
"github.com/grafana/authlib/claims"
"golang.org/x/oauth2"
"github.com/grafana/grafana/pkg/apimachinery/identity"
@@ -74,6 +75,19 @@ type Identity struct {
IDTokenClaims *authn.Claims[authn.IDTokenClaims]
}
// Access implements claims.AuthInfo.
func (i *Identity) GetAccess() claims.AccessClaims {
return &identity.IDClaimsWrapper{Source: i}
}
// Identity implements claims.AuthInfo.
func (i *Identity) GetIdentity() claims.IdentityClaims {
if i.IDTokenClaims != nil {
return authn.NewIdentityClaims(*i.IDTokenClaims)
}
return &identity.IDClaimsWrapper{Source: i}
}
// GetRawIdentifier implements Requester.
func (i *Identity) GetRawIdentifier() string {
return i.UID.ID()