Skip to content

auth

appimage_updater.repositories.gitlab.auth

GitLab authentication handling for AppImage Updater.

This module provides GitLab authentication using personal access tokens, supporting both environment variable configuration and explicit token passing.

GitLabAuth(token=None)

GitLab authentication handler using personal access tokens.

Supports authentication via: - Explicit token parameter - GITLAB_TOKEN environment variable - GITLAB_PRIVATE_TOKEN environment variable (alternative)

Parameters:

Name Type Description Default
token str | None

Explicit GitLab personal access token. If None, will attempt to load from environment variables.

None
Source code in src/appimage_updater/repositories/gitlab/auth.py
def __init__(self, token: str | None = None) -> None:
    """Initialize GitLab authentication.

    Args:
        token: Explicit GitLab personal access token. If None, will attempt
              to load from environment variables.
    """
    self._token = token or self._load_token_from_env()

    if self._token:
        logger.debug("GitLab authentication configured with personal access token")
    else:
        logger.debug("No GitLab authentication token found")

get_headers()

Get authentication headers for GitLab API requests.

Returns:

Type Description
dict[str, str]

Dictionary containing PRIVATE-TOKEN header if authenticated,

dict[str, str]

empty dictionary if no token available

Source code in src/appimage_updater/repositories/gitlab/auth.py
def get_headers(self) -> dict[str, str]:
    """Get authentication headers for GitLab API requests.

    Returns:
        Dictionary containing PRIVATE-TOKEN header if authenticated,
        empty dictionary if no token available
    """
    if not self._token:
        return {}

    return {"PRIVATE-TOKEN": self._token}

is_authenticated()

Check if authentication is available.

Returns:

Type Description
bool

True if a valid token is configured, False otherwise

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

    Returns:
        True if a valid token is configured, False otherwise
    """
    return bool(self._token)