oidc

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: 40 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

Index

Constants

View Source
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"
)
View Source
const PadCallbackPath = "/auth/callback"

PadCallbackPath is where the pads' login comes back to with a code.

Variables

View Source
var ErrGrantNotFound = errors.New("no such app")

ErrGrantNotFound: the person has no such consent.

View Source
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.

View Source
var ErrNotMCPToken = errors.New("not an MCP access token")

ErrNotMCPToken: the token is no access token of an MCP client.

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

func PKCEChallenge(verifier string) string

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) ClockSkew added in v0.7.0

func (c *Client) ClockSkew() time.Duration

func (*Client) DevMode added in v0.7.0

func (c *Client) DevMode() bool

func (*Client) GetID added in v0.7.0

func (c *Client) GetID() string

func (*Client) GrantTypes added in v0.7.0

func (c *Client) GrantTypes() []oidc.GrantType

func (*Client) IDTokenLifetime added in v0.7.0

func (c *Client) IDTokenLifetime() time.Duration

func (*Client) IDTokenUserinfoClaimsAssertion added in v0.7.0

func (c *Client) IDTokenUserinfoClaimsAssertion() bool

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

func (c *Client) IsScopeAllowed(scope string) bool

IsScopeAllowed is asked for scopes beyond the standard OIDC ones: MCP clients ask for the MCP server's.

func (*Client) LoginURL added in v0.7.0

func (c *Client) LoginURL(authRequestID string) string

func (*Client) PostLogoutRedirectURIs added in v0.7.0

func (c *Client) PostLogoutRedirectURIs() []string

func (*Client) RedirectURIs added in v0.7.0

func (c *Client) RedirectURIs() []string

func (*Client) ResponseTypes added in v0.7.0

func (c *Client) ResponseTypes() []oidc.ResponseType

func (*Client) RestrictAdditionalAccessTokenScopes added in v0.7.0

func (c *Client) RestrictAdditionalAccessTokenScopes() func(scopes []string) []string

func (*Client) RestrictAdditionalIdTokenScopes added in v0.7.0

func (c *Client) RestrictAdditionalIdTokenScopes() func(scopes []string) []string

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 (s *Storage) AuthRequestByCode(_ context.Context, code string) (op.AuthRequest, error)

func (*Storage) AuthRequestByID added in v0.7.0

func (s *Storage) AuthRequestByID(_ context.Context, id string) (op.AuthRequest, error)

func (*Storage) AuthorizeClientIDSecret added in v0.7.0

func (s *Storage) AuthorizeClientIDSecret(_ context.Context, clientID, clientSecret string) error

func (*Storage) ClientCredentials added in v0.7.0

func (s *Storage) ClientCredentials(_ context.Context, clientID, clientSecret string) (op.Client, error)

func (*Storage) ClientCredentialsTokenRequest added in v0.7.0

func (s *Storage) ClientCredentialsTokenRequest(_ context.Context, clientID string, scopes []string) (op.TokenRequest, error)

func (*Storage) CreateAccessAndRefreshTokens added in v0.7.0

func (s *Storage) CreateAccessAndRefreshTokens(_ context.Context, req op.TokenRequest, currentRefreshToken string) (string, string, time.Time, error)

func (*Storage) CreateAccessToken added in v0.7.0

func (s *Storage) CreateAccessToken(_ context.Context, req op.TokenRequest) (string, time.Time, error)

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 (s *Storage) DeleteAuthRequest(_ context.Context, id string) error

func (*Storage) GetClientByClientID added in v0.7.0

func (s *Storage) GetClientByClientID(_ context.Context, clientID string) (op.Client, error)

func (*Storage) GetKeyByIDAndClientID added in v0.7.0

func (s *Storage) GetKeyByIDAndClientID(context.Context, string, string) (*jose.JSONWebKey, error)

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 (s *Storage) GetRefreshTokenInfo(_ context.Context, clientID string, token string) (string, string, error)

func (*Storage) Health added in v0.7.0

func (s *Storage) Health(context.Context) error

func (*Storage) KeySet added in v0.7.0

func (s *Storage) KeySet(context.Context) ([]op.Key, error)

func (*Storage) RevokeToken added in v0.7.0

func (s *Storage) RevokeToken(_ context.Context, tokenOrID string, _ string, clientID string) *oidc.Error

func (*Storage) SaveAuthCode added in v0.7.0

func (s *Storage) SaveAuthCode(_ context.Context, id string, code string) error

func (*Storage) SetIntrospectionFromToken added in v0.7.0

func (s *Storage) SetIntrospectionFromToken(_ context.Context, resp *oidc.IntrospectionResponse, tokenID, _, _ string) error

func (*Storage) SetUserinfoFromScopes added in v0.7.0

func (s *Storage) SetUserinfoFromScopes(_ context.Context, info *oidc.UserInfo, userID, _ string, scopes []string) error

func (*Storage) SetUserinfoFromToken added in v0.7.0

func (s *Storage) SetUserinfoFromToken(_ context.Context, info *oidc.UserInfo, tokenID, _, _ string) error

func (*Storage) SignatureAlgorithms added in v0.7.0

func (s *Storage) SignatureAlgorithms(context.Context) ([]jose.SignatureAlgorithm, error)

func (*Storage) SigningKey added in v0.7.0

func (s *Storage) SigningKey(context.Context) (op.SigningKey, error)

func (*Storage) TerminateSession added in v0.7.0

func (s *Storage) TerminateSession(context.Context, string, string) error

TerminateSession is called by the end_session endpoint. The tables have no index by user, so the tokens simply expire.

func (*Storage) TokenRequestByRefreshToken added in v0.7.0

func (s *Storage) TokenRequestByRefreshToken(_ context.Context, token string) (op.RefreshTokenRequest, error)

func (*Storage) ValidateJWTProfileScopes added in v0.7.0

func (s *Storage) ValidateJWTProfileScopes(context.Context, string, []string) ([]string, error)

Jump to

Keyboard shortcuts

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