fastauth_plugin_api_key/
error.rs1use fastauth_core::plugin_prelude::*;
4
5#[derive(AuthError, Clone, Copy, Debug, PartialEq, Eq)]
8pub enum ApiKeyError {
9 #[auth_error(status = 400, message = "metadata must be an object or undefined")]
10 InvalidMetadataType,
11 #[auth_error(
12 status = 400,
13 message = "refillAmount is required when refillInterval is provided"
14 )]
15 RefillAmountAndIntervalRequired,
16 #[auth_error(
17 status = 400,
18 message = "refillInterval is required when refillAmount is provided"
19 )]
20 RefillIntervalAndAmountRequired,
21 #[auth_error(status = 401, message = "Unauthorized or invalid session")]
22 UnauthorizedSession,
23 #[auth_error(status = 404, message = "API Key not found")]
25 KeyNotFound,
26 #[auth_error(status = 401, message = "API Key is disabled")]
27 KeyDisabled,
28 #[auth_error(status = 401, message = "API Key has expired")]
29 KeyExpired,
30 #[auth_error(status = 429, message = "API Key has reached its usage limit")]
31 UsageExceeded,
32 #[auth_error(
33 status = 400,
34 message = "The expiresIn is smaller than the predefined minimum value."
35 )]
36 ExpiresInIsTooSmall,
37 #[auth_error(
38 status = 400,
39 message = "The expiresIn is larger than the predefined maximum value."
40 )]
41 ExpiresInIsTooLarge,
42 #[auth_error(
43 status = 400,
44 message = "The prefix length is either too large or too small."
45 )]
46 InvalidPrefixLength,
47 #[auth_error(
48 status = 400,
49 message = "The name length is either too large or too small."
50 )]
51 InvalidNameLength,
52 #[auth_error(status = 400, message = "Metadata is disabled.")]
53 MetadataDisabled,
54 #[auth_error(status = 429, message = "Rate limit exceeded.")]
56 RateLimited,
57 #[auth_error(status = 400, message = "No values to update.")]
58 NoValuesToUpdate,
59 #[auth_error(status = 401, message = "Invalid API key.")]
60 InvalidApiKey,
61 #[auth_error(
62 status = 400,
63 message = "The property you're trying to set can only be set from the server auth instance only."
64 )]
65 ServerOnlyProperty,
66 #[auth_error(status = 500, message = "Failed to update API key")]
67 FailedToUpdateApiKey,
68 #[auth_error(status = 400, message = "API Key name is required.")]
69 NameRequired,
70}