connect

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: May 9, 2026 License: AGPL-3.0 Imports: 9 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

func NewIdentityHandler(
	auth *service.AuthService,
	admin *service.AdminService,
	groups *service.GroupService,
	help *service.HelpService,
	profile *service.ProfileService,
	cfg *config.Config,
) *IdentityHandler

NewIdentityHandler creates a new IdentityHandler wired to the service layer.

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) 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 deletes a user. Admin only. Delegates to DeactivateUser since the service layer does not provide hard-delete — deactivation is the supported removal path.

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

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

RequestPasswordReset sends a password reset link to the user's recovery email. Always returns success to prevent email enumeration.

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