Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Authorizer ¶
type Authorizer struct {
// contains filtered or unexported fields
}
Authorizer is the admission authorizer of the operator's phone: per new identity — the boundary, the claim, and the presented keys' fingerprints keyed together — it prompts the configured chat over the Bot API with the facts and an approve and a deny button, and answers on the long-polled callbacks, one prompt per identity inside a decision window — a decided prompt rewritten to its verdict with its buttons gone. The auth key reverses the flow: the operator asks the bot for a key in the configured chat, hands it to the headless client, and a registration presenting a key the plugin minted and has not spent approves on the plugin's own records and spends it; a spent or unknown key is a bare joiner's, prompted as ever — a stale auth key fails toward the human, not closed. It speaks the API directly over net/http — no SDK, for a vendored tree prices every dependency, and the handful of calls this needs are plain HTTPS and JSON. The prompts' decisions live in memory: a restart forgets pending and denied entries and a join still in flight asks again, while the unspent auth keys persist in the state directory.
func New ¶
func New(cfg Config) (*Authorizer, error)
New builds the authorizer; Run launches its poll loop. Unspent auth keys load from the state directory when its file exists.
func (*Authorizer) Authorize ¶
func (t *Authorizer) Authorize( ctx context.Context, f enrollauth.AdmissionFacts, ) enrollauth.AdmissionAnswer
Authorize answers one admission exchange. A registration presenting a credential the plugin minted and has not spent approves and spends it. A standing decision returns for its window's remainder, and the first ask — or the first past the window — sends the chat one prompt and pends. A prompt that cannot be sent denies: with the API unreachable admission fails closed, safe, but unavailable until it returns.
func (*Authorizer) Run ¶
func (t *Authorizer) Run(ctx context.Context)
Run receives the operator's chat until the context is canceled: it offers the console's commands once, then one getUpdates long poll after another, under the caller's supervision, each pass sweeping the decisions whose window has passed and answering the buttons pressed and the messages sent.
type Config ¶
type Config struct {
// API is the Bot API's base URL; empty is the public one.
API string
// Chat is the chat the prompts go to and the only one whose answers
// count — and the only one the operator can mint or retire auth keys
// from.
Chat int64
// Token is the bot's token. It rides the run argument and so the
// process list — an accepted consequence of argument-driven
// configuration, the file indirection deliberately not built.
Token string
// State is the core's state directory: the unspent auth keys'
// persistent home, so an auth key survives a restart while the
// transient asks stay in memory.
State string
// Window overrides how long one prompt's verdict stands; zero uses the
// default.
Window time.Duration
}
Config configures the Telegram authorizer.