ó
    åÑqi£  ã                   ó^   • S r SSKJr  SSKJr  Sr\R                  " \5      r " S S\5      r	g)aÝ  
Implementation of a domain controller that uses realm/user_name/password mappings
from the configuration file and uses the share path as realm name.

user_mapping is defined a follows::

    simple_dc: {
        user_mapping = {
            "realm1": {
                "John Smith": {
                    "password": "YouNeverGuessMe",
                },
                "Dan Brown": {
                    "password": "DontGuessMeEither",
                    "roles": ["editor"]
                }
            },
            "realm2": {
                ...
            }
        },
    }

The "*" pseudo-share is used to pass a default definition::

    user_mapping = {
        "*": {  // every share except for 'realm2'
            "Dan Brown": {
                "password": "DontGuessMeEither",
                "roles": ["editor"]
            }
        },
        "realm2": {
            ...
        }
    },

A share (even the "*" pseudo-share) can be set to True to allow anonymous access::

    user_mapping = {
        "*": {
            "Dan Brown": {
                "password": "DontGuessMeEither",
                "roles": ["editor"]
            },
        },
        "realm2": True
    },

The SimpleDomainController fulfills the requirements of a DomainController as
used for authentication with http_authenticator.HTTPAuthenticator for the
WsgiDAV application.

Domain Controllers must provide the methods as described in
DomainControllerBase_

.. _DomainControllerBase : dc/base_dc.py

é    )Úutil)ÚBaseDomainControllerÚreStructuredTextc                   óV   ^ • \ rS rSrU 4S jrS rSS jrS rS rS r	S r
S	 rS
rU =r$ )ÚSimpleDomainControlleréH   c                 óR  >• [         TU ]  X5        [        R                  " USSS9nUR	                  S5      U l        U R
                  c  [        S5      eU R
                  R                  5        H5  u  pE[        U5      [        [        4;  d	  U(       a  M'  [        SU< S35      e   g )NÚ	simple_dcT)Úas_dictÚuser_mappingz&Missing option: simple_dc.user_mappingz'Invalid option: simple_dc.user_mapping[z"]: must be True or non-empty dict.)ÚsuperÚ__init__r   Úget_dict_valueÚgetÚuser_mapÚRuntimeErrorÚitemsÚtypeÚboolÚdict)ÚselfÚwsgidav_appÚconfigÚdc_confÚshareÚdataÚ	__class__s         €ÚI/home/kali/flask_env/lib/python3.13/site-packages/wsgidav/dc/simple_dc.pyr   ÚSimpleDomainController.__init__I   s–   ø€ Ü‰Ñ˜Ô-ä×%Ò% f¨kÀ4ÑHˆàŸ™ NÓ3ˆŒØ=‰=Ñ ÜÐGÓHÐHàŸ=™=×.Ñ.Ö0‰KˆEÜD‹z¤$¬ Ó-·T°TÜ"Ø=¸e¹YÐFhÐióð ñ 1ð
 	ó    c                 ó4   • U R                   R                   S3$ )Nz())r   Ú__name__©r   s    r   Ú__str__ÚSimpleDomainController.__str__Y   s   € Ø—.‘.×)Ñ)Ð*¨"Ð-Ð-r    c                 ó¦   • U R                   R                  U5      nUc  U R                   R                  S5      nUb  Uc  U$ UR                  U5      $ )zHReturn the matching user_map entry (falling back to default '*' if any).Ú*)r   r   )r   ÚrealmÚ	user_nameÚrealm_entrys       r   Ú_get_realm_entryÚ'SimpleDomainController._get_realm_entry\   sP   € à—m‘m×'Ñ'¨Ó.ˆØÑØŸ-™-×+Ñ+¨CÓ0ˆKØÑ Ñ 3ØÐØ‰˜yÓ)Ð)r    c                 ó(   • U R                  X5      nU$ )z5Resolve a relative url to the appropriate realm name.)Ú_calc_realm_from_path_provider)r   Ú	path_infoÚenvironr(   s       r   Úget_domain_realmÚ'SimpleDomainController.get_domain_realme   s   € à×3Ñ3°IÓGˆØˆr    c                 ód   • U R                  U5      nUc  [        R                  SU S35        USL$ )zUReturn True if this realm requires authentication (grant anonymous access otherwise).z.Missing configuration simple_dc.user_mapping["z%"] (or "*"): realm is not accessible!T)r+   Ú_loggerÚerror)r   r(   r0   r*   s       r   Úrequire_authenticationÚ-SimpleDomainController.require_authenticationj   sC   € à×+Ñ+¨EÓ2ˆØÑÜM‰MØ@ÀÀð H+ð +ôð  $Ð&Ð&r    c                 ó€   • U R                  X5      nUb*  X5R                  S5      :X  a  UR                  S/ 5      US'   gg)ztReturns True if this user_name/password pair is valid for the realm,
False otherwise. Used for basic authentication.ÚpasswordÚrolesúwsgidav.auth.rolesTF)r+   r   )r   r(   r)   r9   r0   Úusers         r   Úbasic_auth_userÚ&SimpleDomainController.basic_auth_usert   sD   € ð ×$Ñ$ UÓ6ˆàÑ ¯H©H°ZÓ,@Ó @Ø,0¯H©H°W¸bÓ,AˆGÐ(Ñ)ØØr    c                 ó   • g)NT© r#   s    r   Úsupports_http_digest_authÚ0SimpleDomainController.supports_http_digest_auth~   s   € àr    c                 óœ   • U R                  X5      nUc  gUR                  S5      nUR                  S/ 5      US'   U R                  XU5      $ )zComputes digest hash A1 part.Fr9   r:   r;   )r+   r   Ú_compute_http_digest_a1)r   r(   r)   r0   r<   r9   s         r   Údigest_auth_userÚ'SimpleDomainController.digest_auth_user‚   sQ   € à×$Ñ$ UÓ6ˆØ‰<ØØ—8‘8˜JÓ'ˆØ(,¯©°¸"Ó(=ˆÐ$Ñ%Ø×+Ñ+¨E¸hÓGÐGr    )r   )N)r"   Ú
__module__Ú__qualname__Ú__firstlineno__r   r$   r+   r1   r6   r=   rA   rE   Ú__static_attributes__Ú__classcell__)r   s   @r   r   r   H   s2   ø† õò .ô*òò
'òò÷Hð Hr    r   N)
Ú__doc__Úwsgidavr   Úwsgidav.dc.base_dcr   Ú__docformat__Úget_module_loggerr"   r4   r   r@   r    r   Ú<module>rQ      s9   ðñ
:õv Ý 3à"€à
×
 Ò
  Ó
*€ôAHÐ1õ AHr    