Documentation
¶
Overview ¶
Package identity carries the caller's authenticated identity on a request's context, from the authentication middleware that resolves it to the handlers that act on it.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Identity ¶
type Identity struct {
ID string
Username string
TenantID string
DeviceUID string
APIKey string
APIKeyID string
Role authorizer.Role
Admin bool
AdminID string
}
Identity is the caller's authenticated identity, as resolved from the request's credential.
func FromContext ¶
FromContext returns the identity NewContext stored on ctx, and false when the request is anonymous or never went through authentication.
func (*Identity) WithoutUserScope ¶
WithoutUserScope returns the identity stripped of the acting user's ID and namespace scope, keeping the admin flag. An administrator's ID moves to AdminID, so an admin route can still tell who acted without the ID the guards key on.
The /admin/api surface depends on this shape: the authorization middleware treats a missing ID alongside Admin as "this call came from the admin panel rather than from a namespace member", and lets it past the tenant guard. An admin hitting the regular /api surface keeps their user scope and stays subject to that guard.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package identitytest stands in for the authentication middleware in tests that drive a router built without it.
|
Package identitytest stands in for the authentication middleware in tests that drive a router built without it. |