Help us shape the future of Go! Take the 2026 Go Developer Survey

identitymodels

package
v1.25.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 23, 2026 License: Apache-2.0 Imports: 7 Imported by: 5

Documentation

Overview

Package implements models representing identity

Index

Constants

View Source
const (
	IdentityTypeUser    IdentityType = "User"
	IdentityTypeCluster IdentityType = "Cluster"
	IdentityTypeService IdentityType = "Service"

	IdentityProviderOidc   IdentityProvider = "OIDC"
	IdentityProviderApiKey IdentityProvider = "APIKEY"
)

Variables

View Source
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

func NewClusterIdentity(auth AuthInfo, clusterID, uid string) (Identity, error)

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

func NewServiceIdentity(auth AuthInfo, id string) (Identity, error)

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

func (identity *Identity) GetAuthInfo() AuthInfo

Function returns the auth info of the identity

func (*Identity) GetClaim added in v1.25.6

func (identity *Identity) GetClaim(name string) (string, bool)

GetClaim returns an additional claim captured at authentication.

func (*Identity) GetEmail added in v1.25.6

func (identity *Identity) GetEmail() (string, error)

GetEmail returns the email of a user identity and fails for any other type.

func (*Identity) GetGroups added in v1.25.1

func (identity *Identity) GetGroups() ([]string, error)

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

func (identity *Identity) GetId() string

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

func (identity *Identity) GetName() (string, error)

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

func (identity *Identity) GetSubject() (string, error)

GetSubject returns the identifier authorization is derived from: a user's email, a cluster's uid or a service's id.

func (*Identity) GetToken added in v1.9.1

func (identity *Identity) GetToken() string

func (*Identity) IsCluster

func (identity *Identity) IsCluster() bool

Function returns true if identity is a cluster

func (*Identity) IsService

func (identity *Identity) IsService() bool

Function returns true if identity is a service

func (*Identity) IsUser

func (identity *Identity) IsUser() bool

Function returns true if identity is an user

func (Identity) ReturnGroupQuery

func (identity Identity) ReturnGroupQuery() (bson.A, error)

Function returns a bson.A containing the groups of an identity. To be used in filtering in mongodb.

func (*Identity) SetToken added in v1.9.1

func (identity *Identity) SetToken(token string)

func (*Identity) Validate added in v1.25.6

func (identity *Identity) Validate() error

Validate reports whether the identity is complete enough to act on.

type IdentityProvider

type IdentityProvider string

type IdentityType

type IdentityType string

Type to hold the identitytype eg. user, cluster,service...

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL