Module: BetterAuth::APIKey

Defined in:
lib/better_auth/api_key.rb,
lib/better_auth/api_key/keys.rb,
lib/better_auth/api_key/types.rb,
lib/better_auth/api_key/utils.rb,
lib/better_auth/api_key/schema.rb,
lib/better_auth/api_key/adapter.rb,
lib/better_auth/api_key/session.rb,
lib/better_auth/api_key/version.rb,
lib/better_auth/api_key/rate_limit.rb,
lib/better_auth/api_key/validation.rb,
lib/better_auth/api_key/error_codes.rb,
lib/better_auth/api_key/routes/index.rb,
lib/better_auth/api_key/configuration.rb,
lib/better_auth/api_key/plugin_factory.rb,
lib/better_auth/api_key/org_authorization.rb,
lib/better_auth/api_key/routes/get_api_key.rb,
lib/better_auth/api_key/routes/list_api_keys.rb,
lib/better_auth/api_key/routes/create_api_key.rb,
lib/better_auth/api_key/routes/delete_api_key.rb,
lib/better_auth/api_key/routes/update_api_key.rb,
lib/better_auth/api_key/routes/verify_api_key.rb,
lib/better_auth/api_key/routes/delete_all_expired_api_keys.rb

Defined Under Namespace

Modules: Adapter, Configuration, Keys, OrgAuthorization, PluginFactory, RateLimit, Routes, SchemaDefinition, Session, Types, Utils, Validation

Constant Summary collapse

VERSION =
"0.5.0"
ERROR_CODES =
{
  "INVALID_METADATA_TYPE" => "metadata must be an object or undefined",
  "REFILL_AMOUNT_AND_INTERVAL_REQUIRED" => "refillAmount is required when refillInterval is provided",
  "REFILL_INTERVAL_AND_AMOUNT_REQUIRED" => "refillInterval is required when refillAmount is provided",
  "USER_BANNED" => "User is banned",
  "UNAUTHORIZED_SESSION" => "Unauthorized or invalid session",
  "KEY_NOT_FOUND" => "API Key not found",
  "KEY_DISABLED" => "API Key is disabled",
  "KEY_EXPIRED" => "API Key has expired",
  "USAGE_EXCEEDED" => "API Key has reached its usage limit",
  "KEY_NOT_RECOVERABLE" => "API Key is not recoverable",
  "EXPIRES_IN_IS_TOO_SMALL" => "The expiresIn is smaller than the predefined minimum value.",
  "EXPIRES_IN_IS_TOO_LARGE" => "The expiresIn is larger than the predefined maximum value.",
  "INVALID_REMAINING" => "The remaining count is either too large or too small.",
  "INVALID_PREFIX_LENGTH" => "The prefix length is either too large or too small.",
  "INVALID_NAME_LENGTH" => "The name length is either too large or too small.",
  "METADATA_DISABLED" => "Metadata is disabled.",
  "RATE_LIMIT_EXCEEDED" => "Rate limit exceeded.",
  "NO_VALUES_TO_UPDATE" => "No values to update.",
  "KEY_DISABLED_EXPIRATION" => "Custom key expiration values are disabled.",
  "INVALID_API_KEY" => "Invalid API key.",
  "INVALID_USER_ID_FROM_API_KEY" => "The user id from the API key is invalid.",
  "INVALID_REFERENCE_ID_FROM_API_KEY" => "The reference id from the API key is invalid.",
  "INVALID_API_KEY_GETTER_RETURN_TYPE" => "API Key getter returned an invalid key type. Expected string.",
  "SERVER_ONLY_PROPERTY" => "The property you're trying to set can only be set from the server auth instance only.",
  "FAILED_TO_UPDATE_API_KEY" => "Failed to update API key",
  "NAME_REQUIRED" => "API Key name is required.",
  "ORGANIZATION_ID_REQUIRED" => "Organization ID is required for organization-owned API keys.",
  "USER_NOT_MEMBER_OF_ORGANIZATION" => "You are not a member of the organization that owns this API key.",
  "INSUFFICIENT_API_KEY_PERMISSIONS" => "You do not have permission to perform this action on organization API keys.",
  "NO_DEFAULT_API_KEY_CONFIGURATION_FOUND" => "No default api-key configuration found.",
  "ORGANIZATION_PLUGIN_REQUIRED" => "Organization plugin is required for organization-owned API keys. Please install and configure the organization plugin."
}.freeze

Class Method Summary collapse

Class Method Details

.default_key_hasher(key) ⇒ Object



31
32
33
# File 'lib/better_auth/api_key.rb', line 31

def default_key_hasher(key)
  Plugins.default_api_key_hasher(key)
end