connect

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2026 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package connect provides the Connect-Go RPC handler layer for the identity service. It implements the identityconnect.IdentityServiceHandler interface generated by buf/protoc-gen-connect-go.

The handler is a thin adapter — it extracts request metadata (IP, user agent, authenticated user ID), calls the appropriate service method, and converts service-layer domain types to proto response messages.

Since buf generate has not run yet, the generated proto types (identitypb.*, identityconnect.*) do not exist. This code is written against the EXPECTED interface. The compiler will catch any mismatches when protos are generated.

Expected generated import paths:

identitypb      "github.com/elloloop/identity/gen/go/identity/v1"
identityconnect "github.com/elloloop/identity/gen/go/identity/v1/identityv1connect"

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IdentityHandler

type IdentityHandler struct {
	// contains filtered or unexported fields
}

IdentityHandler implements identityconnect.IdentityServiceHandler. Each method delegates to the appropriate service, translating between proto and service-layer types.

func NewIdentityHandler

NewIdentityHandler creates a new IdentityHandler wired to the service layer. idv is optional: pass nil in deployments that do not need identity verification, and the IDV RPCs will return CodeUnimplemented.

domains is optional: nil (memory, which has no control plane) causes the tenant-domain RPCs to return CodeUnimplemented.

members is optional: nil (memory, which has no control plane) causes the tenant-membership/invitation RPCs to return CodeUnimplemented.

controlAdmin is optional: nil (memory, or no configured admin secret) causes the control-plane admin RPCs to return CodeUnimplemented.

captchaVerifier is optional: a nil verifier is treated as disabled, so the CAPTCHA gate behaves as a no-op regardless of the per-endpoint toggles. Production wiring passes a concrete verifier (or the no-op one) built from config.

func (*IdentityHandler) AcceptInvitation

AcceptInvitation completes account setup for an invited user.

func (*IdentityHandler) AcceptTenantInvitation added in v0.18.0

AcceptTenantInvitation redeems a raw invitation token for the authenticated caller, making them a member of the tenant.

func (*IdentityHandler) AddGroupMember

AddGroupMember adds a user to a group.

func (*IdentityHandler) AddProjectAuthDomain added in v1.1.0

AddProjectAuthDomain registers a customer-owned serving hostname UNVERIFIED and returns its DNS TXT ownership challenge. Operator-only.

func (*IdentityHandler) AdminAddProjectAuthDomain added in v0.19.0

AdminAddProjectAuthDomain registers a serving hostname on a project, idempotently and seeded verified. Operator-only.

func (*IdentityHandler) AdminAddTenantAdmin added in v0.19.0

AdminAddTenantAdmin bootstraps the first tenant administrator. Operator-only.

func (*IdentityHandler) AdminCreateProject added in v0.19.0

AdminCreateProject provisions a control-plane project. Operator-only.

func (*IdentityHandler) AdminCreateProjectCredential added in v0.19.0

AdminCreateProjectCredential mints a project credential and returns the raw key exactly once. Operator-only.

func (*IdentityHandler) AdminCreateTenant added in v0.19.0

AdminCreateTenant provisions a tenant under a project. Operator-only.

func (*IdentityHandler) ApproveQrLogin

ApproveQrLogin approves or rejects a QR login session from the authenticated device.

func (*IdentityHandler) BeginIdentityVerification added in v0.4.0

BeginIdentityVerification starts a verification session for the caller.

func (*IdentityHandler) BeginOAuthLogin

BeginOAuthLogin returns the provider authorization URL plus the server-minted state artifacts needed to complete the callback safely.

func (*IdentityHandler) BeginPasskeyLogin

BeginPasskeyLogin generates PublicKeyCredentialRequestOptions for navigator.credentials.get().

func (*IdentityHandler) BeginPasskeyRegistration

BeginPasskeyRegistration generates PublicKeyCredentialCreationOptions for navigator.credentials.create().

func (*IdentityHandler) BeginPasskeySignup added in v1.7.2

BeginPasskeySignup generates PublicKeyCredentialCreationOptions for creating a brand-new account from a passkey. Unauthenticated: no session required.

func (*IdentityHandler) BeginTotpSetup

BeginTotpSetup generates a new TOTP secret and recovery codes for the authenticated user. The secret is NOT yet active — the user must call VerifyTotpSetup with a valid code to confirm enrollment.

func (*IdentityHandler) ChangePassword

ChangePassword changes the authenticated user's password after verifying the current password. The service layer also revokes all of the user's sessions (deletes their refresh tokens), forcing re-authentication everywhere — including the caller, who must sign in again with the new password.

func (*IdentityHandler) CompletePasskeyLogin

CompletePasskeyLogin verifies the passkey assertion and issues tokens.

func (*IdentityHandler) CompletePasskeyRegistration

CompletePasskeyRegistration verifies the attestation and stores the new passkey credential.

func (*IdentityHandler) CompletePasskeySignup added in v1.7.2

CompletePasskeySignup verifies the attestation, creates the account (or returns an enumeration-safe decoy when the email already exists) and issues tokens. Unauthenticated: no session required.

func (*IdentityHandler) ConfirmEmailChange

ConfirmEmailChange consumes a pending email-change token (sent to the new address). This RPC is exempt from the auth middleware so a user clicking the link from their inbox doesn't need to be currently signed in. On success, the user's email is updated and ALL of their refresh tokens are revoked, forcing re-authentication everywhere.

func (*IdentityHandler) ConfirmPasswordReset

ConfirmPasswordReset consumes a password-reset token and sets a new password.

func (*IdentityHandler) CreateDomain added in v0.17.0

CreateDomain registers a pending email domain on a tenant and returns the DNS TXT challenge the caller must publish. Available only on the postgres control-plane driver; nil service (memory) returns Unimplemented.

func (*IdentityHandler) CreateFirstPlatformAdmin added in v1.1.0

CreateFirstPlatformAdmin is the zero-config bootstrap of the first platform admin. Unlike the other Admin RPCs it reads NO admin secret: it succeeds only while platform_admins is empty and is rejected (FailedPrecondition) once any admin exists. nil controlAdmin (memory, no control plane) yields Unimplemented.

func (*IdentityHandler) CreateGroup

CreateGroup creates a new group.

func (*IdentityHandler) CreateTenantInvitation added in v0.18.0

CreateTenantInvitation invites an email to join a tenant. Owner/admin only. Available only on the postgres control-plane driver; nil service (memory) returns Unimplemented.

func (*IdentityHandler) CreateUser

CreateUser creates a new user. Admin only. Delegates to InviteUser with createImmediately=true.

func (*IdentityHandler) DeactivateUser

DeactivateUser deactivates a user account. Admin only.

func (*IdentityHandler) DeleteGroup

DeleteGroup deletes a group.

func (*IdentityHandler) DeleteLoginPolicy added in v1.3.0

DeleteLoginPolicy clears a claimed tenant's LoginPolicy (idempotent). Operator-only.

func (*IdentityHandler) DeletePasskey

DeletePasskey deletes a registered passkey credential. Delegates to ProfileService.DeletePasskey.

func (*IdentityHandler) DeleteUser

DeleteUser physically removes a user and cascades all user-owned records (sessions, tokens, passkeys, etc.). Audit events are retained. Admin only.

func (*IdentityHandler) DisableTotp

DisableTotp removes TOTP enrollment for the authenticated user. Requires password confirmation for security.

func (*IdentityHandler) GetCurrentUser

GetCurrentUser returns the currently authenticated user's profile.

func (*IdentityHandler) GetIdentityVerificationStatus added in v0.4.0

GetIdentityVerificationStatus returns the current status of a verification.

func (*IdentityHandler) GetLoginPolicy added in v1.3.0

GetLoginPolicy reads a claimed tenant's LoginPolicy. The policy field is unset when none exists. Operator-only.

func (*IdentityHandler) GetProjectConfig added in v1.3.0

GetProjectConfig reads a project's config_json blob. Operator-only.

func (*IdentityHandler) GetQrLoginSession

GetQrLoginSession retrieves the details of a QR login session for display on the authenticated device.

func (*IdentityHandler) GetUser

GetUser returns a single user by ID. Admin only.

func (*IdentityHandler) InitiateQrLogin

InitiateQrLogin creates a new QR login session for a new device.

func (*IdentityHandler) InviteUser

InviteUser creates a new user invitation or immediately creates an active user.

func (*IdentityHandler) LinkIdentity added in v1.3.0

LinkIdentity attaches a freshly-verified OAuth identity to the caller. The server performs the provider code exchange itself; the client is never trusted to assert the identity.

func (*IdentityHandler) ListAuditEvents

ListAuditEvents returns a paginated list of audit events. Admin only. Delegates to ProfileService.ListAuditEvents which enforces admin role.

func (*IdentityHandler) ListGroupMembers

ListGroupMembers lists all members of a group.

func (*IdentityHandler) ListGroups

ListGroups returns a paginated list of groups.

func (*IdentityHandler) ListHelpRequests

ListHelpRequests returns a paginated list of admin help requests. Admin only.

func (*IdentityHandler) ListLinkedIdentities added in v1.3.0

ListLinkedIdentities returns the authenticated user's connected providers.

func (*IdentityHandler) ListMySessions

ListMySessions lists the authenticated user's active sessions.

func (*IdentityHandler) ListPasskeys

ListPasskeys lists the authenticated user's registered passkey credentials. Delegates to ProfileService.ListMyPasskeys.

func (*IdentityHandler) ListProjectAuthDomains added in v1.1.0

ListProjectAuthDomains lists a project's auth-domains (verified and pending). Operator-only.

func (*IdentityHandler) ListTenantDomains added in v0.17.0

ListTenantDomains lists every domain bound to a tenant.

func (*IdentityHandler) ListTenantInvitations added in v0.18.0

ListTenantInvitations lists every invitation in a tenant. Owner/admin only.

func (*IdentityHandler) ListTenantMembers added in v0.18.0

ListTenantMembers lists every membership in a tenant. Owner/admin only.

func (*IdentityHandler) ListUsers

ListUsers returns a paginated list of users. Admin only.

func (*IdentityHandler) Logout

Logout invalidates the given refresh token.

func (*IdentityHandler) NativeOAuthLogin added in v1.8.0

NativeOAuthLogin verifies a native mobile-SDK ID token (Google idToken / Apple identityToken) server-side and issues backend tokens scoped to the product's project — no browser, no PKCE. The service layer performs the token verification, product→project resolution, account linking, and token issuance; the handler forwards the request fields and the caller's IP / UA.

func (*IdentityHandler) OAuthLogin

OAuthLogin exchanges an OAuth authorization code for backend-issued tokens.

The service layer is responsible for the actual provider-side code exchange and identity verification. The handler simply forwards the authorization code, the user-selected provider, and the redirect URI.

func (*IdentityHandler) PasswordLogin

PasswordLogin authenticates a user with email and password. If TOTP is enabled, returns totp_required=true and a login_challenge_id for the client to pass to VerifyTotp.

func (*IdentityHandler) PasswordSignup

PasswordSignup creates a new user account with email and password.

func (*IdentityHandler) PollQrLogin

PollQrLogin polls for QR login session completion from the new device.

func (*IdentityHandler) ReactivateUser

ReactivateUser reactivates a previously deactivated user. Admin only.

RedeemMagicLink consumes the single-use token, resolves-or-creates the user by the bound email, and issues a token pair plus the validated return_to.

func (*IdentityHandler) RedeemOAuthCode added in v0.9.0

RedeemOAuthCode exchanges the single-use one-time code from the hosted OAuth callback redirect for a backend-issued token pair. The code is consumed atomically; a replay or expired code surfaces as CodeUnauthenticated.

func (*IdentityHandler) RefreshToken

RefreshToken rotates the refresh token and issues a new access token.

func (*IdentityHandler) RegenerateRecoveryCodes

RegenerateRecoveryCodes generates a new set of recovery codes, invalidating any existing codes. Requires password confirmation.

func (*IdentityHandler) RemoveGroupMember

RemoveGroupMember removes a user from a group.

func (*IdentityHandler) RemoveTenantMember added in v0.18.0

RemoveTenantMember removes a user's membership from a tenant. Owner/admin only, and never the tenant's last owner.

func (*IdentityHandler) RequestAdminHelp

RequestAdminHelp creates a new admin help request. This is an unauthenticated endpoint — the user cannot log in and needs admin assistance.

func (*IdentityHandler) RequestEmailChange

RequestEmailChange begins the primary-email rotation flow. The caller must already be authenticated (auth middleware enforces this) AND supply their current password as a re-authentication step. The new address is sent a verification link; the old address is sent a security notice. The change takes effect only after ConfirmEmailChange.

func (*IdentityHandler) RequestEmailLoginCode added in v0.11.0

RequestEmailLoginCode emails a 6-digit OTP. The response is identical whether or not the email has an account (anti-enumeration); the service always returns nil for a well-formed request.

RequestMagicLink emails a single-use sign-in link. A disallowed return_to is rejected with InvalidArgument; everything else returns the same anti-enumeration success.

func (*IdentityHandler) RequestPasswordReset

RequestPasswordReset sends a password reset link to the user's primary verified email (the address on file for the account). Always returns success to prevent email enumeration.

func (*IdentityHandler) RequestPhoneVerification added in v0.14.0

RequestPhoneVerification texts a 6-digit code to the supplied number for the authenticated caller to confirm.

func (*IdentityHandler) ResetUserPassword

ResetUserPassword resets a user's password. Admin only.

func (*IdentityHandler) ResolveHelpRequest

ResolveHelpRequest resolves or rejects an admin help request. Admin only.

func (*IdentityHandler) RevokeAllSessions

RevokeAllSessions revokes all sessions for the authenticated user. Requires password confirmation.

func (*IdentityHandler) RevokeSession

RevokeSession revokes a single session by its ID.

func (*IdentityHandler) SendEmailVerification

SendEmailVerification sends a verification email to the authenticated user.

func (*IdentityHandler) SetPrimaryAuthDomain added in v1.2.0

SetPrimaryAuthDomain promotes a VERIFIED custom auth-domain to the project's primary serving host, atomically demoting the current primary. Operator-only.

func (*IdentityHandler) SetUserQuota

SetUserQuota sets a user's storage quota. Admin only.

func (*IdentityHandler) SignOutEverywhere

SignOutEverywhere revokes all sessions for the authenticated user. This is a distinct RPC from RevokeAllSessions per the proto definition but delegates to the same service method.

func (*IdentityHandler) UnlinkIdentity added in v1.3.0

UnlinkIdentity disconnects a provider identity from the caller, refusing to remove the user's last remaining sign-in credential.

func (*IdentityHandler) UpdateGroup

UpdateGroup updates a group's name and/or description.

func (*IdentityHandler) UpdateProfile

UpdateProfile updates the authenticated user's profile (name, avatar).

func (*IdentityHandler) UpdateUser

UpdateUser updates a user's profile fields. Admin only.

func (*IdentityHandler) UpsertLoginPolicy added in v1.3.0

UpsertLoginPolicy authors a claimed tenant's LoginPolicy (the policy the login path enforces). Operator-only.

func (*IdentityHandler) UpsertProjectConfig added in v1.3.0

UpsertProjectConfig replaces a project's config_json blob. Operator-only.

func (*IdentityHandler) VerifyDomain added in v0.17.0

VerifyDomain proves control of a pending domain, claiming its tenant and making the caller an owner on success.

func (*IdentityHandler) VerifyEmail

VerifyEmail consumes an email-verification token and marks the email verified.

func (*IdentityHandler) VerifyEmailLoginCode added in v0.11.0

VerifyEmailLoginCode validates the OTP, resolves-or-creates the user by email, and issues a token pair.

func (*IdentityHandler) VerifyPhoneCode added in v0.14.0

VerifyPhoneCode validates the OTP and marks the authenticated caller's phone verified, returning the updated user.

func (*IdentityHandler) VerifyProjectAuthDomain added in v1.1.0

VerifyProjectAuthDomain checks the DNS TXT challenge and flips a custom auth-domain to verified (resolving). Operator-only.

func (*IdentityHandler) VerifyTotp

VerifyTotp completes a login challenge that requires TOTP. Accepts either a 6-digit TOTP code or a recovery code.

func (*IdentityHandler) VerifyTotpSetup

VerifyTotpSetup confirms TOTP enrollment by verifying a code generated from the secret provided by BeginTotpSetup.

Jump to

Keyboard shortcuts

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