Documentation
¶
Index ¶
- Constants
- Variables
- func PKCEChallenge(verifier string) string
- type Authenticator
- func (a *Authenticator) Accounts() *accounts.Manager
- func (a *Authenticator) AdminAccount(tokenString string, adminClient *settings.SSOClient) (string, error)
- func (a *Authenticator) Handler() http.Handler
- func (a *Authenticator) LoginHandler(rw http.ResponseWriter, req *http.Request)
- func (a *Authenticator) MCPAccessToken(token string) (*MCPAccess, error)
- func (a *Authenticator) MCPGrants(accountID string) ([]MCPGrant, error)
- func (a *Authenticator) MCPOAuthIssuer() (string, bool)
- func (a *Authenticator) PadAuthorizeURL(state, verifier string) (string, error)
- func (a *Authenticator) PadCallbackURL() string
- func (a *Authenticator) PadLoginAvailable() bool
- func (a *Authenticator) Paths() []string
- func (a *Authenticator) RedeemPadCode(code, verifier string) (*db.Account, error)
- func (a *Authenticator) RegisterHandler(rw http.ResponseWriter, req *http.Request)
- func (a *Authenticator) RevokeMCPGrant(actor accounts.Actor, accountID, grantID string) error
- func (a *Authenticator) Stop()
- func (a *Authenticator) ValidateAdminToken(tokenString string, adminClient *settings.SSOClient) (bool, error)
- func (a *Authenticator) ValidateServiceToken(token string) bool
- type Client
- func (c *Client) AccessTokenType() op.AccessTokenType
- func (c *Client) ApplicationType() op.ApplicationType
- func (c *Client) AuthMethod() oidc.AuthMethod
- func (c *Client) ClockSkew() time.Duration
- func (c *Client) DevMode() bool
- func (c *Client) GetID() string
- func (c *Client) GrantTypes() []oidc.GrantType
- func (c *Client) IDTokenLifetime() time.Duration
- func (c *Client) IDTokenUserinfoClaimsAssertion() bool
- func (c *Client) IsScopeAllowed(scope string) bool
- func (c *Client) LoginURL(authRequestID string) string
- func (c *Client) PostLogoutRedirectURIs() []string
- func (c *Client) RedirectURIs() []string
- func (c *Client) ResponseTypes() []oidc.ResponseType
- func (c *Client) RestrictAdditionalAccessTokenScopes() func(scopes []string) []string
- func (c *Client) RestrictAdditionalIdTokenScopes() func(scopes []string) []string
- type MCPAccess
- type MCPGrant
- type Storage
- func (s *Storage) AuthRequestByCode(_ context.Context, code string) (op.AuthRequest, error)
- func (s *Storage) AuthRequestByID(_ context.Context, id string) (op.AuthRequest, error)
- func (s *Storage) AuthorizeClientIDSecret(_ context.Context, clientID, clientSecret string) error
- func (s *Storage) ClientCredentials(_ context.Context, clientID, clientSecret string) (op.Client, error)
- func (s *Storage) ClientCredentialsTokenRequest(_ context.Context, clientID string, scopes []string) (op.TokenRequest, error)
- func (s *Storage) CreateAccessAndRefreshTokens(_ context.Context, req op.TokenRequest, currentRefreshToken string) (string, string, time.Time, error)
- func (s *Storage) CreateAccessToken(_ context.Context, req op.TokenRequest) (string, time.Time, error)
- func (s *Storage) CreateAuthRequest(_ context.Context, req *oidc.AuthRequest, userID string) (op.AuthRequest, error)
- func (s *Storage) DeleteAuthRequest(_ context.Context, id string) error
- func (s *Storage) GetClientByClientID(_ context.Context, clientID string) (op.Client, error)
- func (s *Storage) GetKeyByIDAndClientID(context.Context, string, string) (*jose.JSONWebKey, error)
- func (s *Storage) GetPrivateClaimsFromScopes(context.Context, string, string, []string) (map[string]any, error)
- func (s *Storage) GetRefreshTokenInfo(_ context.Context, clientID string, token string) (string, string, error)
- func (s *Storage) Health(context.Context) error
- func (s *Storage) KeySet(context.Context) ([]op.Key, error)
- func (s *Storage) RevokeToken(_ context.Context, tokenOrID string, _ string, clientID string) *oidc.Error
- func (s *Storage) SaveAuthCode(_ context.Context, id string, code string) error
- func (s *Storage) SetIntrospectionFromToken(_ context.Context, resp *oidc.IntrospectionResponse, tokenID, _, _ string) error
- func (s *Storage) SetUserinfoFromScopes(_ context.Context, info *oidc.UserInfo, userID, _ string, scopes []string) error
- func (s *Storage) SetUserinfoFromToken(_ context.Context, info *oidc.UserInfo, tokenID, _, _ string) error
- func (s *Storage) SignatureAlgorithms(context.Context) ([]jose.SignatureAlgorithm, error)
- func (s *Storage) SigningKey(context.Context) (op.SigningKey, error)
- func (s *Storage) TerminateSession(context.Context, string, string) error
- func (s *Storage) TokenRequestByRefreshToken(_ context.Context, token string) (op.RefreshTokenRequest, error)
- func (s *Storage) ValidateJWTProfileScopes(context.Context, string, []string) ([]string, error)
Constants ¶
const ( // ClientIPHeader carries the client's address, as fiber sees it behind // trusted proxies, to the registration (overwritten, never taken from // the request). ClientIPHeader = "X-Etherpad-Oidc-Client-Ip" )
const PadCallbackPath = "/auth/callback"
PadCallbackPath is where the pads' login comes back to with a code.
Variables ¶
var ErrGrantNotFound = errors.New("no such app")
ErrGrantNotFound: the person has no such consent.
var ErrLoginFailed = errors.New("the login could not be completed")
ErrLoginFailed is any failure to redeem a pad login code; the reason is not told to the browser.
var ErrNotMCPToken = errors.New("not an MCP access token")
ErrNotMCPToken: the token is no access token of an MCP client.
var MCPScopes = []string{accounts.ScopePadRead, accounts.ScopePadWrite, accounts.ScopePadCreate, accounts.ScopeChatWrite}
MCPScopes are the scopes an MCP client may ask for and a person may allow: what the MCP server's tools need.
Functions ¶
func PKCEChallenge ¶ added in v0.7.0
PKCEChallenge is the S256 code challenge of a verifier.
Types ¶
type Authenticator ¶
type Authenticator struct {
// contains filtered or unexported fields
}
Authenticator is Etherpad's OpenID Connect provider, built on github.com/zitadel/oidc. Users log in on Etherpad's own login page with their accounts (lib/accounts).
func Init ¶
func Init(store *lib.InitStore) *Authenticator
Init sets up the OpenID Connect provider and mounts its endpoints.
func NewAuthenticator ¶
func NewAuthenticator(retrievedSettings *settings.Settings, persistence db.DataStore) *Authenticator
func (*Authenticator) Accounts ¶ added in v0.7.0
func (a *Authenticator) Accounts() *accounts.Manager
Accounts returns the account manager the provider logs in with.
func (*Authenticator) AdminAccount ¶ added in v0.7.0
func (a *Authenticator) AdminAccount(tokenString string, adminClient *settings.SSOClient) (string, error)
AdminAccount checks an admin token like ValidateAdminToken and returns the id of the account it was issued to.
func (*Authenticator) Handler ¶ added in v0.7.0
func (a *Authenticator) Handler() http.Handler
Handler serves the OpenID Connect endpoints.
func (*Authenticator) LoginHandler ¶ added in v0.7.0
func (a *Authenticator) LoginHandler(rw http.ResponseWriter, req *http.Request)
LoginHandler is the login page the provider redirects auth requests to. GET shows the form, POST checks the credentials and hands the auth request back to the provider, which redirects to the client with a code.
func (*Authenticator) MCPAccessToken ¶ added in v0.7.0
func (a *Authenticator) MCPAccessToken(token string) (*MCPAccess, error)
MCPAccessToken checks an access token for /mcp: issued to an MCP client, unexpired, for a person who is still active, under a grant that still exists. The rights are the person's of the moment, cut down to it.
func (*Authenticator) MCPGrants ¶ added in v0.7.0
func (a *Authenticator) MCPGrants(accountID string) ([]MCPGrant, error)
MCPGrants are the MCP clients a person allowed, newest first.
func (*Authenticator) MCPOAuthIssuer ¶ added in v0.7.0
func (a *Authenticator) MCPOAuthIssuer() (string, bool)
MCPOAuthIssuer is the issuer MCP clients get their tokens from, and whether they may.
func (*Authenticator) PadAuthorizeURL ¶ added in v0.7.0
func (a *Authenticator) PadAuthorizeURL(state, verifier string) (string, error)
PadAuthorizeURL is the provider's authorization URL for a pad login with the given state and PKCE verifier.
func (*Authenticator) PadCallbackURL ¶ added in v0.7.0
func (a *Authenticator) PadCallbackURL() string
PadCallbackURL is the redirect URI of the pads' login. It is allowed for the user client without being listed in its redirect_uris: it is this server's own page, on the issuer's origin.
func (*Authenticator) PadLoginAvailable ¶ added in v0.7.0
func (a *Authenticator) PadLoginAvailable() bool
PadLoginAvailable reports whether the pads can log in: a client of type "user" that may use the authorization code grant is configured.
func (*Authenticator) Paths ¶ added in v0.7.0
func (a *Authenticator) Paths() []string
Paths lists every path Handler serves.
func (*Authenticator) RedeemPadCode ¶ added in v0.7.0
func (a *Authenticator) RedeemPadCode(code, verifier string) (*db.Account, error)
RedeemPadCode exchanges the code of a pad login for the account that logged in, without the token endpoint: the server is its own client, so it checks the code where it is stored. The code must belong to the user client and the pads' callback, match the PKCE verifier, and belong to a finished login of an active person. It works only once.
func (*Authenticator) RegisterHandler ¶ added in v0.7.0
func (a *Authenticator) RegisterHandler(rw http.ResponseWriter, req *http.Request)
RegisterHandler answers dynamic client registration (RFC 7591) for MCP clients.
func (*Authenticator) RevokeMCPGrant ¶ added in v0.7.0
func (a *Authenticator) RevokeMCPGrant(actor accounts.Actor, accountID, grantID string) error
RevokeMCPGrant ends a person's consent: the client's tokens stop at once. actor is who ends it (the person, or an admin).
func (*Authenticator) Stop ¶ added in v0.6.5
func (a *Authenticator) Stop()
Stop is kept for the server's shutdown sequence; nothing runs in the background anymore.
func (*Authenticator) ValidateAdminToken ¶
func (a *Authenticator) ValidateAdminToken(tokenString string, adminClient *settings.SSOClient) (bool, error)
ValidateAdminToken checks an ID token issued by this provider for the admin client and reports whether it belongs to an admin.
func (*Authenticator) ValidateServiceToken ¶ added in v0.7.0
func (a *Authenticator) ValidateServiceToken(token string) bool
ValidateServiceToken reports whether token is an access token a configured client got with the client_credentials grant. etherpad-lite accepts such tokens for its HTTP API (/api); /admin/api takes admin tokens only. A token issued to a user is never one, even when the user is named like a client.
type Client ¶ added in v0.7.0
type Client struct {
// contains filtered or unexported fields
}
Client is an SSO client from the settings.
func (*Client) AccessTokenType ¶ added in v0.7.0
func (c *Client) AccessTokenType() op.AccessTokenType
func (*Client) ApplicationType ¶ added in v0.7.0
func (c *Client) ApplicationType() op.ApplicationType
func (*Client) AuthMethod ¶ added in v0.7.0
func (c *Client) AuthMethod() oidc.AuthMethod
func (*Client) GrantTypes ¶ added in v0.7.0
func (*Client) IDTokenLifetime ¶ added in v0.7.0
func (*Client) IDTokenUserinfoClaimsAssertion ¶ added in v0.7.0
IDTokenUserinfoClaimsAssertion puts the userinfo claims into the ID token, which the admin UI uses as its bearer token.
func (*Client) IsScopeAllowed ¶ added in v0.7.0
IsScopeAllowed is asked for scopes beyond the standard OIDC ones: MCP clients ask for the MCP server's.
func (*Client) PostLogoutRedirectURIs ¶ added in v0.7.0
func (*Client) RedirectURIs ¶ added in v0.7.0
func (*Client) ResponseTypes ¶ added in v0.7.0
func (c *Client) ResponseTypes() []oidc.ResponseType
func (*Client) RestrictAdditionalAccessTokenScopes ¶ added in v0.7.0
func (*Client) RestrictAdditionalIdTokenScopes ¶ added in v0.7.0
type MCPAccess ¶ added in v0.7.0
type MCPAccess struct {
Account *db.Account
ClientID string
Scopes []string
PadPattern string
ExpiresAt time.Time
}
MCPAccess is what an OAuth access token allows at /mcp.
type MCPGrant ¶ added in v0.7.0
type MCPGrant struct {
ID string `json:"id"`
ClientID string `json:"clientId"`
ClientName string `json:"clientName"`
Scopes []string `json:"scopes"`
PadPattern string `json:"padPattern"`
CreatedAt time.Time `json:"createdAt"`
}
MCPGrant is a person's consent for an MCP client.
type Storage ¶ added in v0.7.0
type Storage struct {
// contains filtered or unexported fields
}
Storage implements op.Storage for zitadel/oidc. Auth requests, codes and tokens live in the datastore's oauth_* tables, so several Etherpad instances on one database share them. Each row carries its state as JSON in session_data; the other columns are only keys.
func (*Storage) AuthRequestByCode ¶ added in v0.7.0
func (*Storage) AuthRequestByID ¶ added in v0.7.0
func (*Storage) AuthorizeClientIDSecret ¶ added in v0.7.0
func (*Storage) ClientCredentials ¶ added in v0.7.0
func (*Storage) ClientCredentialsTokenRequest ¶ added in v0.7.0
func (*Storage) CreateAccessAndRefreshTokens ¶ added in v0.7.0
func (*Storage) CreateAccessToken ¶ added in v0.7.0
func (*Storage) CreateAuthRequest ¶ added in v0.7.0
func (s *Storage) CreateAuthRequest(_ context.Context, req *oidc.AuthRequest, userID string) (op.AuthRequest, error)
func (*Storage) DeleteAuthRequest ¶ added in v0.7.0
func (*Storage) GetClientByClientID ¶ added in v0.7.0
func (*Storage) GetKeyByIDAndClientID ¶ added in v0.7.0
The JWT profile grant and private_key_jwt client authentication are disabled, so these are never asked for a key.
func (*Storage) GetPrivateClaimsFromScopes ¶ added in v0.7.0
func (s *Storage) GetPrivateClaimsFromScopes(context.Context, string, string, []string) (map[string]any, error)
GetPrivateClaimsFromScopes is only used for JWT access tokens, which Etherpad does not issue.
func (*Storage) GetRefreshTokenInfo ¶ added in v0.7.0
func (*Storage) RevokeToken ¶ added in v0.7.0
func (*Storage) SaveAuthCode ¶ added in v0.7.0
func (*Storage) SetIntrospectionFromToken ¶ added in v0.7.0
func (*Storage) SetUserinfoFromScopes ¶ added in v0.7.0
func (*Storage) SetUserinfoFromToken ¶ added in v0.7.0
func (*Storage) SignatureAlgorithms ¶ added in v0.7.0
func (*Storage) SigningKey ¶ added in v0.7.0
func (*Storage) TerminateSession ¶ added in v0.7.0
TerminateSession is called by the end_session endpoint. The tables have no index by user, so the tokens simply expire.