From 0ac2002cffa9f67acc91af1ff00a7386e6e09a5c Mon Sep 17 00:00:00 2001 From: Matthew Mauer Date: Tue, 11 Feb 2025 16:50:44 -0500 Subject: [PATCH 1/2] catch PropelAuthRateLimit error on all requests --- src/apis/api_key_service_api.rs | 1 + src/propelauth/access_token.rs | 2 + src/propelauth/api_key.rs | 70 +++++++++++++++++++++++++-------- src/propelauth/auth.rs | 3 +- src/propelauth/errors.rs | 54 +++++++++++++++++++++++++ src/propelauth/org.rs | 21 ++++++++++ src/propelauth/user.rs | 20 ++++++++++ 7 files changed, 153 insertions(+), 18 deletions(-) diff --git a/src/apis/api_key_service_api.rs b/src/apis/api_key_service_api.rs index 4a1a656..9799f90 100644 --- a/src/apis/api_key_service_api.rs +++ b/src/apis/api_key_service_api.rs @@ -56,6 +56,7 @@ pub enum ApiKeyError { wait_seconds: f64, user_facing_error: String, }, + PropelAuthRateLimit, InvalidPersonalAPIKey, InvalidOrgAPIKey, NotFound, diff --git a/src/propelauth/access_token.rs b/src/propelauth/access_token.rs index a54bc36..4389649 100644 --- a/src/propelauth/access_token.rs +++ b/src/propelauth/access_token.rs @@ -32,6 +32,7 @@ impl AccessTokenService<'_> { )), ) => CreateAccessTokenError::BadRequest(bad_request), (401, _) => CreateAccessTokenError::InvalidApiKey, + (429, _) => CreateAccessTokenError::PropelAuthRateLimit, (404, _) => CreateAccessTokenError::NotFound, _ => CreateAccessTokenError::UnexpectedException, }, @@ -61,6 +62,7 @@ impl AccessTokenService<'_> { )), ) => CreateAccessTokenError::BadRequest(bad_request), (401, _) => CreateAccessTokenError::InvalidApiKey, + (429, _) => CreateAccessTokenError::PropelAuthRateLimit, (404, _) => CreateAccessTokenError::NotFound, _ => CreateAccessTokenError::UnexpectedException, }, diff --git a/src/propelauth/api_key.rs b/src/propelauth/api_key.rs index d22b31a..244e8ff 100644 --- a/src/propelauth/api_key.rs +++ b/src/propelauth/api_key.rs @@ -1,7 +1,14 @@ -use crate::apis::api_key_service_api::{ApiKeyError, ApiKeyQueryParams, ApiKeyValidationErrorResponse, CreateApiKeyParams, UpdateApiKeyParams, ValidateApiKeyParams}; +use crate::apis::api_key_service_api::{ + ApiKeyError, ApiKeyQueryParams, ApiKeyValidationErrorResponse, CreateApiKeyParams, + UpdateApiKeyParams, ValidateApiKeyParams, +}; use crate::apis::configuration::Configuration; -use crate::models::{CreateApiKeyResponse, FetchApiKeyResponse, FetchApiKeysPagedResponse, ValidateApiKeyResponse}; -use crate::models::validate_api_key_response::{ValidateOrgApiKeyResponse, ValidatePersonalApiKeyResponse}; +use crate::models::validate_api_key_response::{ + ValidateOrgApiKeyResponse, ValidatePersonalApiKeyResponse, +}; +use crate::models::{ + CreateApiKeyResponse, FetchApiKeyResponse, FetchApiKeysPagedResponse, ValidateApiKeyResponse, +}; use crate::propelauth::helpers::map_autogenerated_error; pub struct ApiKeyService<'a> { @@ -9,7 +16,10 @@ pub struct ApiKeyService<'a> { } impl ApiKeyService<'_> { - pub async fn fetch_current_api_keys(&self, params: ApiKeyQueryParams) -> Result { + pub async fn fetch_current_api_keys( + &self, + params: ApiKeyQueryParams, + ) -> Result { crate::apis::api_key_service_api::fetch_current_api_keys(&self.config, params) .await .map_err(|err| { @@ -20,10 +30,11 @@ impl ApiKeyService<'_> { ( _, Some(crate::apis::api_key_service_api::ApiKeyError::BadRequest( - bad_request, - )), + bad_request, + )), ) => ApiKeyError::BadRequest(bad_request), (401, _) => ApiKeyError::InvalidIntegrationAPIKey, + (429, _) => ApiKeyError::PropelAuthRateLimit, (404, _) => ApiKeyError::NotFound, _ => ApiKeyError::UnexpectedExceptionWithSDK, }, @@ -31,7 +42,10 @@ impl ApiKeyService<'_> { }) } - pub async fn fetch_archived_api_keys(&self, params: ApiKeyQueryParams) -> Result { + pub async fn fetch_archived_api_keys( + &self, + params: ApiKeyQueryParams, + ) -> Result { crate::apis::api_key_service_api::fetch_archived_api_keys(&self.config, params) .await .map_err(|err| { @@ -42,10 +56,11 @@ impl ApiKeyService<'_> { ( _, Some(crate::apis::api_key_service_api::ApiKeyError::BadRequest( - bad_request, - )), + bad_request, + )), ) => ApiKeyError::BadRequest(bad_request), (401, _) => ApiKeyError::InvalidIntegrationAPIKey, + (429, _) => ApiKeyError::PropelAuthRateLimit, (404, _) => ApiKeyError::NotFound, _ => ApiKeyError::UnknownError, }, @@ -53,7 +68,10 @@ impl ApiKeyService<'_> { }) } - pub async fn fetch_api_key(&self, api_key_id: String) -> Result { + pub async fn fetch_api_key( + &self, + api_key_id: String, + ) -> Result { crate::apis::api_key_service_api::fetch_api_key(&self.config, api_key_id) .await .map_err(|err| { @@ -62,6 +80,7 @@ impl ApiKeyService<'_> { ApiKeyError::UnexpectedExceptionWithSDK, |status_code, _| match status_code.as_u16() { 401 => ApiKeyError::InvalidIntegrationAPIKey, + 429 => ApiKeyError::PropelAuthRateLimit, 404 => ApiKeyError::NotFound, _ => ApiKeyError::UnknownError, }, @@ -69,7 +88,10 @@ impl ApiKeyService<'_> { }) } - pub async fn create_api_key(&self, params: CreateApiKeyParams) -> Result { + pub async fn create_api_key( + &self, + params: CreateApiKeyParams, + ) -> Result { crate::apis::api_key_service_api::create_api_key(&self.config, params) .await .map_err(|err| { @@ -78,6 +100,7 @@ impl ApiKeyService<'_> { ApiKeyError::UnexpectedExceptionWithSDK, |status_code, _| match status_code.as_u16() { 401 => ApiKeyError::InvalidIntegrationAPIKey, + 429 => ApiKeyError::PropelAuthRateLimit, 404 => ApiKeyError::NotFound, _ => ApiKeyError::UnknownError, }, @@ -85,7 +108,11 @@ impl ApiKeyService<'_> { }) } - pub async fn update_api_key(&self, api_key_id: String, params: UpdateApiKeyParams) -> Result<(), ApiKeyError> { + pub async fn update_api_key( + &self, + api_key_id: String, + params: UpdateApiKeyParams, + ) -> Result<(), ApiKeyError> { crate::apis::api_key_service_api::update_api_key(&self.config, api_key_id, params) .await .map_err(|err| { @@ -94,6 +121,7 @@ impl ApiKeyService<'_> { ApiKeyError::UnexpectedExceptionWithSDK, |status_code, _| match status_code.as_u16() { 401 => ApiKeyError::InvalidIntegrationAPIKey, + 429 => ApiKeyError::PropelAuthRateLimit, 404 => ApiKeyError::NotFound, _ => ApiKeyError::UnknownError, }, @@ -112,6 +140,7 @@ impl ApiKeyService<'_> { ApiKeyError::UnexpectedExceptionWithSDK, |status_code, _| match status_code.as_u16() { 401 => ApiKeyError::InvalidIntegrationAPIKey, + 429 => ApiKeyError::PropelAuthRateLimit, 404 => ApiKeyError::NotFound, _ => ApiKeyError::UnknownError, }, @@ -127,10 +156,10 @@ impl ApiKeyService<'_> { ) -> Result { if hex::decode(¶ms.api_key_token).is_err() { return Err(ApiKeyError::InvalidAPIKey { - message: "Invalid API key format.".to_string() - }); + message: "Invalid API key format.".to_string(), + }); } - + crate::apis::api_key_service_api::validate_api_key(&self.config, params) .await .map_err(|err| { @@ -153,6 +182,7 @@ impl ApiKeyService<'_> { }, None => match status_code.as_u16() { 401 => ApiKeyError::InvalidIntegrationAPIKey, + 429 => ApiKeyError::PropelAuthRateLimit, 404 => ApiKeyError::NotFound, _ => ApiKeyError::UnknownError, }, @@ -161,7 +191,10 @@ impl ApiKeyService<'_> { }) } - pub async fn validate_personal_api_key(&self, params: ValidateApiKeyParams) -> Result { + pub async fn validate_personal_api_key( + &self, + params: ValidateApiKeyParams, + ) -> Result { let resp = self.validate_api_key(params).await?; if resp.user.is_none() || resp.org.is_some() { return Err(ApiKeyError::InvalidPersonalAPIKey); @@ -173,7 +206,10 @@ impl ApiKeyService<'_> { }) } - pub async fn validate_org_api_key(&self, params: ValidateApiKeyParams) -> Result { + pub async fn validate_org_api_key( + &self, + params: ValidateApiKeyParams, + ) -> Result { let resp = self.validate_api_key(params).await?; if resp.org.is_none() { return Err(ApiKeyError::InvalidOrgAPIKey); diff --git a/src/propelauth/auth.rs b/src/propelauth/auth.rs index 5621a2b..0f11800 100644 --- a/src/propelauth/auth.rs +++ b/src/propelauth/auth.rs @@ -3,6 +3,7 @@ use url::Url; use crate::apis::auth_service_api::token_verification_metadata; use crate::apis::configuration::Configuration; use crate::models::AuthTokenVerificationMetadata; +use crate::propelauth::access_token::AccessTokenService; use crate::propelauth::api_key::ApiKeyService; use crate::propelauth::errors::InitializationError; use crate::propelauth::helpers::map_autogenerated_error; @@ -10,7 +11,6 @@ use crate::propelauth::options::{AuthOptions, AuthOptionsWithTokenVerification}; use crate::propelauth::org::OrgService; use crate::propelauth::token::TokenService; use crate::propelauth::user::UserService; -use crate::propelauth::access_token::AccessTokenService; /// The main entrypoint of this library. /// All authentication, authorization and API requests starts from this struct @@ -57,6 +57,7 @@ impl PropelAuth { InitializationError::UnexpectedException, |status, _| match status.as_u16() { 401 => InitializationError::InvalidApiKey, + 429 => InitializationError::PropelAuthRateLimit, _ => InitializationError::UnexpectedException, }, ) diff --git a/src/propelauth/errors.rs b/src/propelauth/errors.rs index 02c4e6e..f5e8bad 100644 --- a/src/propelauth/errors.rs +++ b/src/propelauth/errors.rs @@ -14,6 +14,9 @@ pub enum InitializationError { #[error("Invalid API Key")] InvalidApiKey, + #[error("Rate limited by PropelAuth")] + PropelAuthRateLimit, + #[error("Unexpected exception, please try again")] UnexpectedException, } @@ -23,6 +26,9 @@ pub enum ErrorsWithNotFound { #[error("Invalid API Key")] InvalidApiKey, + #[error("Rate limited by PropelAuth")] + PropelAuthRateLimit, + #[error("Not found")] NotFound, @@ -35,6 +41,9 @@ pub enum BatchFetchError { #[error("Invalid API Key")] InvalidApiKey, + #[error("Rate limited by PropelAuth")] + PropelAuthRateLimit, + #[error("Bad request: {0}")] BadRequest(String), @@ -47,6 +56,9 @@ pub enum FetchByQueryError { #[error("Invalid API Key")] InvalidApiKey, + #[error("Rate limited by PropelAuth")] + PropelAuthRateLimit, + #[error("Bad request")] BadRequest(BadFetchUsersByQuery), @@ -59,6 +71,9 @@ pub enum CreateUserError { #[error("Invalid API Key")] InvalidApiKey, + #[error("Rate limited by PropelAuth")] + PropelAuthRateLimit, + #[error("Bad request")] BadRequest(BadCreateUserRequest), @@ -71,6 +86,9 @@ pub enum UpdateUserMetadataError { #[error("Invalid API Key")] InvalidApiKey, + #[error("Rate limited by PropelAuth")] + PropelAuthRateLimit, + #[error("Bad request")] BadRequest(BadUpdateUserMetadataRequest), @@ -122,6 +140,9 @@ pub enum UpdatePasswordError { #[error("Invalid API Key")] InvalidApiKey, + #[error("Rate limited by PropelAuth")] + PropelAuthRateLimit, + #[error("Bad request")] BadRequest(BadUpdatePasswordRequest), @@ -137,6 +158,9 @@ pub enum ClearPasswordError { #[error("Invalid API Key")] InvalidApiKey, + #[error("Rate limited by PropelAuth")] + PropelAuthRateLimit, + #[error("Not found")] NotFound, @@ -149,6 +173,9 @@ pub enum MigrateUserError { #[error("Invalid API Key")] InvalidApiKey, + #[error("Rate limited by PropelAuth")] + PropelAuthRateLimit, + #[error("Bad request")] BadRequest(BadMigrateUserRequest), @@ -161,6 +188,9 @@ pub enum CreateMagicLinkError { #[error("Invalid API Key")] InvalidApiKey, + #[error("Rate limited by PropelAuth")] + PropelAuthRateLimit, + #[error("Bad request")] BadRequest(BadCreateMagicLinkRequest), @@ -173,6 +203,9 @@ pub enum UpdateOrgError { #[error("Invalid API Key")] InvalidApiKey, + #[error("Rate limited by PropelAuth")] + PropelAuthRateLimit, + #[error("Not found")] NotFound, @@ -188,6 +221,9 @@ pub enum SubscribeOrgToRoleMappingError { #[error("Invalid API Key")] InvalidApiKey, + #[error("Rate limited by PropelAuth")] + PropelAuthRateLimit, + #[error("Not found")] NotFound, @@ -203,6 +239,9 @@ pub enum InviteUserToOrgError { #[error("Invalid API Key")] InvalidApiKey, + #[error("Rate limited by PropelAuth")] + PropelAuthRateLimit, + #[error("Not found")] NotFound, @@ -218,6 +257,9 @@ pub enum CreateOrgError { #[error("Invalid API Key")] InvalidApiKey, + #[error("Rate limited by PropelAuth")] + PropelAuthRateLimit, + #[error("Bad request")] BadRequest(BadCreateOrgRequest), @@ -230,6 +272,9 @@ pub enum OrgMissingOrRoleError { #[error("Invalid API Key")] InvalidApiKey, + #[error("Rate limited by PropelAuth")] + PropelAuthRateLimit, + #[error("Unknown role")] UnknownRoleError, @@ -245,6 +290,9 @@ pub enum FetchUsersInOrgError { #[error("Invalid API Key")] InvalidApiKey, + #[error("Rate limited by PropelAuth")] + PropelAuthRateLimit, + #[error("Bad request")] BadRequest(BadFetchUsersInOrgQuery), @@ -257,6 +305,9 @@ pub enum FetchOrgsByQueryError { #[error("Invalid API Key")] InvalidApiKey, + #[error("Rate limited by PropelAuth")] + PropelAuthRateLimit, + #[error("Bad request")] BadRequest(BadFetchOrgQuery), @@ -269,6 +320,9 @@ pub enum CreateAccessTokenError { #[error("Invalid API Key")] InvalidApiKey, + #[error("Rate limited by PropelAuth")] + PropelAuthRateLimit, + #[error("Unexpected exception, please try again")] UnexpectedException, diff --git a/src/propelauth/org.rs b/src/propelauth/org.rs index e54041e..ed31535 100644 --- a/src/propelauth/org.rs +++ b/src/propelauth/org.rs @@ -41,6 +41,7 @@ impl OrgService<'_> { ErrorsWithNotFound::UnexpectedException, |status_code, _| match status_code.as_u16() { 401 => ErrorsWithNotFound::InvalidApiKey, + 429 => ErrorsWithNotFound::PropelAuthRateLimit, 404 => ErrorsWithNotFound::NotFound, _ => ErrorsWithNotFound::UnexpectedException, }, @@ -67,6 +68,7 @@ impl OrgService<'_> { )), ) => FetchOrgsByQueryError::BadRequest(bad_request), (401, _) => FetchOrgsByQueryError::InvalidApiKey, + (429, _) => FetchOrgsByQueryError::PropelAuthRateLimit, _ => FetchOrgsByQueryError::UnexpectedException, }, ) @@ -96,6 +98,7 @@ impl OrgService<'_> { )), ) => FetchUsersInOrgError::BadRequest(bad_request), (401, _) => FetchUsersInOrgError::InvalidApiKey, + (429, _) => FetchUsersInOrgError::PropelAuthRateLimit, _ => FetchUsersInOrgError::UnexpectedException, }, ) @@ -114,6 +117,7 @@ impl OrgService<'_> { ErrorsWithNotFound::UnexpectedException, |status_code, _| match status_code.as_u16() { 401 => ErrorsWithNotFound::InvalidApiKey, + 429 => ErrorsWithNotFound::PropelAuthRateLimit, 404 => ErrorsWithNotFound::NotFound, _ => ErrorsWithNotFound::UnexpectedException, }, @@ -133,6 +137,7 @@ impl OrgService<'_> { ErrorsWithNotFound::UnexpectedException, |status_code, _| match status_code.as_u16() { 401 => ErrorsWithNotFound::InvalidApiKey, + 429 => ErrorsWithNotFound::PropelAuthRateLimit, 404 => ErrorsWithNotFound::NotFound, _ => ErrorsWithNotFound::UnexpectedException, }, @@ -156,6 +161,7 @@ impl OrgService<'_> { |status_code, _| match status_code.as_u16() { 400 => OrgMissingOrRoleError::UnknownRoleError, 401 => OrgMissingOrRoleError::InvalidApiKey, + 429 => OrgMissingOrRoleError::PropelAuthRateLimit, 404 => OrgMissingOrRoleError::NotFound, _ => OrgMissingOrRoleError::UnexpectedException, }, @@ -180,6 +186,7 @@ impl OrgService<'_> { |status_code, _| match status_code.as_u16() { 400 => OrgMissingOrRoleError::UnknownRoleError, 401 => OrgMissingOrRoleError::InvalidApiKey, + 429 => OrgMissingOrRoleError::PropelAuthRateLimit, 404 => OrgMissingOrRoleError::NotFound, _ => OrgMissingOrRoleError::UnexpectedException, }, @@ -203,6 +210,7 @@ impl OrgService<'_> { ErrorsWithNotFound::UnexpectedException, |status_code, _| match status_code.as_u16() { 401 => ErrorsWithNotFound::InvalidApiKey, + 429 => ErrorsWithNotFound::PropelAuthRateLimit, 404 => ErrorsWithNotFound::NotFound, _ => ErrorsWithNotFound::UnexpectedException, }, @@ -230,6 +238,7 @@ impl OrgService<'_> { )), ) => CreateOrgError::BadRequest(bad_request), (401, _) => CreateOrgError::InvalidApiKey, + (429, _) => CreateOrgError::PropelAuthRateLimit, _ => CreateOrgError::UnexpectedException, }, ) @@ -264,6 +273,7 @@ impl OrgService<'_> { )), ) => UpdateOrgError::BadRequest(bad_request), (401, _) => UpdateOrgError::InvalidApiKey, + (429, _) => UpdateOrgError::PropelAuthRateLimit, (404, _) => UpdateOrgError::NotFound, _ => UpdateOrgError::UnexpectedException, }, @@ -301,6 +311,7 @@ impl OrgService<'_> { )), ) => SubscribeOrgToRoleMappingError::BadRequest(bad_request), (401, _) => SubscribeOrgToRoleMappingError::InvalidApiKey, + (429, _) => SubscribeOrgToRoleMappingError::PropelAuthRateLimit, (404, _) => SubscribeOrgToRoleMappingError::NotFound, _ => SubscribeOrgToRoleMappingError::UnexpectedException, }, @@ -325,6 +336,7 @@ impl OrgService<'_> { ErrorsWithNotFound::UnexpectedException, |status_code, _| match status_code.as_u16() { 401 => ErrorsWithNotFound::InvalidApiKey, + 429 => ErrorsWithNotFound::PropelAuthRateLimit, 404 => ErrorsWithNotFound::NotFound, _ => ErrorsWithNotFound::UnexpectedException, }, @@ -349,6 +361,7 @@ impl OrgService<'_> { ErrorsWithNotFound::UnexpectedException, |status_code, _| match status_code.as_u16() { 401 => ErrorsWithNotFound::InvalidApiKey, + 429 => ErrorsWithNotFound::PropelAuthRateLimit, 404 => ErrorsWithNotFound::NotFound, _ => ErrorsWithNotFound::UnexpectedException, }, @@ -373,6 +386,7 @@ impl OrgService<'_> { ErrorsWithNotFound::UnexpectedException, |status_code, _| match status_code.as_u16() { 401 => ErrorsWithNotFound::InvalidApiKey, + 429 => ErrorsWithNotFound::PropelAuthRateLimit, 404 => ErrorsWithNotFound::NotFound, _ => ErrorsWithNotFound::UnexpectedException, }, @@ -396,6 +410,7 @@ impl OrgService<'_> { ErrorsWithNotFound::UnexpectedException, |status_code, _| match status_code.as_u16() { 401 => ErrorsWithNotFound::InvalidApiKey, + 429 => ErrorsWithNotFound::PropelAuthRateLimit, 404 => ErrorsWithNotFound::NotFound, _ => ErrorsWithNotFound::UnexpectedException, }, @@ -419,6 +434,7 @@ impl OrgService<'_> { ErrorsWithNotFound::UnexpectedException, |status_code, _| match status_code.as_u16() { 401 => ErrorsWithNotFound::InvalidApiKey, + 429 => ErrorsWithNotFound::PropelAuthRateLimit, 404 => ErrorsWithNotFound::NotFound, _ => ErrorsWithNotFound::UnexpectedException, }, @@ -440,6 +456,7 @@ impl OrgService<'_> { ErrorsWithNotFound::UnexpectedException, |status_code, _| match status_code.as_u16() { 401 => ErrorsWithNotFound::InvalidApiKey, + 429 => ErrorsWithNotFound::PropelAuthRateLimit, 404 => ErrorsWithNotFound::NotFound, _ => ErrorsWithNotFound::UnexpectedException, }, @@ -461,6 +478,7 @@ impl OrgService<'_> { ErrorsWithNotFound::UnexpectedException, |status_code, _| match status_code.as_u16() { 401 => ErrorsWithNotFound::InvalidApiKey, + 429 => ErrorsWithNotFound::PropelAuthRateLimit, 404 => ErrorsWithNotFound::NotFound, _ => ErrorsWithNotFound::UnexpectedException, }, @@ -484,6 +502,7 @@ impl OrgService<'_> { ErrorsWithNotFound::UnexpectedException, |status_code, _| match status_code.as_u16() { 401 => ErrorsWithNotFound::InvalidApiKey, + 429 => ErrorsWithNotFound::PropelAuthRateLimit, 404 => ErrorsWithNotFound::NotFound, _ => ErrorsWithNotFound::UnexpectedException, }, @@ -515,6 +534,7 @@ impl OrgService<'_> { )), ) => InviteUserToOrgError::BadRequest(bad_request), (401, _) => InviteUserToOrgError::InvalidApiKey, + (429, _) => InviteUserToOrgError::PropelAuthRateLimit, (404, _) => InviteUserToOrgError::NotFound, _ => InviteUserToOrgError::UnexpectedException, }, @@ -538,6 +558,7 @@ impl OrgService<'_> { ErrorsWithNotFound::UnexpectedException, |status_code, _| match status_code.as_u16() { 401 => ErrorsWithNotFound::InvalidApiKey, + 429 => ErrorsWithNotFound::PropelAuthRateLimit, 404 => ErrorsWithNotFound::NotFound, _ => ErrorsWithNotFound::UnexpectedException, }, diff --git a/src/propelauth/user.rs b/src/propelauth/user.rs index 2338dce..577d77b 100644 --- a/src/propelauth/user.rs +++ b/src/propelauth/user.rs @@ -36,6 +36,7 @@ impl UserService<'_> { ErrorsWithNotFound::UnexpectedException, |status_code, _| match status_code.as_u16() { 401 => ErrorsWithNotFound::InvalidApiKey, + 429 => ErrorsWithNotFound::PropelAuthRateLimit, 404 => ErrorsWithNotFound::NotFound, _ => ErrorsWithNotFound::UnexpectedException, }, @@ -59,6 +60,7 @@ impl UserService<'_> { ErrorsWithNotFound::UnexpectedException, |status_code, _| match status_code.as_u16() { 401 => ErrorsWithNotFound::InvalidApiKey, + 429 => ErrorsWithNotFound::PropelAuthRateLimit, 404 => ErrorsWithNotFound::NotFound, _ => ErrorsWithNotFound::UnexpectedException, }, @@ -78,6 +80,7 @@ impl UserService<'_> { ErrorsWithNotFound::UnexpectedException, |status_code, _| match status_code.as_u16() { 401 => ErrorsWithNotFound::InvalidApiKey, + 429 => ErrorsWithNotFound::PropelAuthRateLimit, 404 => ErrorsWithNotFound::NotFound, _ => ErrorsWithNotFound::UnexpectedException, }, @@ -107,6 +110,7 @@ impl UserService<'_> { } } (401, _) => BatchFetchError::InvalidApiKey, + (429, _) => BatchFetchError::PropelAuthRateLimit, _ => BatchFetchError::UnexpectedException, }, ) @@ -139,6 +143,7 @@ impl UserService<'_> { } } (401, _) => BatchFetchError::InvalidApiKey, + (429, _) => BatchFetchError::PropelAuthRateLimit, _ => BatchFetchError::UnexpectedException, }, ) @@ -171,6 +176,7 @@ impl UserService<'_> { } } (401, _) => BatchFetchError::InvalidApiKey, + (429, _) => BatchFetchError::PropelAuthRateLimit, _ => BatchFetchError::UnexpectedException, }, ) @@ -197,6 +203,7 @@ impl UserService<'_> { FetchByQueryError::BadRequest(bad_request) } (401, _) => FetchByQueryError::InvalidApiKey, + (429, _) => FetchByQueryError::PropelAuthRateLimit, _ => FetchByQueryError::UnexpectedException, }, ) @@ -224,6 +231,7 @@ impl UserService<'_> { )), ) => CreateUserError::BadRequest(bad_request), (401, _) => CreateUserError::InvalidApiKey, + (429, _) => CreateUserError::PropelAuthRateLimit, _ => CreateUserError::UnexpectedException, }, ) @@ -244,6 +252,7 @@ impl UserService<'_> { ErrorsWithNotFound::UnexpectedException, |status_code, _| match status_code.as_u16() { 401 => ErrorsWithNotFound::InvalidApiKey, + 429 => ErrorsWithNotFound::PropelAuthRateLimit, 404 => ErrorsWithNotFound::NotFound, _ => ErrorsWithNotFound::UnexpectedException, }, @@ -266,6 +275,7 @@ impl UserService<'_> { ErrorsWithNotFound::UnexpectedException, |status_code, _| match status_code.as_u16() { 401 => ErrorsWithNotFound::InvalidApiKey, + 429 => ErrorsWithNotFound::PropelAuthRateLimit, 404 => ErrorsWithNotFound::NotFound, _ => ErrorsWithNotFound::UnexpectedException, }, @@ -290,6 +300,7 @@ impl UserService<'_> { ErrorsWithNotFound::UnexpectedException, |status_code, _| match status_code.as_u16() { 401 => ErrorsWithNotFound::InvalidApiKey, + 429 => ErrorsWithNotFound::PropelAuthRateLimit, 404 => ErrorsWithNotFound::NotFound, _ => ErrorsWithNotFound::UnexpectedException, }, @@ -312,6 +323,7 @@ impl UserService<'_> { ErrorsWithNotFound::UnexpectedException, |status_code, _| match status_code.as_u16() { 401 => ErrorsWithNotFound::InvalidApiKey, + 429 => ErrorsWithNotFound::PropelAuthRateLimit, 404 => ErrorsWithNotFound::NotFound, _ => ErrorsWithNotFound::UnexpectedException, }, @@ -344,6 +356,7 @@ impl UserService<'_> { ), ) => UpdateUserMetadataError::BadRequest(bad_request), (401, _) => UpdateUserMetadataError::InvalidApiKey, + (429, _) => UpdateUserMetadataError::PropelAuthRateLimit, (404, _) => UpdateUserMetadataError::NotFound, _ => UpdateUserMetadataError::UnexpectedException, }, @@ -407,6 +420,7 @@ impl UserService<'_> { ), ) => UpdatePasswordError::BadRequest(bad_request), (401, _) => UpdatePasswordError::InvalidApiKey, + (429, _) => UpdatePasswordError::PropelAuthRateLimit, (404, _) => UpdatePasswordError::NotFound, _ => UpdatePasswordError::UnexpectedException, }, @@ -428,6 +442,7 @@ impl UserService<'_> { ClearPasswordError::UnexpectedException, |status_code, _| match status_code.as_u16() { 401 => ClearPasswordError::InvalidApiKey, + 429 => ClearPasswordError::PropelAuthRateLimit, 404 => ClearPasswordError::NotFound, _ => ClearPasswordError::UnexpectedException, }, @@ -450,6 +465,7 @@ impl UserService<'_> { ErrorsWithNotFound::UnexpectedException, |status_code, _| match status_code.as_u16() { 401 => ErrorsWithNotFound::InvalidApiKey, + 429 => ErrorsWithNotFound::PropelAuthRateLimit, 404 => ErrorsWithNotFound::NotFound, _ => ErrorsWithNotFound::UnexpectedException, }, @@ -520,6 +536,7 @@ impl UserService<'_> { )), ) => MigrateUserError::BadRequest(bad_request), (401, _) => MigrateUserError::InvalidApiKey, + (429, _) => MigrateUserError::PropelAuthRateLimit, _ => MigrateUserError::UnexpectedException, }, ) @@ -547,6 +564,7 @@ impl UserService<'_> { )), ) => CreateMagicLinkError::BadRequest(bad_request), (401, _) => CreateMagicLinkError::InvalidApiKey, + (429, _) => CreateMagicLinkError::PropelAuthRateLimit, _ => CreateMagicLinkError::UnexpectedException, }, ) @@ -569,6 +587,7 @@ impl UserService<'_> { ErrorsWithNotFound::UnexpectedException, |status_code, _| match status_code.as_u16() { 401 => ErrorsWithNotFound::InvalidApiKey, + 429 => ErrorsWithNotFound::PropelAuthRateLimit, 404 => ErrorsWithNotFound::NotFound, _ => ErrorsWithNotFound::UnexpectedException, }, @@ -593,6 +612,7 @@ impl UserService<'_> { ErrorsWithNotFound::UnexpectedException, |status_code, _| match status_code.as_u16() { 401 => ErrorsWithNotFound::InvalidApiKey, + 429 => ErrorsWithNotFound::PropelAuthRateLimit, 404 => ErrorsWithNotFound::NotFound, _ => ErrorsWithNotFound::UnexpectedException, }, From 2d74ed6513f4b982a4ebe78585beb43223f52226 Mon Sep 17 00:00:00 2001 From: Matthew Mauer Date: Wed, 12 Feb 2025 12:24:58 -0500 Subject: [PATCH 2/2] bump minor version to 0.22.0 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index d40cb96..8da8df3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "propelauth" -version = "0.21.0" +version = "0.22.0" authors = ["support@propelauth.com"] description = "A Rust crate for managing authentication and authorization with support for multi-tenant / B2B products, powered by PropelAuth" keywords = ["authentication", "auth", "authorization", "b2b", "tenant"]