Documentation
¶
Overview ¶
Package implements models representing identity
Index ¶
- Constants
- Variables
- type AuthInfo
- type ContexIdentityType
- type Identity
- func (identity *Identity) GetAuthInfo() AuthInfo
- func (identity *Identity) GetClaim(name string) (string, bool)
- func (identity *Identity) GetEmail() (string, error)
- func (identity *Identity) GetGroups() ([]string, error)
- func (identity *Identity) GetId() string
- func (identity *Identity) GetName() (string, error)
- func (identity *Identity) GetSubject() (string, error)
- func (identity *Identity) GetToken() string
- func (identity *Identity) IsCluster() bool
- func (identity *Identity) IsService() bool
- func (identity *Identity) IsUser() bool
- func (identity Identity) ReturnGroupQuery() (bson.A, error)
- func (identity *Identity) SetToken(token string)
- func (identity *Identity) Validate() error
- type IdentityProvider
- type IdentityType
Constants ¶
const ( IdentityTypeUser IdentityType = "User" IdentityTypeCluster IdentityType = "Cluster" IdentityTypeService IdentityType = "Service" IdentityProviderOidc IdentityProvider = "OIDC" IdentityProviderApiKey IdentityProvider = "APIKEY" )
Variables ¶
var ( ErrUnknownIdentityType = errors.New("unknown identity type") ErrIncompleteIdentity = errors.New("incomplete identity") ErrNotAUser = errors.New("identity is not a user") )
Errors returned when an identity cannot be resolved. They are sentinels so callers can match with errors.Is rather than on message text.
Functions ¶
This section is empty.
Types ¶
type AuthInfo ¶
type AuthInfo struct {
AuthProvider IdentityProvider `json:"authProvider,omitempty"`
AuthProviderID string `json:"authProviderId,omitempty"`
ExpirationTime time.Time `json:"expirationTime"`
}
type ContexIdentityType ¶
type ContexIdentityType string
Type used to set identity in context
const ContexIdentity ContexIdentityType = "ror-identity"
type Identity ¶
type Identity struct {
Auth AuthInfo `json:"auth"`
Type IdentityType `json:"type,omitempty"`
// contains filtered or unexported fields
}
Identity is a representation of the consumers identity kept in the context for authentication
func NewClusterIdentity ¶ added in v1.25.6
NewClusterIdentity builds a cluster identity. The uid is required: cluster grants are keyed by uid, so an identity without one resolves to no access.
func NewServiceIdentity ¶ added in v1.25.6
NewServiceIdentity builds a service identity.
func NewUserIdentity ¶ added in v1.25.6
func NewUserIdentity(auth AuthInfo, email, name string, idpGroups []string, claims map[string]string) (Identity, error)
NewUserIdentity builds a user identity. idpGroups are the groups supplied by the identity provider; reserved ROR-owned names are dropped.
func (*Identity) GetAuthInfo ¶
Function returns the auth info of the identity
func (*Identity) GetClaim ¶ added in v1.25.6
GetClaim returns an additional claim captured at authentication.
func (*Identity) GetEmail ¶ added in v1.25.6
GetEmail returns the email of a user identity and fails for any other type.
func (*Identity) GetGroups ¶ added in v1.25.1
GetGroups returns the ACL groups of the identity. Every identity type resolves through the same group mechanism: user groups come from the identity provider, while cluster and service groups are ROR-owned principal names. The returned slice is a copy, so callers cannot mutate the identity.
func (*Identity) GetId ¶
Function returns the id of the identity.
User is represented by email, cluster by clusterid and service by service name
func (*Identity) GetName ¶ added in v1.25.6
GetName returns the human readable identifier: a user's display name, a cluster's cluster id or a service's id.
func (*Identity) GetSubject ¶ added in v1.25.6
GetSubject returns the identifier authorization is derived from: a user's email, a cluster's uid or a service's id.
func (Identity) ReturnGroupQuery ¶
Function returns a bson.A containing the groups of an identity. To be used in filtering in mongodb.
type IdentityProvider ¶
type IdentityProvider string
type IdentityType ¶
type IdentityType string
Type to hold the identitytype eg. user, cluster,service...