Documentation
¶
Index ¶
- Constants
- Variables
- func IsSystemGroup(id string) bool
- func IsValidUserStatus(status UserStatus) bool
- type AuthorizationCodeRequest
- type ChangeNotification
- type Group
- type GroupInsert
- type GroupList
- type GroupListRequest
- type GroupMeta
- type Identity
- type IdentityInsert
- type IdentityKey
- type IdentityList
- type IdentityListRequest
- type IdentityMeta
- type Key
- type KeyID
- type KeyMeta
- type KeySelector
- type KeyToken
- type MetaMap
- func (meta MetaMap) Map() map[string]any
- func (meta MetaMap) RedactedString() string
- func (meta *MetaMap) Scan(src any) error
- func (meta MetaMap) String() string
- func (meta *MetaMap) UnmarshalJSON(data []byte) error
- func (meta *MetaMap) UnmarshalText(text []byte) error
- func (meta MetaMap) Value() (driver.Value, error)
- type PublicClientConfiguration
- type PublicClientConfigurations
- type RefreshRequest
- type ScopeList
- type ScopeListRequest
- type Session
- type SessionID
- func (id SessionID) MarshalJSON() ([]byte, error)
- func (id SessionID) MarshalText() ([]byte, error)
- func (id SessionID) Select(bind *pg.Bind, op pg.Op) (string, error)
- func (id SessionID) String() string
- func (id *SessionID) UnmarshalJSON(data []byte) error
- func (id *SessionID) UnmarshalText(text []byte) error
- type SessionInsert
- type SessionMeta
- type TokenResponse
- type User
- type UserGroupInsert
- type UserGroupList
- type UserGroupListRequest
- type UserID
- type UserInfo
- type UserList
- type UserListRequest
- type UserMeta
- type UserStatus
Constants ¶
const ( // GroupSysAdmin is the built-in administrative group seeded at startup. // Its name follows the $name$ convention that marks server-managed groups. // Members are granted full access to the management API and CLI. GroupSysAdmin = "$admin$" // ScopeAuthUserRead grants permission to list and get users. ScopeAuthUserRead = "auth:user:read" // ScopeAuthUserWrite grants permission to create, update, and delete users. ScopeAuthUserWrite = "auth:user:write" // ScopeAuthGroupRead grants permission to list and get groups. ScopeAuthGroupRead = "auth:group:read" // ScopeAuthGroupWrite grants permission to create, update, and delete groups. ScopeAuthGroupWrite = "auth:group:write" // ScopeAuthKeyRead grants permission to list and get API keys. ScopeAuthKeyRead = "auth:key:read" // ScopeAuthKeyWrite grants permission to create, update, and delete API keys. ScopeAuthKeyWrite = "auth:key:write" )
const ( DefaultSchema = "auth" DefaultSessionTTL = time.Minute * 15 // 15 minutes DefaultRefreshTTL = time.Hour * 24 * 7 // 7 days )
const ( GroupListMax = 100 IdentityListMax = 100 ScopeListMax = 100 UserListMax = 100 )
const ( // ProviderKeyLocal is the reserved provider key for the built-in local // issuer. When this provider is not registered, the server has no local // issuer and cannot mint local session tokens from the browser login flow. ProviderKeyLocal = "local" )
const (
SecurityBearerAuth = "bearerAuth"
)
Scopes
Variables ¶
var ( // GroupSysAdminScopes is the fixed set of scopes assigned to GroupSysAdmin at startup. GroupSysAdminScopes = []string{ ScopeAuthUserRead, ScopeAuthUserWrite, ScopeAuthGroupRead, ScopeAuthGroupWrite, ScopeAuthKeyRead, ScopeAuthKeyWrite, } )
var Metrics string
var Objects string
var Queries string
Functions ¶
func IsSystemGroup ¶
IsSystemGroup reports whether id is a server-managed group. System groups are identified by the $name$ naming convention and are seeded at startup; they cannot be created, updated, or deleted via the API.
func IsValidUserStatus ¶
func IsValidUserStatus(status UserStatus) bool
IsValidUserStatus returns true when status is one of the supported values.
Types ¶
type AuthorizationCodeRequest ¶
type AuthorizationCodeRequest struct {
Provider string `` /* 140-byte string literal not displayed */
Code string `json:"code" jsonschema:"Authorization code returned by the selected provider." example:"4/0AQSTgQExampleCode"`
RedirectURI string `` /* 173-byte string literal not displayed */
CodeVerifier string `` /* 170-byte string literal not displayed */
Nonce string `json:"nonce,omitempty" jsonschema:"Optional expected nonce for ID token validation." example:"n-0S6_WzA2Mj"`
Meta MetaMap `json:"meta,omitempty" jsonschema:"Optional metadata forwarded into the local login flow after identity exchange."`
}
AuthorizationCodeRequest contains the provider key and authorization code that should be exchanged server-side for a verified identity token.
func (*AuthorizationCodeRequest) Validate ¶
func (req *AuthorizationCodeRequest) Validate() error
type ChangeNotification ¶
type ChangeNotification struct {
Schema string `json:"schema"`
Table string `json:"table"`
Action string `json:"action"`
}
ChangeNotification is emitted for table changes when database notifications are enabled on the manager.
type GroupInsert ¶
func (GroupInsert) String ¶
func (g GroupInsert) String() string
type GroupList ¶
type GroupList struct {
pg.OffsetLimit
Count uint `json:"count" readonly:""`
Body []Group `json:"body,omitempty"`
}
GroupList represents a paginated list of groups.
type GroupListRequest ¶
type GroupListRequest struct {
pg.OffsetLimit
}
GroupListRequest contains the query parameters for listing groups.
func (GroupListRequest) Query ¶
func (req GroupListRequest) Query() url.Values
func (GroupListRequest) String ¶
func (req GroupListRequest) String() string
type GroupMeta ¶
type Identity ¶
type Identity struct {
IdentityKey
IdentityMeta
User UserID `json:"user" format:"uuid" readonly:""`
CreatedAt time.Time `json:"created_at" format:"date-time" readonly:""`
ModifiedAt time.Time `json:"modified_at" format:"date-time" readonly:""`
}
Identity represents a stored identity row.
func (Identity) RedactedString ¶
type IdentityInsert ¶
type IdentityInsert struct {
IdentityKey
IdentityMeta
}
IdentityInsert contains the fields required to create a new identity.
func NewIdentityFromClaims ¶
func NewIdentityFromClaims(claims map[string]any) (IdentityInsert, error)
func (IdentityInsert) Insert ¶
func (i IdentityInsert) Insert(bind *pg.Bind) (string, error)
Insert binds the identity key and delegates the mutable fields to IdentityMeta.Insert. The owning user must already be present in the bind.
func (IdentityInsert) Name ¶
func (i IdentityInsert) Name() string
func (IdentityInsert) RedactedString ¶
func (i IdentityInsert) RedactedString() string
func (IdentityInsert) String ¶
func (i IdentityInsert) String() string
type IdentityKey ¶
IdentityKey contains the key for an identity.
func (IdentityKey) RedactedString ¶
func (key IdentityKey) RedactedString() string
func (IdentityKey) Select ¶
Select binds the identity key and returns the appropriate named query for the given operation (Get, Update or Delete).
func (IdentityKey) String ¶
func (key IdentityKey) String() string
type IdentityList ¶
type IdentityList struct {
pg.OffsetLimit
Count uint `json:"count" readonly:""`
Body []Identity `json:"body,omitempty"`
}
IdentityList represents a paginated list of identities.
func (IdentityList) String ¶
func (list IdentityList) String() string
type IdentityListRequest ¶
type IdentityListRequest struct {
pg.OffsetLimit
User *uuid.UUID `json:"user,omitempty" format:"uuid"`
}
IdentityListRequest contains the query parameters for listing identities.
func (IdentityListRequest) String ¶
func (req IdentityListRequest) String() string
type IdentityMeta ¶
IdentityMeta contains the mutable fields for an identity.
func (IdentityMeta) Insert ¶
func (i IdentityMeta) Insert(bind *pg.Bind) (string, error)
Insert binds all mutable identity fields for an INSERT and returns the named query. Immutable fields must already be present in the bind.
func (IdentityMeta) RedactedString ¶
func (meta IdentityMeta) RedactedString() string
func (IdentityMeta) String ¶
func (meta IdentityMeta) String() string
type Key ¶ added in v0.0.8
type Key struct {
ID KeyID `` /* 141-byte string literal not displayed */
User UserID `` /* 145-byte string literal not displayed */
CreatedAt time.Time `` /* 136-byte string literal not displayed */
ModifiedAt time.Time `` /* 143-byte string literal not displayed */
Status *UserStatus `` /* 254-byte string literal not displayed */
Token string `` /* 243-byte string literal not displayed */
KeyMeta
}
Key represents a stored API key row plus the generated plaintext token.
type KeyID ¶ added in v0.0.8
KeyID is a unique identifier for an API key.
func KeyIDFromString ¶ added in v0.0.8
func (KeyID) MarshalJSON ¶ added in v0.0.8
func (KeyID) MarshalText ¶ added in v0.0.8
func (*KeyID) UnmarshalJSON ¶ added in v0.0.8
func (*KeyID) UnmarshalText ¶ added in v0.0.8
type KeyMeta ¶ added in v0.0.8
type KeyMeta struct {
Name string `` /* 132-byte string literal not displayed */
ExpiresAt *time.Time `` /* 226-byte string literal not displayed */
}
KeyMeta contains the writable fields for an API key.
type KeySelector ¶ added in v0.0.8
KeySelector selects an API key row by ID and optionally scopes it to a user.
type MetaMap ¶
func (MetaMap) RedactedString ¶
func (*MetaMap) UnmarshalJSON ¶
func (*MetaMap) UnmarshalText ¶
type PublicClientConfiguration ¶
type PublicClientConfiguration struct {
Issuer string `` /* 129-byte string literal not displayed */
ClientID string `` /* 207-byte string literal not displayed */
}
PublicClientConfiguration contains the upstream provider details that are safe to expose to clients that need to initiate authentication.
type PublicClientConfigurations ¶
type PublicClientConfigurations map[string]PublicClientConfiguration
PublicClientConfigurations contains shareable client configuration keyed by provider or role name.
func (PublicClientConfigurations) String ¶
func (cfg PublicClientConfigurations) String() string
type RefreshRequest ¶
type RefreshRequest struct {
Token string `json:"token"`
}
RefreshRequest contains a previously issued local session token.
type ScopeList ¶
type ScopeList struct {
pg.OffsetLimit
Count uint `json:"count" readonly:""`
Body []string `json:"body,omitempty"`
}
type ScopeListRequest ¶
type ScopeListRequest struct {
pg.OffsetLimit
Q string `json:"q,omitempty"`
}
func (ScopeListRequest) Query ¶
func (req ScopeListRequest) Query() url.Values
func (ScopeListRequest) String ¶
func (req ScopeListRequest) String() string
type Session ¶
type Session struct {
ID SessionID `json:"id" format:"uuid" readonly:""`
User UserID `json:"user" format:"uuid" readonly:""`
ExpiresAt time.Time `json:"expires_at" format:"date-time" readonly:""`
RefreshExpiresAt time.Time `json:"refresh_expires_at" format:"date-time" readonly:""`
RefreshCounter uint64 `json:"refresh_counter" readonly:""`
CreatedAt time.Time `json:"created_at" format:"date-time" readonly:""`
SessionMeta
}
Session represents a stored session row.
type SessionID ¶
SessionID is a unique identifier for a session.
func SessionIDFromString ¶
SessionIDFromString parses a string into a SessionID, which is a UUID.
func (SessionID) MarshalJSON ¶
func (SessionID) MarshalText ¶
func (SessionID) Select ¶
Select binds the session ID and returns the appropriate named query for the given operation (Get, Update or Delete).
func (*SessionID) UnmarshalJSON ¶
func (*SessionID) UnmarshalText ¶
type SessionInsert ¶
type SessionInsert struct {
User UserID `json:"user" format:"uuid"`
ExpiresIn *time.Duration `json:"expires_in"`
RefreshExpiresIn *time.Duration `json:"refresh_expires_in,omitempty"`
}
SessionInsert contains the fields required to create a new session.
type SessionMeta ¶
type SessionMeta struct {
ExpiresIn *time.Duration `json:"expires_in,omitempty"`
RefreshExpiresIn *time.Duration `json:"refresh_expires_in,omitempty"`
RevokedAt *time.Time `json:"revoked_at,omitempty" format:"date-time" readonly:""`
}
SessionMeta contains the mutable fields for a session.
type TokenResponse ¶
type TokenResponse struct {
Token string `json:"token" readonly:""`
UserInfo *UserInfo `json:"userinfo,omitempty" readonly:""`
}
TokenResponse is returned by token-issuing auth endpoints.
type User ¶
type User struct {
ID UserID `json:"id" format:"uuid" readonly:""`
CreatedAt time.Time `json:"created_at" format:"date-time" readonly:""`
ModifiedAt *time.Time `json:"modified_at,omitempty" format:"date-time" readonly:""`
Claims map[string]any `json:"claims,omitempty" readonly:""`
EffectiveMeta MetaMap `json:"effective_meta,omitempty" readonly:""`
DisabledGroups []string `json:"disabled_groups,omitempty" readonly:""`
Scopes []string `json:"scopes,omitempty" readonly:""`
UserMeta
}
User represents a user account in the system. It contains both immutable and mutable fields.
func (User) HasAllScopes ¶
func (User) RedactedString ¶
type UserGroupInsert ¶
type UserGroupList ¶
type UserGroupList []string
type UserGroupListRequest ¶
type UserGroupListRequest struct {
User UserID
}
type UserID ¶
UserID is a unique identifier for a user account. It is generated as a UUID.
func UserIDFromString ¶
UserIDFromString parses a string into a UserID, which is a UUID.
func (UserID) MarshalJSON ¶
func (UserID) MarshalText ¶
func (UserID) Select ¶
Select binds the user ID and returns the appropriate named query for the given operation (Get, Update or Delete).
func (*UserID) UnmarshalJSON ¶
func (*UserID) UnmarshalText ¶
type UserInfo ¶
type UserInfo struct {
Sub UserID `` /* 156-byte string literal not displayed */
Email string `` /* 155-byte string literal not displayed */
Name string `` /* 126-byte string literal not displayed */
Groups []string `json:"groups,omitempty" jsonschema:"Group memberships associated with the authenticated user." readonly:""`
Scopes []string `json:"scopes,omitempty" jsonschema:"Scopes granted to the current local bearer token." readonly:""`
}
UserInfo is the client-facing authenticated identity view exposed by the auth APIs.
func NewUserInfo ¶
type UserList ¶
type UserList struct {
pg.OffsetLimit
Count uint `json:"count" readonly:""`
Body []User `json:"body,omitempty"`
}
UserList represents a paginated list of users.
type UserListRequest ¶
type UserListRequest struct {
pg.OffsetLimit
Email string `json:"email,omitempty"`
Status []UserStatus `json:"status,omitempty" enum:"new,active,inactive,suspended,deleted"`
}
UserListRequest contains the query parameters for listing users.
func (UserListRequest) Query ¶
func (req UserListRequest) Query() url.Values
func (UserListRequest) RedactedString ¶
func (u UserListRequest) RedactedString() string
func (UserListRequest) String ¶
func (u UserListRequest) String() string
type UserMeta ¶
type UserMeta struct {
Name string `json:"name,omitempty"`
Email string `json:"email,omitempty"`
Groups []string `json:"groups,omitempty"`
Status *UserStatus `json:"status,omitempty" enum:"new,active,inactive,suspended,deleted"`
Meta MetaMap `json:"meta,omitempty"`
ExpiresAt *time.Time `json:"expires_at,omitzero" format:"date-time"`
}
UserMeta contains the mutable profile fields of a user. Email is the canonical address used to merge logins across providers.
func (UserMeta) Insert ¶
Insert binds all UserMeta fields for an INSERT and returns the named query.
func (UserMeta) RedactedString ¶
type UserStatus ¶
type UserStatus string
UserStatus represents the lifecycle state of a user account.
const ( UserStatusNew UserStatus = "new" UserStatusActive UserStatus = "active" UserStatusInactive UserStatus = "inactive" UserStatusSuspended UserStatus = "suspended" UserStatusDeleted UserStatus = "deleted" )