httpapi

package
v0.0.18 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: MIT Imports: 46 Imported by: 0

Documentation

Overview

Package httpapi is the HTTP face of the service: the ogen handler (thin: extract params, call one scenario, translate the outcome), JSON:API rendering, the error mapping and the full middleware pipeline (request id, path normalisation, content negotiation, authentication, response signing).

The license route handlers: thin extract→scenario→render shells.

The typed-params body validation of the license routes: create, update, the relationship patches, attach/detach, validate, validate-key, usage and checkout — every unknown key an "unpermitted parameter", every wrong-typed value a "type mismatch", the bearer-dependent keys gated like the reference's conditional schemas.

The licenses index filters (the reference's has_scope declarations).

Request-layer metadata containers have typed_params' depth limit of two. Arrays consume a nesting level just like hashes and include their index in the error pointer. The model separately enforces its depth-four limit.

The middleware pipeline of the architecture contract: request id, bare-path rewrite, routing (Keygen 404), content negotiation, API version check, account resolution, body decoding, the password throttle, authentication, the default header set and the response signature.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConsoleContext

func ConsoleContext(ctx context.Context, accountID uuid.UUID) context.Context

ConsoleContext marks only an in-process console request. Neither HTTP headers nor the public API can set this context key. The internal RPC checks OperatorOf before calling it; the check here is defense in depth.

func New

func New(deps Deps) http.Handler

New builds the service's HTTP handler: the ogen server wrapped in the architecture contract's middleware pipeline. It is the seam between routing and the platform's HTTP mounting.

func PolicyAttributes added in v0.0.18

func PolicyAttributes(attrs map[string]any, productID uuid.UUID) (policies.Input, error)

PolicyAttributes decodes a declared policy's Keygen attributes (the API's camelCase names) exactly as POST /policies decodes them, with the policy bound to the product.

Types

type API

type API struct {
	oas.UnimplementedHandler
	// contains filtered or unexported fields
}

API implements the ogen handler over the app's scenarios. The unimplemented base answers the routes whose groups have not landed.

func (*API) AttachGroupOwners

AttachGroupOwners implements POST /groups/{groupId}/owners.

func (*API) AttachLicenseEntitlements

AttachLicenseEntitlements implements POST …/licenses/{licenseId}/entitlements.

func (*API) AttachLicenseUsers

AttachLicenseUsers implements POST …/licenses/{licenseId}/users.

func (*API) AttachPolicyEntitlements

AttachPolicyEntitlements implements POST /v1/accounts/{account}/policies/{policyId}/entitlements.

func (*API) BanUser

func (a *API) BanUser(ctx context.Context, params oas.BanUserParams) (*oas.UserDocument, error)

BanUser implements the ban action.

func (*API) CheckInLicense

func (a *API) CheckInLicense(ctx context.Context, params oas.CheckInLicenseParams) (*oas.LicenseDocument, error)

CheckInLicense implements POST …/licenses/{licenseId}/actions/check-in.

func (*API) CheckoutLicense

func (a *API) CheckoutLicense(
	ctx context.Context, _ oas.CheckoutLicenseReq, params oas.CheckoutLicenseParams,
) (*oas.LicenseFileDocument, error)

CheckoutLicense implements POST …/licenses/{licenseId}/actions/check-out.

func (*API) CheckoutLicenseFile

func (a *API) CheckoutLicenseFile(
	ctx context.Context, params oas.CheckoutLicenseFileParams,
) (*oas.CheckoutLicenseFileOKHeaders, error)

CheckoutLicenseFile implements GET …/licenses/{licenseId}/actions/check-out (the binary certificate).

func (*API) CheckoutMachine added in v0.0.5

func (a *API) CheckoutMachine(
	ctx context.Context, _ oas.CheckoutMachineReq, params oas.CheckoutMachineParams,
) (*oas.MachineFileDocument, error)

CheckoutMachine implements POST …/machines/{id}/actions/check-out.

func (*API) CheckoutMachineRaw added in v0.0.5

func (a *API) CheckoutMachineRaw(
	ctx context.Context, params oas.CheckoutMachineRawParams,
) (*oas.CheckoutMachineRawOKHeaders, error)

CheckoutMachineRaw implements GET …/machines/{id}/actions/check-out (the certificate itself).

func (*API) CreateComponent added in v0.0.5

CreateComponent implements POST …/components.

func (*API) CreateEntitlement

CreateEntitlement implements POST /v1/accounts/{account}/entitlements.

func (*API) CreateGroup

CreateGroup implements POST /v1/accounts/{account}/groups.

func (*API) CreateKey

CreateKey implements POST /v1/accounts/{account}/keys.

func (*API) CreateLicense

CreateLicense implements POST /v1/accounts/{account}/licenses.

func (*API) CreateLicenseToken

func (a *API) CreateLicenseToken(
	ctx context.Context, _ oas.CreateLicenseTokenReq, params oas.CreateLicenseTokenParams,
) (*oas.TokenDocument, error)

CreateLicenseToken implements POST …/licenses/{licenseId}/tokens.

func (*API) CreateMachine added in v0.0.5

CreateMachine implements POST …/machines (an activation).

func (*API) CreatePolicy

CreatePolicy implements POST /v1/accounts/{account}/policies.

func (*API) CreateProcess added in v0.0.5

CreateProcess implements POST …/processes (a spawn).

func (*API) CreateProduct

CreateProduct implements POST /v1/accounts/{account}/products.

func (*API) CreateProductToken

func (a *API) CreateProductToken(
	ctx context.Context, _ oas.CreateProductTokenReq, params oas.CreateProductTokenParams,
) (*oas.TokenDocument, error)

CreateProductToken implements POST /v1/accounts/{account}/products/{productId}/tokens: a 200 (not 201) with the raw secret exactly once.

func (*API) CreateUser

CreateUser implements POST /v1/accounts/{account}/users.

func (*API) CreateUserSecondFactor

CreateUserSecondFactor implements POST /users/{userId}/second-factors.

func (*API) CreateUserToken

func (a *API) CreateUserToken(
	ctx context.Context, _ oas.CreateUserTokenReq, params oas.CreateUserTokenParams,
) (*oas.TokenDocument, error)

CreateUserToken implements POST /users/{userId}/tokens (200 + secret).

func (*API) CreateWebhookEndpoint

CreateWebhookEndpoint implements POST /v1/accounts/{account}/webhook-endpoints.

func (*API) DecrementLicenseUsage

func (a *API) DecrementLicenseUsage(
	ctx context.Context, _ oas.DecrementLicenseUsageReq, params oas.DecrementLicenseUsageParams,
) (*oas.LicenseDocument, error)

DecrementLicenseUsage implements POST …/licenses/{licenseId}/actions/decrement-usage.

func (*API) DeleteComponent added in v0.0.5

func (a *API) DeleteComponent(ctx context.Context, params oas.DeleteComponentParams) error

DeleteComponent implements DELETE …/components/{id}.

func (*API) DeleteGroup

func (a *API) DeleteGroup(ctx context.Context, params oas.DeleteGroupParams) error

DeleteGroup implements DELETE /v1/accounts/{account}/groups/{groupId}.

func (*API) DeleteMachine added in v0.0.5

func (a *API) DeleteMachine(ctx context.Context, params oas.DeleteMachineParams) error

DeleteMachine implements DELETE …/machines/{id} (a deactivation).

func (*API) DeleteProcess added in v0.0.5

func (a *API) DeleteProcess(ctx context.Context, params oas.DeleteProcessParams) error

DeleteProcess implements DELETE …/processes/{id} (a kill).

func (*API) DeleteUser

func (a *API) DeleteUser(ctx context.Context, params oas.DeleteUserParams) error

DeleteUser implements DELETE /v1/accounts/{account}/users/{userId}.

func (*API) DeleteUserSecondFactor

func (a *API) DeleteUserSecondFactor(
	ctx context.Context, _ oas.DeleteUserSecondFactorReq, params oas.DeleteUserSecondFactorParams,
) error

DeleteUserSecondFactor implements DELETE /users/{userId}/second-factors/{id}.

func (*API) DestroyEntitlement

func (a *API) DestroyEntitlement(ctx context.Context, params oas.DestroyEntitlementParams) error

DestroyEntitlement implements DELETE /v1/accounts/{account}/entitlements/{entitlementId}.

func (*API) DestroyKey

func (a *API) DestroyKey(ctx context.Context, params oas.DestroyKeyParams) error

DestroyKey implements DELETE /v1/accounts/{account}/keys/{keyId}.

func (*API) DestroyLicense

func (a *API) DestroyLicense(ctx context.Context, params oas.DestroyLicenseParams) error

DestroyLicense implements DELETE /v1/accounts/{account}/licenses/{licenseId}.

func (*API) DestroyPolicy

func (a *API) DestroyPolicy(ctx context.Context, params oas.DestroyPolicyParams) error

DestroyPolicy implements DELETE /v1/accounts/{account}/policies/{policyId}.

func (*API) DestroyProduct

func (a *API) DestroyProduct(ctx context.Context, params oas.DestroyProductParams) error

DestroyProduct implements DELETE /v1/accounts/{account}/products/{productId}.

func (*API) DestroyWebhookEndpoint

func (a *API) DestroyWebhookEndpoint(ctx context.Context, params oas.DestroyWebhookEndpointParams) error

DestroyWebhookEndpoint implements DELETE /v1/accounts/{account}/webhook-endpoints/{webhookEndpointId}.

func (*API) DestroyWebhookEvent

func (a *API) DestroyWebhookEvent(ctx context.Context, params oas.DestroyWebhookEventParams) error

DestroyWebhookEvent implements DELETE /v1/accounts/{account}/webhook-events/{webhookEventId}.

func (*API) DetachGroupOwners

func (a *API) DetachGroupOwners(
	ctx context.Context, _ oas.DetachGroupOwnersReq, params oas.DetachGroupOwnersParams,
) error

DetachGroupOwners implements DELETE /groups/{groupId}/owners.

func (*API) DetachLicenseEntitlements

func (a *API) DetachLicenseEntitlements(
	ctx context.Context, _ oas.DetachLicenseEntitlementsReq, params oas.DetachLicenseEntitlementsParams,
) error

DetachLicenseEntitlements implements DELETE …/licenses/{licenseId}/entitlements.

func (*API) DetachLicenseUsers

func (a *API) DetachLicenseUsers(
	ctx context.Context, _ oas.DetachLicenseUsersReq, params oas.DetachLicenseUsersParams,
) error

DetachLicenseUsers implements DELETE …/licenses/{licenseId}/users.

func (*API) DetachPolicyEntitlements

func (a *API) DetachPolicyEntitlements(
	ctx context.Context, _ oas.DetachPolicyEntitlementsReq, params oas.DetachPolicyEntitlementsParams,
) error

DetachPolicyEntitlements implements DELETE /v1/accounts/{account}/policies/{policyId}/entitlements.

func (*API) GenerateMachineProof added in v0.0.5

GenerateMachineProof implements POST …/machines/{id}/actions/generate-offline-proof.

func (*API) GenerateToken

GenerateToken implements POST /v1/accounts/{account}/tokens: Basic email:password (with meta.otp for two-factor users) or any token authentication. The raw secret rides the response exactly once.

func (*API) GetAccount

func (a *API) GetAccount(ctx context.Context, _ oas.GetAccountParams) (*oas.AccountDocument, error)

GetAccount implements GET /v1/accounts/{account}: the configured account with its public keys in the data-level meta. The pipeline has already resolved and authenticated the account.

func (*API) Health

func (a *API) Health(context.Context) error

Health implements GET /v1/health: a bare 204.

func (*API) IncrementLicenseUsage

func (a *API) IncrementLicenseUsage(
	ctx context.Context, _ oas.IncrementLicenseUsageReq, params oas.IncrementLicenseUsageParams,
) (*oas.LicenseDocument, error)

IncrementLicenseUsage implements POST …/licenses/{licenseId}/actions/increment-usage.

func (*API) IndexComponents added in v0.0.5

func (a *API) IndexComponents(ctx context.Context, _ oas.IndexComponentsParams) (*oas.ComponentListDocument, error)

IndexComponents implements GET …/components.

func (*API) IndexEntitlements

func (a *API) IndexEntitlements(
	ctx context.Context, _ oas.IndexEntitlementsParams,
) (*oas.EntitlementListDocument, error)

IndexEntitlements implements GET /v1/accounts/{account}/entitlements.

func (*API) IndexKeys

func (a *API) IndexKeys(ctx context.Context, _ oas.IndexKeysParams) (*oas.KeyListDocument, error)

IndexKeys implements GET /v1/accounts/{account}/keys.

func (*API) IndexLicenseEntitlements

func (a *API) IndexLicenseEntitlements(
	ctx context.Context, params oas.IndexLicenseEntitlementsParams,
) (*oas.EntitlementListDocument, error)

IndexLicenseEntitlements implements GET …/licenses/{licenseId}/entitlements.

func (*API) IndexLicenseMachines

func (a *API) IndexLicenseMachines(
	ctx context.Context, params oas.IndexLicenseMachinesParams,
) (*oas.MachineListDocument, error)

IndexLicenseMachines implements GET …/licenses/{licenseId}/machines.

func (*API) IndexLicenseTokens

func (a *API) IndexLicenseTokens(
	ctx context.Context, params oas.IndexLicenseTokensParams,
) (*oas.TokenCollectionDocument, error)

IndexLicenseTokens implements GET …/licenses/{licenseId}/tokens.

func (*API) IndexLicenseUsers

func (a *API) IndexLicenseUsers(
	ctx context.Context, params oas.IndexLicenseUsersParams,
) (*oas.UserCollectionDocument, error)

IndexLicenseUsers implements GET …/licenses/{licenseId}/users.

func (*API) IndexLicenses

func (a *API) IndexLicenses(ctx context.Context, _ oas.IndexLicensesParams) (*oas.LicenseListDocument, error)

IndexLicenses implements GET /v1/accounts/{account}/licenses.

func (*API) IndexMachineComponents added in v0.0.5

func (a *API) IndexMachineComponents(
	ctx context.Context, params oas.IndexMachineComponentsParams,
) (*oas.ComponentListDocument, error)

IndexMachineComponents implements GET …/machines/{id}/components.

func (*API) IndexMachineProcesses added in v0.0.5

func (a *API) IndexMachineProcesses(
	ctx context.Context, params oas.IndexMachineProcessesParams,
) (*oas.ProcessListDocument, error)

IndexMachineProcesses implements GET …/machines/{id}/processes.

func (*API) IndexMachines added in v0.0.5

func (a *API) IndexMachines(ctx context.Context, _ oas.IndexMachinesParams) (*oas.MachineListDocument, error)

IndexMachines implements GET …/machines.

func (*API) IndexPolicies

func (a *API) IndexPolicies(ctx context.Context, _ oas.IndexPoliciesParams) (*oas.PolicyListDocument, error)

IndexPolicies implements GET /v1/accounts/{account}/policies.

func (*API) IndexPolicyEntitlements

func (a *API) IndexPolicyEntitlements(
	ctx context.Context, params oas.IndexPolicyEntitlementsParams,
) (*oas.EntitlementListDocument, error)

IndexPolicyEntitlements implements GET /v1/accounts/{account}/policies/{policyId}/entitlements.

func (*API) IndexPolicyLicenses

func (a *API) IndexPolicyLicenses(
	ctx context.Context, params oas.IndexPolicyLicensesParams,
) (*oas.LicenseListDocument, error)

IndexPolicyLicenses implements GET /v1/accounts/{account}/policies/{policyId}/licenses.

func (*API) IndexPolicyPool

func (a *API) IndexPolicyPool(
	ctx context.Context, params oas.IndexPolicyPoolParams,
) (*oas.KeyListDocument, error)

IndexPolicyPool implements GET /v1/accounts/{account}/policies/{policyId}/pool.

func (*API) IndexProcesses added in v0.0.5

func (a *API) IndexProcesses(ctx context.Context, _ oas.IndexProcessesParams) (*oas.ProcessListDocument, error)

IndexProcesses implements GET …/processes.

func (*API) IndexProductLicenses

func (a *API) IndexProductLicenses(
	ctx context.Context, params oas.IndexProductLicensesParams,
) (*oas.LicenseListDocument, error)

IndexProductLicenses implements GET /v1/accounts/{account}/products/{productId}/licenses: the right shape (an empty collection with links) until the licenses group lands.

func (*API) IndexProductMachines

func (a *API) IndexProductMachines(
	ctx context.Context, params oas.IndexProductMachinesParams,
) (*oas.MachineListDocument, error)

IndexProductMachines implements GET /v1/accounts/{account}/products/{productId}/machines.

func (*API) IndexProductPolicies

func (a *API) IndexProductPolicies(
	ctx context.Context, params oas.IndexProductPoliciesParams,
) (*oas.PolicyListDocument, error)

IndexProductPolicies implements GET /v1/accounts/{account}/products/{productId}/policies.

func (*API) IndexProductTokens

func (a *API) IndexProductTokens(
	ctx context.Context, params oas.IndexProductTokensParams,
) (*oas.ProductTokenListDocument, error)

IndexProductTokens implements GET /v1/accounts/{account}/products/{productId}/tokens.

func (*API) IndexProductUsers

func (a *API) IndexProductUsers(
	ctx context.Context, params oas.IndexProductUsersParams,
) (*oas.ProductUserListDocument, error)

IndexProductUsers implements GET /v1/accounts/{account}/products/{productId}/users.

func (*API) IndexProducts

func (a *API) IndexProducts(
	ctx context.Context, _ oas.IndexProductsParams,
) (*oas.ProductListDocument, error)

IndexProducts implements GET /v1/accounts/{account}/products.

func (*API) ListGroupLicenses

func (a *API) ListGroupLicenses(
	ctx context.Context, params oas.ListGroupLicensesParams,
) (*oas.LicenseListDocument, error)

ListGroupLicenses implements GET /groups/{groupId}/licenses.

func (*API) ListGroupMachines

func (a *API) ListGroupMachines(
	ctx context.Context, params oas.ListGroupMachinesParams,
) (*oas.MachineListDocument, error)

ListGroupMachines implements GET /groups/{groupId}/machines.

func (*API) ListGroupOwners

func (a *API) ListGroupOwners(
	ctx context.Context, params oas.ListGroupOwnersParams,
) (*oas.GroupOwnerCollectionDocument, error)

ListGroupOwners implements GET /groups/{groupId}/owners.

func (*API) ListGroupUsers

func (a *API) ListGroupUsers(
	ctx context.Context, params oas.ListGroupUsersParams,
) (*oas.UserCollectionDocument, error)

ListGroupUsers implements GET /groups/{groupId}/users.

func (*API) ListGroups

ListGroups implements GET /v1/accounts/{account}/groups.

func (*API) ListTokens

ListTokens implements GET /v1/accounts/{account}/tokens.

func (*API) ListUserLicenses

func (a *API) ListUserLicenses(
	ctx context.Context, params oas.ListUserLicensesParams,
) (*oas.LicenseListDocument, error)

ListUserLicenses implements GET /users/{userId}/licenses.

func (*API) ListUserMachines

func (a *API) ListUserMachines(
	ctx context.Context, params oas.ListUserMachinesParams,
) (*oas.MachineListDocument, error)

ListUserMachines implements GET /users/{userId}/machines.

func (*API) ListUserProducts

func (a *API) ListUserProducts(
	ctx context.Context, params oas.ListUserProductsParams,
) (*oas.UserProductCollectionDocument, error)

ListUserProducts implements GET /users/{userId}/products.

func (*API) ListUserSecondFactors

func (a *API) ListUserSecondFactors(
	ctx context.Context, params oas.ListUserSecondFactorsParams,
) (*oas.SecondFactorCollectionDocument, error)

ListUserSecondFactors implements GET /users/{userId}/second-factors.

func (*API) ListUserTokens

func (a *API) ListUserTokens(
	ctx context.Context, params oas.ListUserTokensParams,
) (*oas.TokenCollectionDocument, error)

ListUserTokens implements GET /users/{userId}/tokens.

func (*API) ListUsers

ListUsers implements GET /v1/accounts/{account}/users.

func (*API) ListWebhookEndpoints

func (a *API) ListWebhookEndpoints(
	ctx context.Context, _ oas.ListWebhookEndpointsParams,
) (*oas.WebhookEndpointListDocument, error)

ListWebhookEndpoints implements GET /v1/accounts/{account}/webhook-endpoints.

func (*API) ListWebhookEvents

func (a *API) ListWebhookEvents(
	ctx context.Context, _ oas.ListWebhookEventsParams,
) (*oas.WebhookEventListDocument, error)

ListWebhookEvents implements GET /v1/accounts/{account}/webhook-events (the events[] filter narrows by exact event names).

func (*API) Me

func (a *API) Me(ctx context.Context, _ oas.MeParams) (*oas.MeDocument, error)

Me implements GET /v1/accounts/{account}/me: the authenticated user with, for token authentication, the current token in included.

func (*API) NewError

func (a *API) NewError(ctx context.Context, err error) *oas.ErrorStatusCode

NewError maps handler errors to Keygen error documents: the typed app error (or the 500 fallback) with the request id as meta.id.

func (*API) Ping

func (a *API) Ping(context.Context) error

Ping implements GET /v1/ping: a one-byte body the pipeline renders as text/plain.

func (*API) PingMachine added in v0.0.5

func (a *API) PingMachine(ctx context.Context, params oas.PingMachineParams) (*oas.MachineDocument, error)

PingMachine implements POST …/machines/{id}/actions/ping.

func (*API) PingMachineHeartbeat added in v0.0.5

func (a *API) PingMachineHeartbeat(
	ctx context.Context, _ oas.PingMachineHeartbeatReq, params oas.PingMachineHeartbeatParams,
) (*oas.MachineDocument, error)

PingMachineHeartbeat implements POST …/machines/{id}/actions/ping-heartbeat.

func (*API) PingProcess added in v0.0.5

func (a *API) PingProcess(
	ctx context.Context, _ oas.PingProcessReq, params oas.PingProcessParams,
) (*oas.ProcessDocument, error)

PingProcess implements POST …/processes/{id}/actions/ping.

func (*API) PopPolicyPool

func (a *API) PopPolicyPool(ctx context.Context, params oas.PopPolicyPoolParams) (*oas.KeyDocument, error)

PopPolicyPool implements DELETE /v1/accounts/{account}/policies/{policyId}/pool.

func (*API) Profile

func (a *API) Profile(ctx context.Context, _ oas.ProfileParams) (*oas.ProfileDocument, error)

Profile implements GET /v1/accounts/{account}/profile: the authenticated user with the current token's id in meta.

func (*API) QuickValidateLicense

func (a *API) QuickValidateLicense(
	ctx context.Context, params oas.QuickValidateLicenseParams,
) (*oas.LicenseValidateDocument, error)

QuickValidateLicense implements GET …/licenses/{licenseId}/actions/validate.

func (*API) RegenerateCurrentToken

func (a *API) RegenerateCurrentToken(
	ctx context.Context, _ oas.RegenerateCurrentTokenParams,
) (*oas.TokenDocument, error)

RegenerateCurrentToken implements the deprecated PUT /tokens.

func (*API) RegenerateToken

func (a *API) RegenerateToken(
	ctx context.Context, params oas.RegenerateTokenParams,
) (*oas.TokenDocument, error)

RegenerateToken implements PUT /tokens/{tokenId}.

func (*API) ReinstateLicense

func (a *API) ReinstateLicense(ctx context.Context, params oas.ReinstateLicenseParams) (*oas.LicenseDocument, error)

ReinstateLicense implements POST …/licenses/{licenseId}/actions/reinstate.

func (*API) RenewLicense

func (a *API) RenewLicense(ctx context.Context, params oas.RenewLicenseParams) (*oas.LicenseDocument, error)

RenewLicense implements POST …/licenses/{licenseId}/actions/renew.

func (*API) ReplaceUserSecondFactor

ReplaceUserSecondFactor is the reference's PUT alias of PATCH.

func (*API) ReportMachineUsage added in v0.0.5

ReportMachineUsage implements POST …/machines/{id}/actions/report-usage.

func (*API) RequestPasswordReset

func (a *API) RequestPasswordReset(
	ctx context.Context, _ oas.RequestPasswordResetReq, _ oas.RequestPasswordResetParams,
) error

RequestPasswordReset implements POST /passwords: always 204.

func (*API) ResetLicenseUsage

func (a *API) ResetLicenseUsage(ctx context.Context, params oas.ResetLicenseUsageParams) (*oas.LicenseDocument, error)

ResetLicenseUsage implements POST …/licenses/{licenseId}/actions/reset-usage.

func (*API) ResetMachine added in v0.0.5

func (a *API) ResetMachine(ctx context.Context, params oas.ResetMachineParams) (*oas.MachineDocument, error)

ResetMachine implements POST …/machines/{id}/actions/reset.

func (*API) ResetMachineHeartbeat added in v0.0.5

func (a *API) ResetMachineHeartbeat(
	ctx context.Context, _ oas.ResetMachineHeartbeatReq, params oas.ResetMachineHeartbeatParams,
) (*oas.MachineDocument, error)

ResetMachineHeartbeat implements POST …/machines/{id}/actions/reset-heartbeat.

func (*API) ResetUserPassword

func (a *API) ResetUserPassword(
	ctx context.Context, _ oas.ResetUserPasswordReq, params oas.ResetUserPasswordParams,
) (*oas.UserDocument, error)

ResetUserPassword implements the reset-password action.

func (*API) RetryWebhookEvent

RetryWebhookEvent implements POST /v1/accounts/{account}/webhook-events/{webhookEventId}/actions/retry.

func (*API) RevokeLicense

func (a *API) RevokeLicense(ctx context.Context, params oas.RevokeLicenseParams) error

RevokeLicense implements DELETE …/licenses/{licenseId}/actions/revoke.

func (*API) RevokeToken

func (a *API) RevokeToken(ctx context.Context, params oas.RevokeTokenParams) error

RevokeToken implements DELETE /tokens/{tokenId}.

func (*API) Search

func (a *API) Search(
	ctx context.Context, _ oas.SearchReq, _ oas.SearchParams,
) (jx.Raw, error)

Search implements POST /v1/accounts/{account}/search: the matches of one resource type, answered as that type's list document.

func (*API) ShowComponent added in v0.0.5

func (a *API) ShowComponent(ctx context.Context, params oas.ShowComponentParams) (*oas.ComponentDocument, error)

ShowComponent implements GET …/components/{id}.

func (*API) ShowComponentLicense added in v0.0.5

func (a *API) ShowComponentLicense(
	ctx context.Context, params oas.ShowComponentLicenseParams,
) (*oas.LicenseDocument, error)

ShowComponentLicense implements GET …/components/{id}/license.

func (*API) ShowComponentMachine added in v0.0.5

func (a *API) ShowComponentMachine(
	ctx context.Context, params oas.ShowComponentMachineParams,
) (*oas.MachineDocument, error)

ShowComponentMachine implements GET …/components/{id}/machine.

func (*API) ShowComponentProduct added in v0.0.5

func (a *API) ShowComponentProduct(
	ctx context.Context, params oas.ShowComponentProductParams,
) (*oas.ProductDocument, error)

ShowComponentProduct implements GET …/components/{id}/product.

func (*API) ShowEntitlement

func (a *API) ShowEntitlement(
	ctx context.Context, params oas.ShowEntitlementParams,
) (*oas.EntitlementDocument, error)

ShowEntitlement implements GET /v1/accounts/{account}/entitlements/{entitlementId}.

func (*API) ShowGroup

func (a *API) ShowGroup(ctx context.Context, params oas.ShowGroupParams) (*oas.GroupDocument, error)

ShowGroup implements GET /v1/accounts/{account}/groups/{groupId}.

func (*API) ShowGroupLicense

func (a *API) ShowGroupLicense(
	ctx context.Context, params oas.ShowGroupLicenseParams,
) (*oas.LicenseDocument, error)

ShowGroupLicense implements GET /groups/{groupId}/licenses/{licenseId}.

func (*API) ShowGroupMachine

func (a *API) ShowGroupMachine(
	ctx context.Context, params oas.ShowGroupMachineParams,
) (*oas.MachineDocument, error)

ShowGroupMachine implements GET /groups/{groupId}/machines/{machineId}.

func (*API) ShowGroupOwner

func (a *API) ShowGroupOwner(
	ctx context.Context, params oas.ShowGroupOwnerParams,
) (*oas.GroupOwnerDocument, error)

ShowGroupOwner implements GET /groups/{groupId}/owners/{ownerId}.

func (*API) ShowGroupUser

func (a *API) ShowGroupUser(ctx context.Context, params oas.ShowGroupUserParams) (*oas.UserDocument, error)

ShowGroupUser implements GET /groups/{groupId}/users/{userId}.

func (*API) ShowKey

func (a *API) ShowKey(ctx context.Context, params oas.ShowKeyParams) (*oas.KeyDocument, error)

ShowKey implements GET /v1/accounts/{account}/keys/{keyId}.

func (*API) ShowKeyPolicy

func (a *API) ShowKeyPolicy(ctx context.Context, params oas.ShowKeyPolicyParams) (*oas.PolicyDocument, error)

ShowKeyPolicy implements GET /v1/accounts/{account}/keys/{keyId}/policy.

func (*API) ShowKeyProduct

func (a *API) ShowKeyProduct(ctx context.Context, params oas.ShowKeyProductParams) (*oas.ProductDocument, error)

ShowKeyProduct implements GET /v1/accounts/{account}/keys/{keyId}/product.

func (*API) ShowLicense

func (a *API) ShowLicense(ctx context.Context, params oas.ShowLicenseParams) (*oas.LicenseDocument, error)

ShowLicense implements GET /v1/accounts/{account}/licenses/{licenseId}.

func (*API) ShowLicenseEntitlement

func (a *API) ShowLicenseEntitlement(
	ctx context.Context, params oas.ShowLicenseEntitlementParams,
) (*oas.EntitlementDocument, error)

ShowLicenseEntitlement implements GET …/licenses/{licenseId}/entitlements/{entitlementId}.

func (*API) ShowLicenseGroup

func (a *API) ShowLicenseGroup(
	ctx context.Context, params oas.ShowLicenseGroupParams,
) (*oas.GroupDocument, error)

ShowLicenseGroup implements GET …/licenses/{licenseId}/group.

func (*API) ShowLicenseMachine

func (a *API) ShowLicenseMachine(
	ctx context.Context, params oas.ShowLicenseMachineParams,
) (*oas.MachineDocument, error)

ShowLicenseMachine implements GET …/licenses/{licenseId}/machines/{machineId}.

func (*API) ShowLicenseOwner

func (a *API) ShowLicenseOwner(
	ctx context.Context, params oas.ShowLicenseOwnerParams,
) (*oas.LicenseOwnerDocument, error)

ShowLicenseOwner implements GET …/licenses/{licenseId}/owner.

func (*API) ShowLicensePolicy

func (a *API) ShowLicensePolicy(
	ctx context.Context, params oas.ShowLicensePolicyParams,
) (*oas.PolicyDocument, error)

ShowLicensePolicy implements GET …/licenses/{licenseId}/policy.

func (*API) ShowLicenseProduct

func (a *API) ShowLicenseProduct(
	ctx context.Context, params oas.ShowLicenseProductParams,
) (*oas.ProductDocument, error)

ShowLicenseProduct implements GET …/licenses/{licenseId}/product.

func (*API) ShowLicenseToken

func (a *API) ShowLicenseToken(
	ctx context.Context, params oas.ShowLicenseTokenParams,
) (*oas.TokenDocument, error)

ShowLicenseToken implements GET …/licenses/{licenseId}/tokens/{tokenId}.

func (*API) ShowLicenseUser

func (a *API) ShowLicenseUser(
	ctx context.Context, params oas.ShowLicenseUserParams,
) (*oas.LicenseOwnerDocument, error)

ShowLicenseUser implements GET …/licenses/{licenseId}/users/{userId}.

func (*API) ShowLicenseUserAlias

func (a *API) ShowLicenseUserAlias(
	ctx context.Context, params oas.ShowLicenseUserAliasParams,
) (*oas.LicenseOwnerDocument, error)

ShowLicenseUserAlias implements GET …/licenses/{licenseId}/user (the v1.5 alias of owner).

func (*API) ShowMachine added in v0.0.5

func (a *API) ShowMachine(ctx context.Context, params oas.ShowMachineParams) (*oas.MachineDocument, error)

ShowMachine implements GET …/machines/{id}.

func (*API) ShowMachineComponent added in v0.0.5

func (a *API) ShowMachineComponent(
	ctx context.Context, params oas.ShowMachineComponentParams,
) (*oas.ComponentDocument, error)

ShowMachineComponent implements GET …/machines/{id}/components/{componentId}.

func (*API) ShowMachineGroup added in v0.0.5

func (a *API) ShowMachineGroup(ctx context.Context, params oas.ShowMachineGroupParams) (*oas.GroupDocument, error)

ShowMachineGroup implements GET …/machines/{id}/group.

func (*API) ShowMachineLicense added in v0.0.5

func (a *API) ShowMachineLicense(
	ctx context.Context, params oas.ShowMachineLicenseParams,
) (*oas.LicenseDocument, error)

ShowMachineLicense implements GET …/machines/{id}/license.

func (*API) ShowMachineOwner added in v0.0.5

func (a *API) ShowMachineOwner(
	ctx context.Context, params oas.ShowMachineOwnerParams,
) (*oas.LicenseOwnerDocument, error)

ShowMachineOwner implements GET …/machines/{id}/owner.

func (*API) ShowMachineProcess added in v0.0.5

func (a *API) ShowMachineProcess(
	ctx context.Context, params oas.ShowMachineProcessParams,
) (*oas.ProcessDocument, error)

ShowMachineProcess implements GET …/machines/{id}/processes/{processId}.

func (*API) ShowMachineProduct added in v0.0.5

func (a *API) ShowMachineProduct(
	ctx context.Context, params oas.ShowMachineProductParams,
) (*oas.ProductDocument, error)

ShowMachineProduct implements GET …/machines/{id}/product.

func (*API) ShowMachineUsage added in v0.0.5

func (a *API) ShowMachineUsage(
	ctx context.Context, params oas.ShowMachineUsageParams,
) (*oas.MachineUsageDocument, error)

ShowMachineUsage implements GET …/machines/{id}/usage.

func (*API) ShowMachineUserAlias added in v0.0.5

func (a *API) ShowMachineUserAlias(
	ctx context.Context, params oas.ShowMachineUserAliasParams,
) (*oas.LicenseOwnerDocument, error)

ShowMachineUserAlias implements GET …/machines/{id}/user (the v1.5 "user": the license's owner).

func (*API) ShowPolicy

func (a *API) ShowPolicy(ctx context.Context, params oas.ShowPolicyParams) (*oas.PolicyDocument, error)

ShowPolicy implements GET /v1/accounts/{account}/policies/{policyId}.

func (*API) ShowPolicyEntitlement

func (a *API) ShowPolicyEntitlement(
	ctx context.Context, params oas.ShowPolicyEntitlementParams,
) (*oas.EntitlementDocument, error)

ShowPolicyEntitlement implements GET /v1/accounts/{account}/policies/{policyId}/entitlements/{entitlementId}.

func (*API) ShowPolicyLicense

func (a *API) ShowPolicyLicense(
	ctx context.Context, params oas.ShowPolicyLicenseParams,
) (*oas.LicenseDocument, error)

ShowPolicyLicense implements GET /v1/accounts/{account}/policies/{policyId}/licenses/{licenseId}.

func (*API) ShowPolicyPoolKey

func (a *API) ShowPolicyPoolKey(
	ctx context.Context, params oas.ShowPolicyPoolKeyParams,
) (*oas.KeyDocument, error)

ShowPolicyPoolKey implements GET /v1/accounts/{account}/policies/{policyId}/pool/{keyId}.

func (*API) ShowPolicyProduct

func (a *API) ShowPolicyProduct(
	ctx context.Context, params oas.ShowPolicyProductParams,
) (*oas.ProductDocument, error)

ShowPolicyProduct implements GET /v1/accounts/{account}/policies/{policyId}/product.

func (*API) ShowProcess added in v0.0.5

func (a *API) ShowProcess(ctx context.Context, params oas.ShowProcessParams) (*oas.ProcessDocument, error)

ShowProcess implements GET …/processes/{id}.

func (*API) ShowProcessLicense added in v0.0.5

func (a *API) ShowProcessLicense(
	ctx context.Context, params oas.ShowProcessLicenseParams,
) (*oas.LicenseDocument, error)

ShowProcessLicense implements GET …/processes/{id}/license.

func (*API) ShowProcessMachine added in v0.0.5

func (a *API) ShowProcessMachine(
	ctx context.Context, params oas.ShowProcessMachineParams,
) (*oas.MachineDocument, error)

ShowProcessMachine implements GET …/processes/{id}/machine.

func (*API) ShowProcessProduct added in v0.0.5

func (a *API) ShowProcessProduct(
	ctx context.Context, params oas.ShowProcessProductParams,
) (*oas.ProductDocument, error)

ShowProcessProduct implements GET …/processes/{id}/product.

func (*API) ShowProduct

func (a *API) ShowProduct(ctx context.Context, params oas.ShowProductParams) (*oas.ProductDocument, error)

ShowProduct implements GET /v1/accounts/{account}/products/{productId}.

func (*API) ShowProductLicense

func (a *API) ShowProductLicense(
	ctx context.Context, params oas.ShowProductLicenseParams,
) (*oas.LicenseDocument, error)

ShowProductLicense implements GET /v1/accounts/{account}/products/{productId}/licenses/{licenseId}: the licenses collection is empty until the group lands, so every show is the 404.

func (*API) ShowProductMachine

func (a *API) ShowProductMachine(
	ctx context.Context, params oas.ShowProductMachineParams,
) (oas.ShowProductMachineOK, error)

ShowProductMachine implements GET /v1/accounts/{account}/products/{productId}/machines/{machineId} (404 until the machines group lands).

func (*API) ShowProductPolicy

func (a *API) ShowProductPolicy(
	ctx context.Context, params oas.ShowProductPolicyParams,
) (*oas.PolicyDocument, error)

ShowProductPolicy implements GET /v1/accounts/{account}/products/{productId}/policies/{policyId}.

func (*API) ShowProductToken

func (a *API) ShowProductToken(
	ctx context.Context, params oas.ShowProductTokenParams,
) (*oas.TokenDocument, error)

ShowProductToken implements GET /v1/accounts/{account}/products/{productId}/tokens/{tokenId}.

func (*API) ShowProductUser

func (a *API) ShowProductUser(
	ctx context.Context, params oas.ShowProductUserParams,
) (*oas.UserDocument, error)

ShowProductUser implements GET /v1/accounts/{account}/products/{productId}/users/{userId}.

func (*API) ShowToken

func (a *API) ShowToken(ctx context.Context, params oas.ShowTokenParams) (*oas.TokenDocument, error)

ShowToken implements GET /v1/accounts/{account}/tokens/{tokenId}.

func (*API) ShowUser

func (a *API) ShowUser(ctx context.Context, params oas.ShowUserParams) (*oas.UserDocument, error)

ShowUser implements GET /v1/accounts/{account}/users/{userId}.

func (*API) ShowUserGroup

func (a *API) ShowUserGroup(ctx context.Context, params oas.ShowUserGroupParams) (*oas.GroupDocument, error)

ShowUserGroup implements GET /users/{userId}/group.

func (*API) ShowUserLicense

func (a *API) ShowUserLicense(
	ctx context.Context, params oas.ShowUserLicenseParams,
) (*oas.LicenseDocument, error)

ShowUserLicense implements GET /users/{userId}/licenses/{licenseId}.

func (*API) ShowUserMachine

func (a *API) ShowUserMachine(
	ctx context.Context, params oas.ShowUserMachineParams,
) (*oas.MachineDocument, error)

ShowUserMachine implements GET /users/{userId}/machines/{machineId}.

func (*API) ShowUserProduct

func (a *API) ShowUserProduct(
	ctx context.Context, params oas.ShowUserProductParams,
) (*oas.UserProductDocument, error)

ShowUserProduct implements GET /users/{userId}/products/{productId}.

func (*API) ShowUserSecondFactor

func (a *API) ShowUserSecondFactor(
	ctx context.Context, params oas.ShowUserSecondFactorParams,
) (*oas.SecondFactorDocument, error)

ShowUserSecondFactor implements GET /users/{userId}/second-factors/{id}.

func (*API) ShowUserToken

func (a *API) ShowUserToken(
	ctx context.Context, params oas.ShowUserTokenParams,
) (*oas.TokenDocument, error)

ShowUserToken implements GET /users/{userId}/tokens/{tokenId}.

func (*API) ShowWebhookEndpoint

func (a *API) ShowWebhookEndpoint(
	ctx context.Context, params oas.ShowWebhookEndpointParams,
) (*oas.WebhookEndpointDocument, error)

ShowWebhookEndpoint implements GET /v1/accounts/{account}/webhook-endpoints/{webhookEndpointId}.

func (*API) ShowWebhookEvent

func (a *API) ShowWebhookEvent(
	ctx context.Context, params oas.ShowWebhookEventParams,
) (*oas.WebhookEventDocument, error)

ShowWebhookEvent implements GET /v1/accounts/{account}/webhook-events/{webhookEventId}.

func (*API) SuspendLicense

func (a *API) SuspendLicense(ctx context.Context, params oas.SuspendLicenseParams) (*oas.LicenseDocument, error)

SuspendLicense implements POST …/licenses/{licenseId}/actions/suspend.

func (*API) UnbanUser

func (a *API) UnbanUser(ctx context.Context, params oas.UnbanUserParams) (*oas.UserDocument, error)

UnbanUser implements the unban action.

func (*API) UpdateComponent added in v0.0.5

func (a *API) UpdateComponent(
	ctx context.Context, _ oas.UpdateComponentReq, params oas.UpdateComponentParams,
) (*oas.ComponentDocument, error)

UpdateComponent implements PATCH …/components/{id}.

func (*API) UpdateEntitlement

func (a *API) UpdateEntitlement(
	ctx context.Context, _ oas.UpdateEntitlementReq, params oas.UpdateEntitlementParams,
) (*oas.EntitlementDocument, error)

UpdateEntitlement implements PATCH /v1/accounts/{account}/entitlements/{entitlementId}.

func (*API) UpdateGroup

func (a *API) UpdateGroup(
	ctx context.Context, _ oas.UpdateGroupReq, params oas.UpdateGroupParams,
) (*oas.GroupDocument, error)

UpdateGroup implements PATCH /v1/accounts/{account}/groups/{groupId}.

func (*API) UpdateKey

func (a *API) UpdateKey(
	ctx context.Context, _ oas.UpdateKeyReq, params oas.UpdateKeyParams,
) (*oas.KeyDocument, error)

UpdateKey implements PATCH /v1/accounts/{account}/keys/{keyId}.

func (*API) UpdateLicense

func (a *API) UpdateLicense(
	ctx context.Context, _ oas.UpdateLicenseReq, params oas.UpdateLicenseParams,
) (*oas.LicenseDocument, error)

UpdateLicense implements PATCH /v1/accounts/{account}/licenses/{licenseId}.

func (*API) UpdateLicenseGroup

func (a *API) UpdateLicenseGroup(
	ctx context.Context, _ oas.UpdateLicenseGroupReq, params oas.UpdateLicenseGroupParams,
) (*oas.LicenseDocument, error)

UpdateLicenseGroup implements PATCH …/licenses/{licenseId}/group.

func (*API) UpdateLicenseOwner

func (a *API) UpdateLicenseOwner(
	ctx context.Context, _ oas.UpdateLicenseOwnerReq, params oas.UpdateLicenseOwnerParams,
) (*oas.LicenseDocument, error)

UpdateLicenseOwner implements PATCH …/licenses/{licenseId}/owner.

func (*API) UpdateLicensePolicy

func (a *API) UpdateLicensePolicy(
	ctx context.Context, _ oas.UpdateLicensePolicyReq, params oas.UpdateLicensePolicyParams,
) (*oas.LicenseDocument, error)

UpdateLicensePolicy implements PATCH …/licenses/{licenseId}/policy.

func (*API) UpdateLicenseUserAlias

func (a *API) UpdateLicenseUserAlias(
	ctx context.Context, _ oas.UpdateLicenseUserAliasReq, params oas.UpdateLicenseUserAliasParams,
) (*oas.LicenseDocument, error)

UpdateLicenseUserAlias implements PATCH …/licenses/{licenseId}/user (the v1.5 alias).

func (*API) UpdateMachine added in v0.0.5

func (a *API) UpdateMachine(
	ctx context.Context, _ oas.UpdateMachineReq, params oas.UpdateMachineParams,
) (*oas.MachineDocument, error)

UpdateMachine implements PATCH …/machines/{id}.

func (*API) UpdateMachineGroup added in v0.0.5

func (a *API) UpdateMachineGroup(
	ctx context.Context, _ oas.UpdateMachineGroupReq, params oas.UpdateMachineGroupParams,
) (*oas.MachineDocument, error)

UpdateMachineGroup implements PATCH (and PUT) …/machines/{id}/group.

func (*API) UpdateMachineOwner added in v0.0.5

func (a *API) UpdateMachineOwner(
	ctx context.Context, _ oas.UpdateMachineOwnerReq, params oas.UpdateMachineOwnerParams,
) (*oas.MachineDocument, error)

UpdateMachineOwner implements PATCH (and PUT) …/machines/{id}/owner.

func (*API) UpdatePolicy

func (a *API) UpdatePolicy(
	ctx context.Context, _ oas.UpdatePolicyReq, params oas.UpdatePolicyParams,
) (*oas.PolicyDocument, error)

UpdatePolicy implements PATCH /v1/accounts/{account}/policies/{policyId}.

func (*API) UpdateProcess added in v0.0.5

func (a *API) UpdateProcess(
	ctx context.Context, _ oas.UpdateProcessReq, params oas.UpdateProcessParams,
) (*oas.ProcessDocument, error)

UpdateProcess implements PATCH …/processes/{id}.

func (*API) UpdateProduct

func (a *API) UpdateProduct(
	ctx context.Context, _ oas.UpdateProductReq, params oas.UpdateProductParams,
) (*oas.ProductDocument, error)

UpdateProduct implements PATCH /v1/accounts/{account}/products/{productId}.

func (*API) UpdateUser

func (a *API) UpdateUser(
	ctx context.Context, _ oas.UpdateUserReq, params oas.UpdateUserParams,
) (*oas.UserDocument, error)

UpdateUser implements PATCH /v1/accounts/{account}/users/{userId}.

func (*API) UpdateUserGroup

func (a *API) UpdateUserGroup(
	ctx context.Context, _ oas.UpdateUserGroupReq, params oas.UpdateUserGroupParams,
) (*oas.UserDocument, error)

UpdateUserGroup implements PUT /users/{userId}/group.

func (*API) UpdateUserPassword

func (a *API) UpdateUserPassword(
	ctx context.Context, _ oas.UpdateUserPasswordReq, params oas.UpdateUserPasswordParams,
) (*oas.UserDocument, error)

UpdateUserPassword implements the update-password action.

func (*API) UpdateUserSecondFactor

UpdateUserSecondFactor implements PATCH /users/{userId}/second-factors/{id}.

func (*API) UpdateWebhookEndpoint

UpdateWebhookEndpoint implements PATCH /v1/accounts/{account}/webhook-endpoints/{webhookEndpointId}.

func (*API) ValidateLicense

ValidateLicense implements POST …/licenses/{licenseId}/actions/validate.

func (*API) ValidateLicenseKey

ValidateLicenseKey implements POST /v1/accounts/{account}/licenses/actions/validate-key.

type Accounts

type Accounts interface {
	// Account loads the account by id.
	Account(ctx context.Context, id uuid.UUID) (domain.Account, error)
}

Accounts is the consumer-side port of the account scenario.

type Deps

type Deps struct {
	SecondFactors secondfactors.Scenario
	Passwords     passwords.Scenario
	Throttle      Throttler
	Accounts      Accounts
	Authn         authn.Scenario
	Users         users.Scenario
	Tokens        tokens.Scenario
	Groups        groups.Scenario
	Products      products.Scenario
	Policies      policies.Scenario
	Entitlements  entitlements.Scenario
	Keys          keys.Scenario
	Licenses      licenses.Scenario
	Machines      machines.Scenario
	Webhooks      webhooks.Scenario
	Search        search.Scenario
	Spec          Spec
	// Revision feeds the Keygen-Revision header (the build's commit).
	Revision string
	// DocsHost overrides the docs origin of error links; when empty it
	// is derived from the request host (its last two labels).
	DocsHost string
	// TrustedProxies lists the proxy CIDRs whose X-Forwarded-For is
	// honored when resolving the client IP (empty: RemoteAddr always).
	TrustedProxies []string
	Clock          func() time.Time
	// Log records the technical failures answered as 500.
	Log *slog.Logger
}

Deps is everything the HTTP face is built from.

type MemoryThrottler

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

func NewMemoryThrottler

func NewMemoryThrottler(clock func() time.Time) *MemoryThrottler

NewMemoryThrottler builds the in-memory counter over the given clock (windows are aligned to it, like Rack::Attack periods).

func (*MemoryThrottler) Inc

func (t *MemoryThrottler) Inc(_ context.Context, key string, window time.Duration) (int64, error)

Inc increments the key's window counter.

type Spec

type Spec struct {
	ID   uuid.UUID
	Slug string
}

Spec identifies the configured account: both its id and its slug address it on the wire.

type Throttler

type Throttler interface {
	// Inc increments the key's counter and answers the new count (an
	// error fails open: the request is allowed through).
	Inc(ctx context.Context, key string, window time.Duration) (int64, error)
}

Throttler counts attempts per key inside a fixed window, mirroring the reference's Rack::Attack counters (the password limiter: 5 per minute per account segment, IP and email hash).

type ValkeyThrottler

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

ValkeyThrottler counts through the cache's raw client (INCR with a window expiry), sharing the counter across replicas.

func NewValkeyThrottler

func NewValkeyThrottler(client valkey.Client) *ValkeyThrottler

NewValkeyThrottler builds the shared counter.

func (*ValkeyThrottler) Inc

func (t *ValkeyThrottler) Inc(ctx context.Context, key string, window time.Duration) (int64, error)

Inc increments the key's window counter.

Jump to

Keyboard shortcuts

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