Identity: Remove typed id (#91801)
* Refactor identity struct to store type in separate field * Update ResolveIdentity to take string representation of typedID * Add IsIdentityType to requester interface * Use IsIdentityType from interface * Remove usage of TypedID * Remote typedID struct * fix GetInternalID
This commit is contained in:
@@ -3,6 +3,7 @@ package accesscontrol
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"go.opentelemetry.io/otel"
|
||||
@@ -84,8 +85,8 @@ type SearchOptions struct {
|
||||
Action string
|
||||
ActionSets []string
|
||||
Scope string
|
||||
TypedID identity.TypedID // ID of the identity (ex: user:3, service-account:4)
|
||||
wildcards Wildcards // private field computed based on the Scope
|
||||
TypedID string // ID of the identity (ex: user:3, service-account:4)
|
||||
wildcards Wildcards // private field computed based on the Scope
|
||||
RolePrefixes []string
|
||||
}
|
||||
|
||||
@@ -105,17 +106,16 @@ func (s *SearchOptions) Wildcards() []string {
|
||||
}
|
||||
|
||||
func (s *SearchOptions) ComputeUserID() (int64, error) {
|
||||
id, err := s.TypedID.ParseInt()
|
||||
typ, id, err := identity.ParseTypeAndID(s.TypedID)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
// Validate namespace type is user or service account
|
||||
if s.TypedID.Type() != claims.TypeUser && s.TypedID.Type() != claims.TypeServiceAccount {
|
||||
return 0, fmt.Errorf("invalid type: %s", s.TypedID.Type())
|
||||
if !claims.IsIdentityType(typ, claims.TypeUser, claims.TypeServiceAccount) {
|
||||
return 0, fmt.Errorf("invalid type: %s", typ)
|
||||
}
|
||||
|
||||
return id, nil
|
||||
return strconv.ParseInt(id, 10, 64)
|
||||
}
|
||||
|
||||
type SyncUserRolesCommand struct {
|
||||
|
||||
Reference in New Issue
Block a user