Documentation
¶
Overview ¶
Package authsvc is the LFX MCP server's client of the platform message bus (NATS request/reply). See conn.go.
Package authsvc is the LFX MCP server's client of the platform message bus (NATS request/reply), for the LFX auth service's two subjects and the v1 sync helper's one.
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 three 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 fourth 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 platform message bus (NATS request/reply). See conn.go.
This file holds everything of the v1 sync helper's subject: the lookup of the e-mail address a person chose for meeting invitations, which is stored in LFX v1. It is an interim: the subject, MeetingInviteEmail and what get_lf_account shows of it are removed when the preference has a v2 store (linuxfoundation/lfx-self-serve-ops#2128).
Package authsvc is the LFX MCP server's client of the platform message bus (NATS request/reply). See conn.go.
This file restates the auth service's two subjects, reply strings and wire types. Their owner is github.com/linuxfoundation/lfx-v2-auth-service; they were copied from its release v0.5.26. 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. The package's third subject, the v1 sync helper's, is in synchelper.go.
Index ¶
- Constants
- Variables
- type Client
- func (c *Client) AccountByUsername(ctx context.Context, username string) (UserAccount, error)
- func (c *Client) Close()
- func (c *Client) MeetingInviteEmail(ctx context.Context, username string) (string, error)
- func (c *Client) SearchAccounts(ctx context.Context, query string, limit int) ([]UserAccountMatch, error)
- type LookupError
- type UserAccount
- type UserAccountEmail
- type UserAccountLogin
- type UserAccountMatch
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 service replied with any other failure ReasonMalformed = "malformed_reply" // the reply is not what the subject documents ReasonAmbiguous = "ambiguous_user" // the v1 sync helper replied that more than one v1 user has the username )
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 ErrNoV1User = errors.New("no v1 user has this LF username")
ErrNoV1User is the answer "no live LFX v1 user has this LF username": the v1 sync helper replied exactly "error: user_not_found".
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 and of the v1 sync helper 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) MeetingInviteEmail ¶ added in v0.22.1
MeetingInviteEmail returns the e-mail address the person with this LF username chose for meeting invitations, as LFX v1 stores it, and "" when a v1 user has the username and no such preference. It returns ErrNoV1User when no live v1 user has the username, and a *LookupError for every other outcome. It makes one request, whose payload is the username as plain text, and never retries. No token is sent: the caller authorizes.
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 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"`
Organization string `json:"organization,omitempty"`
JobTitle string `json:"job_title,omitempty"`
Country string `json:"country,omitempty"`
Blocked *bool `json:"blocked,omitempty"`
SignInBlocked *bool `json:"sign_in_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, with its fields in the owner's order. Username, Name, Blocked, Emails and Logins are restated at v0.5.26. Organization, JobTitle and Country are restated at v0.6.0 (linuxfoundation/lfx-v2-auth-service#128). SignInBlocked is restated from linuxfoundation/lfx-v2-auth-service#129, which no release holds yet, and is to be named here by its release when it exists.
Organization, JobTitle and Country are the account's profile values as the person entered them: not verified, and Country in no standard form. SignInBlocked says whether sign-in is blocked after failed attempts, from at least one address. It is nil when the service does not know, and nil never means false. It is not an administrator's block, which is Blocked.
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 v0.5.26.
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 v0.5.26.
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 v0.5.26.