Source code for ace.centralize.rest_api.auth_service

import os
from ace.config import settings


[docs] class CentralizeAuth: """ Centralize API Service Type : Bearer Token """
[docs] def __init__(self): self.api_key = settings.CENTRALIZE_API_KEY
[docs] def authenticate(self, headers: dict): headers["X-API-KEY"] = self.api_key return headers
[docs] def authenticate_on_behalf_of(self, headers: dict, user_id: str): headers["X-On-Behalf-Of"] = f"Centralize={user_id}" return self.authenticate(headers)
centralized_auth = CentralizeAuth()