Documentation
¶
Overview ¶
Package authsvc is the LFX MCP server's client of the LFX auth service on the platform message bus (NATS request/reply). See conn.go.
Package authsvc is the LFX MCP server's client of the LFX auth service on the platform message bus (NATS request/reply).
It serves the staff-claim-only brokered account lookups and nothing else: no tool that acts with the caller's token and no read of a platform resource goes through the bus. The package only sends requests, on two subjects, and exports only Connect, Close and the typed lookups with their result and error types. The connection, the generic request and the subject names stay inside it, so no other package of this server can reach the bus. A third subject is agreed with the repository's maintainers before it is built (ARCHITECTURE.md). It imports the NATS client and the standard library only.
Package authsvc is the LFX MCP server's client of the LFX auth service on the platform message bus (NATS request/reply). See conn.go.
This file restates the auth service's subjects, reply strings and wire types. Their owner is github.com/linuxfoundation/lfx-v2-auth-service; they were copied from its branch feat/user-account-lookup at commit 2296a8c. The copy exists because that module declares a newer Go version than this one: when lfx-mcp's Go version reaches the module's, an import of its pkg/api and pkg/constants replaces this file.
Index ¶
Constants ¶
const ( ReasonBus = "bus_error" // not sent or not answered: not connected, no responder, cancelled ReasonTimeout = "timeout" // no reply within the request's time-out or the call's budget ReasonService = "service_error" // the auth service replied with any other failure ReasonMalformed = "malformed_reply" // the reply is not what the subject documents )
Reasons a lookup could not be completed.
Variables ¶
var ErrNoAccount = errors.New("no LF account matches")
ErrNoAccount is the answer "no LF account matches": the auth service replied exactly "user not found" to the account read.
var ErrSearchRefused = errors.New("the auth service refused the search query")
ErrSearchRefused is the auth service's refusal of a search query. It is an answer about the query, not a failure of the search.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the client of the auth service on the platform message bus. Connect makes it. It logs nothing.
func Connect ¶
func Connect(address string, logger *slog.Logger, traceparent func(context.Context) string) (*Client, error)
Connect starts the process's one connection to the platform message bus and returns at once: the bus is never a start-up dependency. The connection is made in the background and retried for as long as the process runs; until it is up, and whenever it is down, every lookup fails at once. Connect returns an error only for an address that cannot be one. Neither the error nor a log line holds the address.
traceparent gives the value of the traceparent header of a request made under a context; nil sends none.
func (*Client) AccountByUsername ¶
AccountByUsername returns the LF account with exactly this LF username. It returns ErrNoAccount when there is none, and a *LookupError for every other outcome.
func (*Client) SearchAccounts ¶
func (c *Client) SearchAccounts(ctx context.Context, query string, limit int) ([]UserAccountMatch, error)
SearchAccounts returns up to limit LF accounts that the auth service matches to query: by name, by the start of an LF username or by e-mail address, as its search subject documents. The query is passed as given. An empty list means nothing matched. It returns ErrSearchRefused when the auth service refuses the query, and a *LookupError for every other outcome.
type LookupError ¶
type LookupError struct {
Subject string
Reason string
Err error // the transport's error: ReasonBus and ReasonTimeout only
}
LookupError is every outcome of a lookup other than an answer. It says nothing about whether an account exists. Its text holds the subject, the reason and, for a bus error or a time-out, the transport's own error text; it never holds the request payload or text the auth service returned.
func (*LookupError) Error ¶
func (e *LookupError) Error() string
func (*LookupError) Unwrap ¶
func (e *LookupError) Unwrap() error
type UserAccount ¶
type UserAccount struct {
Username string `json:"username,omitempty"`
Name string `json:"name,omitempty"`
Blocked *bool `json:"blocked,omitempty"`
Emails []UserAccountEmail `json:"emails"`
Logins []UserAccountLogin `json:"logins"`
}
UserAccount is one LF account as the account read returns it: UserAccount in pkg/api/user_account.go at 2296a8c.
type UserAccountEmail ¶
type UserAccountEmail struct {
Email string `json:"email"`
Primary bool `json:"primary"`
Verified bool `json:"verified"`
}
UserAccountEmail is one e-mail address of an account: UserAccountEmail in pkg/api/user_account.go at 2296a8c.
type UserAccountLogin ¶
type UserAccountLogin struct {
Provider string `json:"provider"`
Handle string `json:"handle,omitempty"`
}
UserAccountLogin is one login linked to an account: UserAccountLogin in pkg/api/user_account.go at 2296a8c.
type UserAccountMatch ¶
type UserAccountMatch struct {
Username string `json:"username"`
Name string `json:"name,omitempty"`
}
UserAccountMatch is one account a search matched: UserAccountMatch in pkg/api/user_account.go at 2296a8c.