patch
This commit is contained in:
		
							parent
							
								
									b0250a47aa
								
							
						
					
					
						commit
						93387d0677
					
				@ -3,11 +3,12 @@ from uuid import UUID
 | 
			
		||||
from fastapi import HTTPException, status
 | 
			
		||||
from typing import List, Dict
 | 
			
		||||
from config import settings
 | 
			
		||||
from .utils import ssl_transport
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
async def get_profile_by_user_id(user_id: UUID, token: str) -> dict:
 | 
			
		||||
    try:
 | 
			
		||||
        async with httpx.AsyncClient(timeout=5.0, verify=False) as client:
 | 
			
		||||
        async with httpx.AsyncClient(transport=ssl_transport, timeout=5.0,) as client:
 | 
			
		||||
            response = await client.get(
 | 
			
		||||
                f"{settings.PROFILE_SERVICE}/user_id/{user_id}",
 | 
			
		||||
                headers={"Authorization": f"Bearer {token}"}
 | 
			
		||||
@ -27,7 +28,7 @@ async def get_profile_by_user_id(user_id: UUID, token: str) -> dict:
 | 
			
		||||
 | 
			
		||||
async def get_profiles_by_user_ids(user_ids: List[UUID], token: str, user_id: UUID) -> Dict[str, dict]:
 | 
			
		||||
    try:
 | 
			
		||||
        async with httpx.AsyncClient(timeout=5.0, verify=False) as client:
 | 
			
		||||
        async with httpx.AsyncClient(transport=ssl_transport, timeout=5.0,) as client:
 | 
			
		||||
            response = await client.post(
 | 
			
		||||
                f"{settings.PROFILE_SERVICE}/user_ids/internal",
 | 
			
		||||
                headers={"Authorization": f"Bearer {token}"},
 | 
			
		||||
 | 
			
		||||
@ -1,3 +1,4 @@
 | 
			
		||||
from .utils import get_datetime
 | 
			
		||||
from .utils import ssl_transport
 | 
			
		||||
 | 
			
		||||
__all__ = ["get_datetime"]
 | 
			
		||||
__all__ = ["get_datetime", "ssl_transport"]
 | 
			
		||||
 | 
			
		||||
@ -6,6 +6,7 @@ from typing import List
 | 
			
		||||
 | 
			
		||||
from dataclasses import dataclass
 | 
			
		||||
from config import settings
 | 
			
		||||
from .utils import ssl_transport
 | 
			
		||||
 | 
			
		||||
auth_scheme = HTTPBearer()
 | 
			
		||||
 | 
			
		||||
@ -27,11 +28,7 @@ async def _fetch_current_user(
 | 
			
		||||
    user_agent = request.headers.get("User-Agent", "(unknown)")
 | 
			
		||||
 | 
			
		||||
    try:
 | 
			
		||||
        async with httpx.AsyncClient(
 | 
			
		||||
            verify=settings.CA_CERT,
 | 
			
		||||
            cert=(settings.CLIENT_FULLCHAIN, settings.CLIENT_PRIVKEY),
 | 
			
		||||
            timeout=5.0
 | 
			
		||||
        ) as client:
 | 
			
		||||
        async with httpx.AsyncClient(transport=ssl_transport, timeout=5.0,) as client:
 | 
			
		||||
            response = await client.post(
 | 
			
		||||
                f"{settings.TOKEN_SERVICE}/decode",
 | 
			
		||||
                json={
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										8
									
								
								common_lib/utils/ssl_transport.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								common_lib/utils/ssl_transport.py
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,8 @@
 | 
			
		||||
import ssl
 | 
			
		||||
import httpx
 | 
			
		||||
from config import settings
 | 
			
		||||
 | 
			
		||||
ctx = ssl.create_default_context(cafile=settings.CA_CERT)
 | 
			
		||||
ctx.load_cert_chain(certfile=settings.CLIENT_FULLCHAIN, keyfile=settings.CLIENT_PRIVKEY)
 | 
			
		||||
 | 
			
		||||
ssl_transport = httpx.AsyncHTTPTransport(verify=ctx, http2=True)
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user