4141def archivist_job (
4242 storage_type : str ,
4343 storage_url : str ,
44+ storage_username : str ,
45+ storage_password : str ,
4446 storage_db_name : str ,
4547 storage_verify_certs : bool ,
4648 redis_group : str ,
@@ -56,6 +58,8 @@ def archivist_job(
5658
5759 :param storage_type: type of the storage system (e.g., 'opensearch')
5860 :param storage_url: URL of the storage system
61+ :param storage_username: Username to use when authentication is required
62+ :param storage_password: Password to use when authentication is required
5963 :param storage_db_name: Name of the database to use
6064 :param storage_verify_certs: Verify certificates when connecting to the storage system
6165 :param redis_group: Redis group name to use for fetching events
@@ -77,6 +81,8 @@ def archivist_job(
7781
7882 Storage = get_storage_backend (storage_type )
7983 storage = Storage (url = storage_url ,
84+ user = storage_username ,
85+ password = storage_password ,
8086 db_name = storage_db_name ,
8187 verify_certs = storage_verify_certs )
8288 events = events_consumer (rq_job .connection ,
@@ -272,8 +278,17 @@ class StorageBackend:
272278
273279 :param url: URL of the storage backend
274280 """
275- def __init__ (self , url : str , db_name : str , verify_certs : bool = False ) -> None :
281+ def __init__ (
282+ self ,
283+ url : str ,
284+ db_name : str ,
285+ user : str | None = None ,
286+ password : str | None = None ,
287+ verify_certs : bool = False
288+ ) -> None :
276289 self .url = url
290+ self .user = user
291+ self .password = password
277292 self .db_name = db_name
278293 self .verify_certs = verify_certs
279294
@@ -361,13 +376,24 @@ class OpenSearchStorage(StorageBackend):
361376 }
362377 }
363378
364- def __init__ (self , url : str , db_name : str , verify_certs : bool = False ) -> None :
365- super ().__init__ (url , db_name , verify_certs )
379+ def __init__ (
380+ self ,
381+ url : str ,
382+ db_name : str ,
383+ user : str | None = None ,
384+ password : str | None = None ,
385+ verify_certs : bool = False
386+ ) -> None :
387+ super ().__init__ (url = url , db_name = db_name , user = user , password = password , verify_certs = verify_certs )
366388
367389 if not verify_certs :
368390 urllib3 .disable_warnings (urllib3 .exceptions .InsecureRequestWarning )
369391
370- self .client = OpenSearch ([url ], verify_certs = self .verify_certs )
392+ auth = None
393+ if user and password :
394+ auth = (user , password )
395+
396+ self .client = OpenSearch ([url ], http_auth = auth , verify_certs = self .verify_certs )
371397 self ._create_index (db_name )
372398 self .max_items_bulk = 100
373399
0 commit comments