Documentation
¶
Index ¶
- Constants
- Variables
- type APIError
- type ConfigProvider
- type CustomTokenKeys
- type Handler
- func (h *Handler) Addr() string
- func (h *Handler) ExtractOperation(c *echo.Context) string
- func (h *Handler) ExtractResource(c *echo.Context) string
- func (h *Handler) GetSupportedOperations() []string
- func (h *Handler) Handler() echo.HandlerFunc
- func (h *Handler) MatchPriority() int
- func (h *Handler) Name() string
- func (h *Handler) Reset()
- func (h *Handler) Restore(ctx context.Context, data []byte) error
- func (h *Handler) RouteMatcher() service.Matcher
- func (h *Handler) Shutdown(ctx context.Context)
- func (h *Handler) Snapshot(ctx context.Context) []byte
- func (h *Handler) StartWorker(ctx context.Context) error
- type InMemoryBackend
- func (b *InMemoryBackend) AdminCreate(c call, r *authRequest) (map[string]any, error)
- func (b *InMemoryBackend) BatchCreate(c call, r *uploadRequest) (map[string]any, error)
- func (b *InMemoryBackend) BatchDelete(c call, ids []string, force bool, tenant string) (map[string]any, error)
- func (b *InMemoryBackend) BatchGet(c call, tenant, token string, maxResults int) (map[string]any, error)
- func (b *InMemoryBackend) ClearAccounts(project, tenant string) error
- func (b *InMemoryBackend) CreateAuthURI(c call, r *authRequest) (map[string]any, error)
- func (b *InMemoryBackend) CreateSessionCookie(c call, r *authRequest) (map[string]string, error)
- func (b *InMemoryBackend) CreateTenant(project string, in *idtkv2.GoogleCloudIdentitytoolkitAdminV2Tenant) (*idtkv2.GoogleCloudIdentitytoolkitAdminV2Tenant, error)
- func (b *InMemoryBackend) DeleteAccount(c call, r *authRequest) error
- func (b *InMemoryBackend) DeleteTenant(project, id string) error
- func (b *InMemoryBackend) GetConfig(project string) *idtkv2.GoogleCloudIdentitytoolkitAdminV2Config
- func (b *InMemoryBackend) GetTenant(project, id string) (*idtkv2.GoogleCloudIdentitytoolkitAdminV2Tenant, error)
- func (b *InMemoryBackend) ListTenants(project, token string, size int) (page.Page[*idtkv2.GoogleCloudIdentitytoolkitAdminV2Tenant], error)
- func (b *InMemoryBackend) Lookup(c call, r *authRequest) (map[string]any, error)
- func (b *InMemoryBackend) OOBCodes(project, tenant string) ([]OOBCode, error)
- func (b *InMemoryBackend) ProjectIDs() []string
- func (b *InMemoryBackend) Query(c call, r *queryRequest) (map[string]any, error)
- func (b *InMemoryBackend) Refresh(grantType, token string) (map[string]string, error)
- func (b *InMemoryBackend) Reset()
- func (b *InMemoryBackend) ResetPassword(c call, r *authRequest) (map[string]any, error)
- func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error
- func (b *InMemoryBackend) SendOobCode(c call, r *authRequest) (*oobResponse, error)
- func (b *InMemoryBackend) SetClock(now func() time.Time)
- func (b *InMemoryBackend) SetCustomTokenKeys(f CustomTokenKeys)
- func (b *InMemoryBackend) SignInWithCustomToken(c call, r *authRequest) (*tokenResponse, error)
- func (b *InMemoryBackend) SignInWithEmailLink(c call, r *authRequest) (*tokenResponse, error)
- func (b *InMemoryBackend) SignInWithPassword(c call, r *authRequest) (*tokenResponse, error)
- func (b *InMemoryBackend) SignUp(c call, r *authRequest) (*tokenResponse, error)
- func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte
- func (b *InMemoryBackend) Update(c call, r *authRequest) (*setAccountResponse, error)
- func (b *InMemoryBackend) UpdateConfig(project string, patch map[string]any, mask string) (*idtkv2.GoogleCloudIdentitytoolkitAdminV2Config, error)
- func (b *InMemoryBackend) UpdateTenant(project, id string, patch map[string]any, mask string) (*idtkv2.GoogleCloudIdentitytoolkitAdminV2Tenant, error)
- type OOBCode
- type Provider
- type Settings
Constants ¶
const DefaultPort = 8145
DefaultPort is the dedicated Identity Platform listener's default TCP port (FIREBASE_AUTH_EMULATOR_HOST).
const DefaultProject = "gopherstack-local"
DefaultProject is the project client calls resolve to when the request names none.
Variables ¶
var ErrNilAppContext = errors.New("gcpidentitytoolkit: nil app context")
ErrNilAppContext is returned when Init is called with a nil AppContext.
var ErrSnapshotNull = errors.New("gcpidentitytoolkit: snapshot contains a null record")
ErrSnapshotNull is returned when a snapshot holds a null record.
Functions ¶
This section is empty.
Types ¶
type APIError ¶
APIError is a Google JSON REST error; Message carries the Identity Toolkit error code.
type ConfigProvider ¶
type ConfigProvider interface {
GetGCPIdentityToolkitSettings() Settings
}
ConfigProvider extracts Identity Platform configuration from the AppContext Config.
type CustomTokenKeys ¶
CustomTokenKeys resolves the public keys that may verify a custom token issued by a service account email.
type Handler ¶
type Handler struct {
Backend *InMemoryBackend
Port int
// contains filtered or unexported fields
}
Handler serves the Identity Toolkit and Secure Token REST APIs on a dedicated listener.
func NewHandler ¶
func NewHandler(backend *InMemoryBackend) *Handler
NewHandler creates a Handler; callers override Port from Settings.
func (*Handler) ExtractOperation ¶
ExtractOperation returns the operation name for metrics.
func (*Handler) ExtractResource ¶
ExtractResource returns project[/tenant] for metrics.
func (*Handler) GetSupportedOperations ¶
GetSupportedOperations lists the supported operations.
func (*Handler) Handler ¶
func (h *Handler) Handler() echo.HandlerFunc
Handler returns the Echo handler for every Identity Toolkit and Secure Token request.
func (*Handler) MatchPriority ¶
MatchPriority is irrelevant because RouteMatcher never matches.
func (*Handler) RouteMatcher ¶
RouteMatcher never matches: Identity Platform runs on its own listener.
type InMemoryBackend ¶
type InMemoryBackend struct {
// contains filtered or unexported fields
}
InMemoryBackend holds all Identity Platform state under one lock.
func NewInMemoryBackend ¶
func NewInMemoryBackend() *InMemoryBackend
NewInMemoryBackend creates an empty backend.
func (*InMemoryBackend) AdminCreate ¶
func (b *InMemoryBackend) AdminCreate(c call, r *authRequest) (map[string]any, error)
AdminCreate creates an account without issuing tokens (projects/{p}/accounts).
func (*InMemoryBackend) BatchCreate ¶
func (b *InMemoryBackend) BatchCreate(c call, r *uploadRequest) (map[string]any, error)
BatchCreate imports accounts with optional password hashes (accounts:batchCreate).
func (*InMemoryBackend) BatchDelete ¶
func (b *InMemoryBackend) BatchDelete(c call, ids []string, force bool, tenant string) (map[string]any, error)
BatchDelete deletes accounts; without force only disabled accounts are deleted.
func (*InMemoryBackend) BatchGet ¶
func (b *InMemoryBackend) BatchGet(c call, tenant, token string, maxResults int) (map[string]any, error)
BatchGet pages through accounts with their full password hashes.
func (*InMemoryBackend) ClearAccounts ¶
func (b *InMemoryBackend) ClearAccounts(project, tenant string) error
ClearAccounts deletes every account in a project or tenant (emulator reset endpoint).
func (*InMemoryBackend) CreateAuthURI ¶
func (b *InMemoryBackend) CreateAuthURI(c call, r *authRequest) (map[string]any, error)
CreateAuthURI reports sign-in methods for an identifier, honouring email enumeration protection.
func (*InMemoryBackend) CreateSessionCookie ¶
func (b *InMemoryBackend) CreateSessionCookie(c call, r *authRequest) (map[string]string, error)
CreateSessionCookie mints a session cookie from an ID token.
func (*InMemoryBackend) CreateTenant ¶
func (b *InMemoryBackend) CreateTenant( project string, in *idtkv2.GoogleCloudIdentitytoolkitAdminV2Tenant, ) (*idtkv2.GoogleCloudIdentitytoolkitAdminV2Tenant, error)
CreateTenant creates a tenant with a generated id.
func (*InMemoryBackend) DeleteAccount ¶
func (b *InMemoryBackend) DeleteAccount(c call, r *authRequest) error
DeleteAccount deletes the caller's account (ID token) or any account (admin, by uid).
func (*InMemoryBackend) DeleteTenant ¶
func (b *InMemoryBackend) DeleteTenant(project, id string) error
DeleteTenant removes a tenant and its accounts.
func (*InMemoryBackend) GetConfig ¶
func (b *InMemoryBackend) GetConfig(project string) *idtkv2.GoogleCloudIdentitytoolkitAdminV2Config
GetConfig returns the project configuration.
func (*InMemoryBackend) GetTenant ¶
func (b *InMemoryBackend) GetTenant(project, id string) (*idtkv2.GoogleCloudIdentitytoolkitAdminV2Tenant, error)
GetTenant returns one tenant.
func (*InMemoryBackend) ListTenants ¶
func (b *InMemoryBackend) ListTenants( project, token string, size int, ) (page.Page[*idtkv2.GoogleCloudIdentitytoolkitAdminV2Tenant], error)
ListTenants pages through a project's tenants.
func (*InMemoryBackend) Lookup ¶
func (b *InMemoryBackend) Lookup(c call, r *authRequest) (map[string]any, error)
Lookup returns accounts by ID token (client) or by uid, email, phone or provider id (admin).
func (*InMemoryBackend) OOBCodes ¶
func (b *InMemoryBackend) OOBCodes(project, tenant string) ([]OOBCode, error)
OOBCodes lists the live codes of a project, oldest first. No email is ever sent; tests read codes here.
func (*InMemoryBackend) ProjectIDs ¶
func (b *InMemoryBackend) ProjectIDs() []string
ProjectIDs lists the project IDs with stored state, always including the default project.
func (*InMemoryBackend) Query ¶
func (b *InMemoryBackend) Query(c call, r *queryRequest) (map[string]any, error)
Query filters, sorts and pages accounts (accounts:query).
func (*InMemoryBackend) Refresh ¶
func (b *InMemoryBackend) Refresh(grantType, token string) (map[string]string, error)
Refresh exchanges a refresh token for a new ID token (securetoken v1/token).
func (*InMemoryBackend) Reset ¶
func (b *InMemoryBackend) Reset()
Reset removes all state, including signing keys.
func (*InMemoryBackend) ResetPassword ¶
func (b *InMemoryBackend) ResetPassword(c call, r *authRequest) (map[string]any, error)
ResetPassword checks (no newPassword) or applies (newPassword) a password reset code.
func (*InMemoryBackend) Restore ¶
func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error
Restore loads backend state from a snapshot.
func (*InMemoryBackend) SendOobCode ¶
func (b *InMemoryBackend) SendOobCode(c call, r *authRequest) (*oobResponse, error)
SendOobCode records a reset, verification or sign-in code; no email is sent.
func (*InMemoryBackend) SetClock ¶
func (b *InMemoryBackend) SetClock(now func() time.Time)
SetClock replaces the backend clock.
func (*InMemoryBackend) SetCustomTokenKeys ¶
func (b *InMemoryBackend) SetCustomTokenKeys(f CustomTokenKeys)
SetCustomTokenKeys installs the resolver used to verify RS256 custom tokens.
func (*InMemoryBackend) SignInWithCustomToken ¶
func (b *InMemoryBackend) SignInWithCustomToken(c call, r *authRequest) (*tokenResponse, error)
SignInWithCustomToken exchanges a custom token for an ID token, creating the account on first use.
func (*InMemoryBackend) SignInWithEmailLink ¶
func (b *InMemoryBackend) SignInWithEmailLink(c call, r *authRequest) (*tokenResponse, error)
SignInWithEmailLink completes passwordless sign-in, creating the account on first use.
func (*InMemoryBackend) SignInWithPassword ¶
func (b *InMemoryBackend) SignInWithPassword(c call, r *authRequest) (*tokenResponse, error)
SignInWithPassword authenticates by email and password.
func (*InMemoryBackend) SignUp ¶
func (b *InMemoryBackend) SignUp(c call, r *authRequest) (*tokenResponse, error)
SignUp creates an email/password or anonymous account, or links email/password to an anonymous one.
func (*InMemoryBackend) Snapshot ¶
func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte
Snapshot serialises the backend state, including the token signing key.
func (*InMemoryBackend) Update ¶
func (b *InMemoryBackend) Update(c call, r *authRequest) (*setAccountResponse, error)
Update modifies an account: self-service with an ID token, by oobCode, or by uid for admins.
func (*InMemoryBackend) UpdateConfig ¶
func (b *InMemoryBackend) UpdateConfig( project string, patch map[string]any, mask string, ) (*idtkv2.GoogleCloudIdentitytoolkitAdminV2Config, error)
UpdateConfig merges a patch into the project configuration.
func (*InMemoryBackend) UpdateTenant ¶
func (b *InMemoryBackend) UpdateTenant( project, id string, patch map[string]any, mask string, ) (*idtkv2.GoogleCloudIdentitytoolkitAdminV2Tenant, error)
UpdateTenant merges a patch into a tenant.
type OOBCode ¶
type OOBCode struct {
Email string `json:"email"`
OobCode string `json:"oobCode"`
OobLink string `json:"oobLink"`
RequestType string `json:"requestType"`
}
OOBCode is one stored out-of-band code, as listed by the emulator endpoint.
type Provider ¶
type Provider struct{}
Provider implements service.Provider for Identity Platform. It serves REST on its own listener (see Handler.StartWorker) and never matches on the shared AWS router.
func (*Provider) Init ¶
func (p *Provider) Init(ctx *service.AppContext) (service.Registerable, error)
Init creates the backend and handler; the port is bound in StartWorker.
type Settings ¶
type Settings struct {
DefaultProject string `` //nolint:lll // config struct tags are intentionally verbose
/* 188-byte string literal not displayed */
Port int `` //nolint:lll // config struct tags are intentionally verbose
/* 248-byte string literal not displayed */
}
Settings holds service-level configuration, embedded in the root CLI as CLI.GCPIdentityToolkit.
func DefaultSettings ¶
func DefaultSettings() Settings
DefaultSettings returns the settings used when no ConfigProvider is available.