# -*- coding: utf-8 -*- 
"""
Django App Configuration for Authentication Module.

This module handles comprehensive authentication and authorization systems
including login, logout, password management, and security features.
It provides secure authentication mechanisms and user session management.

Features:
- Multi-factor authentication (MFA)
- Social authentication integration
- Password reset and recovery
- Session management and security
- OAuth and JWT token handling
- Security monitoring and logging

Author: Adtlas Development Team
Version: 1.0.0
"""

from django.apps import AppConfig
from django.utils.translation import gettext_lazy as _


class AuthenticationConfig(AppConfig):
    """
    Django application configuration for the Authentication app.
    
    This configuration class defines the settings and metadata for the authentication
    application, including database field configurations, application naming,
    and initialization hooks for security and authentication systems.
    
    Attributes:
        default_auto_field (str): The default primary key field type for models
        name (str): The full Python path to the application
        verbose_name (str): Human-readable name for the application
        label (str): Short name for the application (used in migrations)
    """
    
    # Database configuration
    default_auto_field = "django.db.models.BigAutoField"
    
    # Application identification
    name = "apps.authentication"
    verbose_name = _("Authentication & Security")
    label = "authentication"
    
    def ready(self):
        """
        Initialize the application when Django starts.
        
        This method is called when the application is ready and all models
        have been imported. It's used to register signal handlers for
        authentication events and security monitoring.
        """
        try:
            # Import signal handlers for authentication events
            from . import signals  # noqa: F401

            # Import and register custom checks
            from . import checks  # noqa: F401
            
            # Initialize logging configuration
            self._setup_logging()
            
            # Setup authentication backends
            self._setup_authentication()

        except ImportError:
            # Signals module doesn't exist yet
            pass

    def _setup_logging(self):
        """Setup application-specific logging configuration.
        
        This method can be used to set up custom logging configuration for the
        auth app. It"s especially useful when customizing log levels,
        handlers, or formats.
        """
        import logging
        
        logger = logging.getLogger("adtlas.auth")
        logger.info("Auth app initialized successfully")    
    
    def _setup_authentication(self):
        """Setup authentication-specific configurations.
        
        This method can be used to set up custom authentication backends,
        custom user models, or any other authentication-related configurations.
        """
        # Any authentication setup can be done here
        pass