mirror of
				https://github.com/juspay/hyperswitch.git
				synced 2025-11-01 02:57:02 +08:00 
			
		
		
		
	feat(auth): Add Authorization for JWT Authentication types (#2973)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
		| @ -2,7 +2,7 @@ use actix_multipart::Multipart; | ||||
| use actix_web::{web, HttpRequest, HttpResponse}; | ||||
| use router_env::{instrument, tracing, Flow}; | ||||
|  | ||||
| use crate::core::api_locking; | ||||
| use crate::{core::api_locking, services::authorization::permissions::Permission}; | ||||
| pub mod transformers; | ||||
|  | ||||
| use super::app::AppState; | ||||
| @ -45,7 +45,11 @@ pub async fn files_create( | ||||
|         &req, | ||||
|         create_file_request, | ||||
|         |state, auth, req| files_create_core(state, auth.merchant_account, auth.key_store, req), | ||||
|         auth::auth_type(&auth::ApiKeyAuth, &auth::JWTAuth, req.headers()), | ||||
|         auth::auth_type( | ||||
|             &auth::ApiKeyAuth, | ||||
|             &auth::JWTAuth(Permission::FileWrite), | ||||
|             req.headers(), | ||||
|         ), | ||||
|         api_locking::LockAction::NotApplicable, | ||||
|     )) | ||||
|     .await | ||||
| @ -83,7 +87,11 @@ pub async fn files_delete( | ||||
|         &req, | ||||
|         file_id, | ||||
|         |state, auth, req| files_delete_core(state, auth.merchant_account, req), | ||||
|         auth::auth_type(&auth::ApiKeyAuth, &auth::JWTAuth, req.headers()), | ||||
|         auth::auth_type( | ||||
|             &auth::ApiKeyAuth, | ||||
|             &auth::JWTAuth(Permission::FileWrite), | ||||
|             req.headers(), | ||||
|         ), | ||||
|         api_locking::LockAction::NotApplicable, | ||||
|     )) | ||||
|     .await | ||||
| @ -121,7 +129,11 @@ pub async fn files_retrieve( | ||||
|         &req, | ||||
|         file_id, | ||||
|         |state, auth, req| files_retrieve_core(state, auth.merchant_account, auth.key_store, req), | ||||
|         auth::auth_type(&auth::ApiKeyAuth, &auth::JWTAuth, req.headers()), | ||||
|         auth::auth_type( | ||||
|             &auth::ApiKeyAuth, | ||||
|             &auth::JWTAuth(Permission::FileRead), | ||||
|             req.headers(), | ||||
|         ), | ||||
|         api_locking::LockAction::NotApplicable, | ||||
|     )) | ||||
|     .await | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Mani Chandra
					Mani Chandra