Requester: Remove duplicated function (#97038)

* Remove duplicated function

* Remove GetDisplayName from interface

* Use GetName
This commit is contained in:
Karl Persson
2024-11-26 15:29:31 +01:00
committed by GitHub
parent 6d04023aa6
commit 76f052e8de
12 changed files with 26 additions and 69 deletions
+2 -5
View File
@@ -23,9 +23,6 @@ type Requester interface {
// GetID returns namespaced internalID for the entity
// Deprecated: use GetUID instead
GetID() string
// GetDisplayName returns the display name of the active entity.
// The display name is the name if it is set, otherwise the login or email.
GetDisplayName() string
// GetEmail returns the email of the active entity.
// Can be empty.
GetEmail() string
@@ -62,6 +59,8 @@ type Requester interface {
// IsNil returns true if the identity is nil
// FIXME: remove this method once all services are using an interface
IsNil() bool
// GetIDToken returns a signed token representing the identity that can be forwarded to plugins and external services.
GetIDToken() string
// Legacy
@@ -72,8 +71,6 @@ type Requester interface {
GetCacheKey() string
// HasUniqueId returns true if the entity has a unique id
HasUniqueId() bool
// GetIDToken returns a signed token representing the identity that can be forwarded to plugins and external services.
GetIDToken() string
}
// IntIdentifier converts a typeID to an int64.
+7 -21
View File
@@ -22,7 +22,6 @@ type StaticRequester struct {
OrgRole RoleType
Login string
Name string
DisplayName string
Email string
EmailVerified bool
AuthID string
@@ -89,7 +88,13 @@ func (u *StaticRequester) GetGroups() []string {
// GetName implements Requester.
func (u *StaticRequester) GetName() string {
return u.DisplayName
if u.Name != "" {
return u.Name
}
if u.Login != "" {
return u.Login
}
return u.Email
}
func (u *StaticRequester) HasRole(role RoleType) bool {
@@ -211,25 +216,6 @@ func (u *StaticRequester) GetCacheKey() string {
return u.CacheKey
}
// GetDisplayName returns the display name of the active entity
// The display name is the name if it is set, otherwise the login or email
func (u *StaticRequester) GetDisplayName() string {
if u.DisplayName != "" {
return u.DisplayName
}
if u.Name != "" {
return u.Name
}
if u.Login != "" {
return u.Login
}
return u.Email
}
func (u *StaticRequester) GetIDToken() string {
return u.IDToken
}
func (u *StaticRequester) GetIDClaims() *authnlib.Claims[authnlib.IDTokenClaims] {
return u.IDTokenClaims
}
+1 -1
View File
@@ -25,7 +25,7 @@ func (i *IDClaimsWrapper) AuthenticatedBy() string {
// GetDisplayName implements claims.IdentityClaims.
func (i *IDClaimsWrapper) DisplayName() string {
return i.Source.GetDisplayName()
return i.Source.GetName()
}
// GetEmail implements claims.IdentityClaims.