Auth: use IdentityType from authlib (#91763)

This commit is contained in:
Ryan McKinley
2024-08-12 09:26:53 +03:00
committed by GitHub
parent faf7cb9312
commit 21d4a4f49e
70 changed files with 230 additions and 212 deletions
+3 -3
View File
@@ -14,7 +14,7 @@ type Requester interface {
claims.AuthInfo
// GetIdentityType returns the type for the requester
GetIdentityType() IdentityType
GetIdentityType() claims.IdentityType
// GetRawIdentifier returns only the identifier part of the UID, excluding the type
GetRawIdentifier() string
// Deprecated: use GetUID instead
@@ -82,7 +82,7 @@ type Requester interface {
// Applicable for users, service accounts, api keys and renderer service.
// Errors if the identifier is not initialized or if type is not recognized.
func IntIdentifier(typedID TypedID) (int64, error) {
if IsIdentityType(typedID, TypeUser, TypeAPIKey, TypeServiceAccount, TypeRenderService) {
if claims.IsIdentityType(typedID.t, claims.TypeUser, claims.TypeAPIKey, claims.TypeServiceAccount, claims.TypeRenderService) {
id, err := strconv.ParseInt(typedID.ID(), 10, 64)
if err != nil {
return 0, fmt.Errorf("unrecognized format for valid type %s: %w", typedID.Type(), err)
@@ -107,7 +107,7 @@ func UserIdentifier(typedID TypedID) (int64, error) {
return 0, err
}
if IsIdentityType(typedID, TypeUser, TypeServiceAccount) {
if claims.IsIdentityType(typedID.t, claims.TypeUser, claims.TypeServiceAccount) {
return userID, nil
}