connect

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2026 License: AGPL-3.0 Imports: 10 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"
identityconnect "github.com/elloloop/identity/gen/go/identity/identityconnect"

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. orgSignup is optional: nil (or a deployment not in mode=multi) causes the OrganizationSignup RPC 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) AddGroupMember

AddGroupMember adds a user to a group.

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) 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 invalidates all refresh tokens.

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

CreateGroup creates a new group.

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

ListUsers returns a paginated list of users. Admin only.

func (*IdentityHandler) Logout

Logout invalidates the given refresh token.

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) OrganizationSignup added in v0.8.0

OrganizationSignup creates a new tenant + admin user in one transaction. Only available in `mode=multi`; returns CodeUnimplemented in `mode=single` per docs/IDENTITY.md decision log §3.

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) 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 recovery email. 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) 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) 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) 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) 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