Documentation
¶
Overview ¶
Package padlogin is the optional login on pads: a person logs in on Etherpad's own OpenID Connect provider and keeps a session cookie; who does not log in has the visitors' rights (lib/accounts).
Index ¶
Constants ¶
const ( LoginPath = "/auth/login" LogoutPath = "/auth/logout" MePath = "/auth/me" )
const TokensPath = "/auth/tokens"
TokensPath is where people logged in on the pads manage their own tokens ("My tokens" in the profile menu); it needs tokens:own.
Variables ¶
This section is empty.
Functions ¶
func CookieName ¶
CookieName is the name of the login session cookie.
func SafeRedirect ¶
SafeRedirect keeps a redirect target on this server: a path, never a URL to another site ("//evil", "/\evil", "https://…"). Anything else is "/".
Types ¶
type Login ¶
type Login struct {
// contains filtered or unexported fields
}
Login is the pads' login.
func New ¶
func New(store db.DataStore, authn *oidc.Authenticator, cfg *settings.Settings, logger *zap.SugaredLogger) *Login
New sets up the login on store; authn may be nil when no OpenID Connect provider runs, then nobody logs in on the pads.
func (*Login) Middleware ¶
Middleware makes the person of a login session the request's user, so the access checks (lib/pad) give it its roles. A session of an account that is gone or disabled counts for nothing. A request that already has a user (e.g. set by a plugin) keeps it.
func (*Login) OnLogout ¶
OnLogout sets what runs when a session logs out, e.g. closing the pad connections opened with it.
func (*Login) SetAuthenticator ¶
func (l *Login) SetAuthenticator(a *oidc.Authenticator)
SetAuthenticator sets the provider people log in on; it is made after the routes are mounted.
type Me ¶
type Me struct {
LoginAvailable bool `json:"loginAvailable"`
LoggedIn bool `json:"loggedIn"`
Username string `json:"username,omitempty"`
DisplayName string `json:"displayName,omitempty"`
Admin bool `json:"admin,omitempty"`
// Tokens: may manage own tokens (tokens:own), "My tokens" in the menu.
Tokens bool `json:"tokens,omitempty"`
}
Me is what the pad's profile menu shows.
type OwnApp ¶
type OwnApp struct {
ID string `json:"id"`
Name string `json:"name"`
Scopes []string `json:"scopes"`
Pads string `json:"pads"`
CreatedAt int64 `json:"createdAt"`
}
OwnApp is an MCP client a person allowed (their consent, a grant).
type OwnScope ¶
type OwnScope struct {
Name string `json:"name"`
Description string `json:"description"`
PadScoped bool `json:"padScoped"`
}
OwnScope is a scope the person has, which a token of theirs may get.
type OwnToken ¶
type OwnToken struct {
ID string `json:"id"`
Name string `json:"name"`
Prefix string `json:"prefix"`
Scopes []string `json:"scopes"`
Pads string `json:"pads"`
ExpiresAt *int64 `json:"expiresAt"`
CreatedAt int64 `json:"createdAt"`
LastUsedAt *int64 `json:"lastUsedAt"`
LastUsedIP string `json:"lastUsedIp,omitempty"`
// Status: active, grace (replaced, still working until it expires).
Status string `json:"status"`
}
OwnToken is a token as its owner sees it: never its key or hash.
type OwnTokens ¶
type OwnTokens struct {
Tokens []OwnToken `json:"tokens"`
Scopes []OwnScope `json:"scopes"`
RequireExpiry bool `json:"requireExpiry"`
MaxLifetimeDays int `json:"maxLifetimeDays"`
Key string `json:"key,omitempty"`
KeyName string `json:"keyName,omitempty"`
// KeyID is the token of Key: the dialog hides the key once it is gone.
KeyID string `json:"keyId,omitempty"`
// Reload: the change was made, but the list could not be read; the key
// is still here, the dialog reads the list again.
Reload bool `json:"reload,omitempty"`
// Apps are the AI clients the person allowed with OAuth (MCP).
Apps []OwnApp `json:"apps"`
}
OwnTokens answers every request of "My tokens": the live tokens, what a new one may get, the expiry rules; Key is a new key, shown once.