Documentation
¶
Index ¶
- Constants
- Variables
- func IndexUsers(ctx context.Context, indexer client.FieldIndexer) error
- func SubjectIndexValue(object client.Object) []string
- type Index
- type UserDatabase
- func (d *UserDatabase) GetActiveOrganizationUser(ctx context.Context, organizationID string, user *unikornv1.User) (*unikornv1.OrganizationUser, error)
- func (d *UserDatabase) GetActiveUser(ctx context.Context, subject string) (*unikornv1.User, error)
- func (d *UserDatabase) GetOrganizationIDs(ctx context.Context, subject string) ([]string, error)
- func (d *UserDatabase) GetOrganizationIDsForUser(ctx context.Context, user *unikornv1.User) ([]string, error)
- func (d *UserDatabase) GetServiceAccount(ctx context.Context, organizationID, id string) (*unikornv1.ServiceAccount, error)
- func (d *UserDatabase) GetUser(ctx context.Context, subject string) (*unikornv1.User, error)
- func (d *UserDatabase) ListOrganizationUsers(ctx context.Context, user *unikornv1.User) ([]unikornv1.OrganizationUser, error)
Constants ¶
const ( // SubjectIndexField indexes Users by the canonical form of their subject. // It serves the unlabelled legacy lookup in GetUser. SubjectIndexField = "spec.subject.canonical" // SubjectLabelIndexField indexes Users by their subject-ID label. It // serves the labelled legacy lookup in GetUser. SubjectLabelIndexField = "metadata.labels.user-subject-id" // MembershipUserIndexField indexes OrganizationUsers by their user label. // It serves every membership lookup. MembershipUserIndexField = "metadata.labels.user" )
Field indexes served by the informer cache. A List with a label selector and no namespace walks every cached object of the kind, so each lookup that would select by label asks the matching index instead. See the README's "Readers" section.
Variables ¶
var ( // ErrResourceReference is raised when a resource cannot be looked up. ErrResourceReference = fmt.Errorf("resource reference error") // ErrUserInactive identifies an inactive global user and wraps // ErrResourceReference for compatibility. ErrUserInactive = fmt.Errorf("%w: user is not active", ErrResourceReference) // ErrAmbiguousSubject identifies a subject that folds onto multiple users. ErrAmbiguousSubject = fmt.Errorf("%w: subject matches more than one user", ErrResourceReference) )
Functions ¶
func IndexUsers ¶ added in v1.28.0
func IndexUsers(ctx context.Context, indexer client.FieldIndexer) error
IndexUsers registers every index in Indexes with indexer.
func SubjectIndexValue ¶ added in v1.28.0
SubjectIndexValue is the index function for SubjectIndexField.
Types ¶
type Index ¶ added in v1.28.0
type Index struct {
Object client.Object
Field string
Func client.IndexerFunc
}
Index is a field index that the cache given to NewUserDatabase MUST have registered before it starts.
type UserDatabase ¶
type UserDatabase struct {
// contains filtered or unexported fields
}
UserDatabase resolves identities from the informer cache. It never writes and never reads live.
func NewUserDatabase ¶
func NewUserDatabase(reader client.Reader, namespace string) *UserDatabase
NewUserDatabase returns a user database over reader. The reader MUST be the informer cache with every index in Indexes registered before it starts: the API server cannot serve a field index on a custom resource, so a live client fails every lookup. A caller that decides a write on a record MUST read it live itself and check it again. See the README's "Readers" section.
func (*UserDatabase) GetActiveOrganizationUser ¶
func (d *UserDatabase) GetActiveOrganizationUser(ctx context.Context, organizationID string, user *unikornv1.User) (*unikornv1.OrganizationUser, error)
GetActiveOrganizationUser gets an organization user that references the actual user.
func (*UserDatabase) GetActiveUser ¶
GetActiveUser returns a user that match the subject and is active.
func (*UserDatabase) GetOrganizationIDs ¶
GetOrganizationIDs returns the active organization IDs for a user subject.
func (*UserDatabase) GetOrganizationIDsForUser ¶ added in v1.24.0
func (d *UserDatabase) GetOrganizationIDsForUser(ctx context.Context, user *unikornv1.User) ([]string, error)
GetOrganizationIDsForUser returns the active organization IDs for an active user.
func (*UserDatabase) GetServiceAccount ¶
func (d *UserDatabase) GetServiceAccount(ctx context.Context, organizationID, id string) (*unikornv1.ServiceAccount, error)
GetServiceAccount reads a service account by key: its organization's namespace and its ID.
func (*UserDatabase) ListOrganizationUsers ¶ added in v1.28.0
func (d *UserDatabase) ListOrganizationUsers(ctx context.Context, user *unikornv1.User) ([]unikornv1.OrganizationUser, error)
ListOrganizationUsers returns the user's membership records, in every organization and in any state. The index finds them by user label, so the cost follows the user's memberships, not the number of members in the estate.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package userdbtest gives tests a fake client that serves the indexes the user database queries.
|
Package userdbtest gives tests a fake client that serves the indexes the user database queries. |