Skip to content

auth

appimage_updater.repositories.auth

Dynamic authentication system for different Git forges.

CodebergForgeAuth(user_agent)

Codeberg authentication - typically no auth needed for public repos.

Source code in src/appimage_updater/repositories/auth.py
def __init__(self, user_agent: str) -> None:
    super().__init__(user_agent)
    self.token = self._discover_codeberg_token()

token = self._discover_codeberg_token() instance-attribute

get_auth_headers()

Get Codeberg authentication headers.

Source code in src/appimage_updater/repositories/auth.py
def get_auth_headers(self) -> dict[str, str]:
    """Get Codeberg authentication headers."""
    headers = {"User-Agent": self.user_agent}
    if self.token:
        # Gitea/Forgejo uses Authorization header with token
        headers["Authorization"] = f"token {self.token}"
    return headers

is_authenticated()

Check if Codeberg authentication is available.

Source code in src/appimage_updater/repositories/auth.py
def is_authenticated(self) -> bool:
    """Check if Codeberg authentication is available."""
    return self.token is not None

DynamicForgeAuth(user_agent)

Dynamic authentication manager that selects appropriate auth based on URL.

Source code in src/appimage_updater/repositories/auth.py
def __init__(self, user_agent: str) -> None:
    self.user_agent = user_agent
    self._auth_cache: dict[str, ForgeAuth] = {}

user_agent = user_agent instance-attribute

get_auth_for_url(url)

Get appropriate authentication for a given URL.

Source code in src/appimage_updater/repositories/auth.py
def get_auth_for_url(self, url: str) -> ForgeAuth:
    """Get appropriate authentication for a given URL."""
    domain = self._extract_domain(url)

    if domain in self._auth_cache:
        return self._auth_cache[domain]

    # Determine forge type and create appropriate auth
    auth = self._create_auth_for_domain(domain)
    self._auth_cache[domain] = auth
    return auth

ForgeAuth(user_agent)

Base class for forge authentication.

Source code in src/appimage_updater/repositories/auth.py
def __init__(self, user_agent: str) -> None:
    self.user_agent = user_agent

user_agent = user_agent instance-attribute

get_auth_headers()

Get authentication headers for API requests.

Source code in src/appimage_updater/repositories/auth.py
def get_auth_headers(self) -> dict[str, str]:
    """Get authentication headers for API requests."""
    return {"User-Agent": self.user_agent}

is_authenticated()

Check if authentication is available.

Source code in src/appimage_updater/repositories/auth.py
def is_authenticated(self) -> bool:
    """Check if authentication is available."""
    return False

GitHubForgeAuth(user_agent)

GitHub authentication using existing GitHub auth system.

Source code in src/appimage_updater/repositories/auth.py
def __init__(self, user_agent: str) -> None:
    super().__init__(user_agent)
    # Import here to avoid circular imports
    from .github.auth import get_github_auth  # noqa: PLC0415

    self.github_auth = get_github_auth()

github_auth = get_github_auth() instance-attribute

get_auth_headers()

Get GitHub authentication headers.

Source code in src/appimage_updater/repositories/auth.py
def get_auth_headers(self) -> dict[str, str]:
    """Get GitHub authentication headers."""
    return self.github_auth.get_auth_headers()

is_authenticated()

Check if GitHub authentication is available.

Source code in src/appimage_updater/repositories/auth.py
def is_authenticated(self) -> bool:
    """Check if GitHub authentication is available."""
    return self.github_auth.is_authenticated

GitLabForgeAuth(user_agent)

GitLab authentication using token from environment.

Source code in src/appimage_updater/repositories/auth.py
def __init__(self, user_agent: str) -> None:
    super().__init__(user_agent)
    self.token = self._discover_gitlab_token()

token = self._discover_gitlab_token() instance-attribute

get_auth_headers()

Get GitLab authentication headers.

Source code in src/appimage_updater/repositories/auth.py
def get_auth_headers(self) -> dict[str, str]:
    """Get GitLab authentication headers."""
    headers = {"User-Agent": self.user_agent}
    if self.token:
        headers["PRIVATE-TOKEN"] = self.token
    return headers

is_authenticated()

Check if GitLab authentication is available.

Source code in src/appimage_updater/repositories/auth.py
def is_authenticated(self) -> bool:
    """Check if GitLab authentication is available."""
    return self.token is not None