padlogin

package
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 21, 2026 License: Apache-2.0 Imports: 23 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
const (
	LoginPath  = "/auth/login"
	LogoutPath = "/auth/logout"
	MePath     = "/auth/me"
)
View Source
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

func CookieName(s *settings.Settings) string

CookieName is the name of the login session cookie.

func LoginURL

func LoginURL(redirect string) string

LoginURL is the page that logs in and comes back to redirect.

func SafeRedirect

func SafeRedirect(target string) string

SafeRedirect keeps a redirect target on this server: a path, never a URL to another site ("//evil", "/\evil", "https://…"). Anything else is "/".

func UserOf

UserOf is the request user of a logged-in person.

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) Available

func (l *Login) Available() bool

Available reports whether people can log in on the pads.

func (*Login) Middleware

func (l *Login) Middleware() fiber.Handler

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

func (l *Login) OnLogout(fn func(sessionID string))

OnLogout sets what runs when a session logs out, e.g. closing the pad connections opened with it.

func (*Login) Register

func (l *Login) Register(app fiber.Router)

Register mounts the login's pages.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL