Documentation
¶
Overview ¶
Package server is `rig serve`: the Engine API over HTTPS for remote CLIs, MCP clients and the web inbox, with accounts, server-side policy, reauth, approvals, leases and one audit log per environment. Requests carry a bearer token; streams are newline-delimited JSON.
Index ¶
- Constants
- Variables
- func Call(w http.ResponseWriter, r *http.Request, e api.Engine, subj identity.Subject, ...)
- func Certificate(certFile, keyFile, dir string, hosts []string) (tls.Certificate, string, error)
- func Fingerprint(der []byte) string
- func NewTOTP() string
- func TOTPCode(secret string, t time.Time) string
- func TOTPURL(issuer, user, secret string) string
- func WithDefaults(c *policy.Config) *policy.Config
- type OIDC
- type Server
- type Store
- func (s *Store) Check(name, password, code string) bool
- func (s *Store) Issue(user, name string, ttl time.Duration, session bool) (string, Token, error)
- func (s *Store) Login(name, password, code string) (User, error)
- func (s *Store) PutUser(name string, u User, password string) error
- func (s *Store) RemoveUser(name string) error
- func (s *Store) Revoke(user, id string) error
- func (s *Store) Token(secret string) (Token, bool)
- func (s *Store) Tokens(user string) []Token
- func (s *Store) User(name string) (User, bool)
- func (s *Store) Users() map[string]User
- type Token
- type User
Constants ¶
const CodeFailed = -32010
CodeFailed carries engine.ErrFailed (a failed check) across the wire.
Variables ¶
var ErrAuth = errors.New("wrong user, password or code")
Functions ¶
func Call ¶ added in v0.30.0
func Call(w http.ResponseWriter, r *http.Request, e api.Engine, subj identity.Subject, reauthed func() bool)
Call answers the Engine call r names (POST .../{method}) on e for subj. reauthed settles a policy reauth; nil asks it as a confirm, for a local client.
func Certificate ¶
Certificate loads certFile and keyFile, or, when both are empty, a self-signed certificate kept in dir (made on first run for hosts). Clients pin a self-signed certificate by its fingerprint.
func Fingerprint ¶
Types ¶
type OIDC ¶
type OIDC struct {
Issuer string `yaml:"issuer" json:"issuer"`
ClientID string `yaml:"client_id" json:"client_id"`
ClientSecret string `yaml:"client_secret" json:"client_secret"`
// RedirectURL is this server's /v1/oidc/callback as the provider reaches it.
RedirectURL string `yaml:"redirect_url" json:"redirect_url"`
// UserClaim names the account (default preferred_username, then email).
UserClaim string `yaml:"user_claim" json:"user_claim"`
GroupsClaim string `yaml:"groups_claim" json:"groups_claim"`
Roles []string `yaml:"roles" json:"roles"`
// contains filtered or unexported fields
}
OIDC signs people in through an identity provider (Keycloak, GitLab, Google, Okta) with the authorization code flow and PKCE. The CLI opens /v1/oidc/start?state=S in a browser and polls /v1/oidc/poll for the session token the callback leaves under S.
type Server ¶
type Server struct {
// File is the project's rig.yaml.
File string
Store *Store
OIDC *OIDC
// Open opens the project on an environment; engine.Open when nil.
Open func(file, env string) (*engine.App, error)
// ReauthWindow is how long a reauth lasts (default 5m).
ReauthWindow time.Duration
// RatePerSecond caps each caller's requests (default 50).
RatePerSecond int
// contains filtered or unexported fields
}
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store keeps accounts and tokens in one 0600 JSON file; tokens are kept as their SHA-256.