Documentation
¶
Overview ¶
Package auth provides an identity which is shared by the authn and authz packages.
Index ¶
- Variables
- func AddSystemEmail(email string)
- type Identity
- func FromContext(ctx context.Context) (*Identity, error)
- func FromIncomingMetadata(ctx context.Context) (*Identity, error)
- func FromJWT(jwt string) (*Identity, error)
- func MustFromContext(ctx context.Context) *Identity
- func MustFromIncomingMetadata(ctx context.Context) *Identity
- func MustFromJWT(jwt string) *Identity
- func MustUnmarshal(data []byte) *Identity
- func Unmarshal(data []byte) (*Identity, error)
- type Seat
- type Seats
- type Type
Constants ¶
This section is empty.
Variables ¶
var SystemIdentity = &Identity{ Type: System, ID: "system", }
Functions ¶
func AddSystemEmail ¶
func AddSystemEmail(email string)
Types ¶
type Identity ¶
type Identity struct {
Type Type // Type of the identity
ID string `json:"sub"` // E.g. "1934872948" or "alis-build@my-project.iam.gserviceaccount.com"
Email string `json:"email"` // E.g. "john@example.com" or "alis-build@myproject.iam.gserviceaccount.com"
Accounts map[string]*Seats `json:"accounts"` // User's seats in their accounts
GroupIDs []string `json:"groups"` // IDs of the groups the user belongs to
Policy string `json:"policy"` // Base64 encoded iam policy
Exp int64 `json:"exp"` // Expiration time in seconds since epoch. Only used for validating tokens.
App string `json:"app"` // Client ID (if any) of the registered third party app.
Scopes []string `json:"scopes"` // Set of scopes that the third party app has been granted.
}
func FromContext ¶
FromContext returns the Identity inside the given ctx, if any.
func FromIncomingMetadata ¶
FromIncomingMetadata returns the Identity inside the given gRPC context, if any.
func MustFromContext ¶
MustFromContext does the same as FromContext, but panics on an error.
func MustFromIncomingMetadata ¶
MustFromIncomingMetadata does the same as FromIncomingMetadata, but panics on an error.
func MustFromJWT ¶
MustFromJWT does the same as FromJWT, but panics on an error.
func MustUnmarshal ¶
MustUnmarshal does the same as Unmarshal, but panics on an error.
func (*Identity) Context ¶
Context returns a derived context with the identity value in it to use locally. Use OutgoingMetadata if you want remote services to identify the requester. You can use Context and OutgoingMetadata together.
func (*Identity) OutgoingMetadata ¶
OutgoingMetadata returns a derived context with the identity value in it. Enables downstream gRPC services in the same environment to identify the requester.
func (*Identity) PolicyMember ¶
PolicyMember returns the member to use in iam policy bindings. E.g. "user:1234129384" or "serviceAccount:alis-build@myproject.iam.gserviceaccount.com"
Directories
¶
| Path | Synopsis |
|---|---|
|
Package authn is used to identify requesters
|
Package authn is used to identify requesters |
|
Package authz is used to authorize whether an identity has the required role.
|
Package authz is used to authorize whether an identity has the required role. |
|
Package policypool provides a Pooler which can fetch policies async.
|
Package policypool provides a Pooler which can fetch policies async. |