File: //usr/lib/python3/dist-packages/mercurial/hgweb/__pycache__/common.cpython-310.pyc
o
�]Lb�# � @ s d dl mZ d dlZd dlZd dlZd dlZd dlZddlmZm Z ddl
mZmZmZm
Z
e
jZdZdZdZd Zd
ZdZdZd
ZdZdZdZdd� Zdd� ZegZG dd� de�ZG dd� de�Z dd� Z!d+dd�Z"dd� Z#dd � Z$d!d"� Z%d#d$� Z&d,d%d&�Z'd'd(� Z(d)d*� Z)dS )-� )�absolute_importN� )�getattr�open)�encoding�pycompat� templater�util�� �� i0 i� i� i� i� i� i� i� i� c C s |dgkp||v S )z�Check if username is a member of userlist.
If userlist has a single '*' member, all users are considered members.
Can be overridden by extensions to provide more complex authorization
schemes.
� *� )�ui�username�userlistr
r
�8/usr/lib/python3/dist-packages/mercurial/hgweb/common.py�ismember+ s r c C s@ |j }| �dd�}|r|rt| jj||�rttd��| �dd�}|r/t| jj||�s/ttd��|dkr;| js;ttd��|dksC|du rEdS |dkrV|jd krUd
}tt |��n|jdkrbd}tt |��| �
dd
�rr|jdkrrttd��| �dd�}|r�|r�t| jj||�r�ttd��| �dd�}|r�t| jj||�s�ttd��dS )z�Check permission for operation based on request data (including
authentication info). Return if op allowed, else raise an ErrorResponse
exception.� webs deny_reads read not authorizeds
allow_reads pulls pull not authorizedNs uploads PUTs upload requires PUT requests POSTs push requires POST requests push_ssls httpss ssl requireds deny_pushs push not authorizeds
allow-push)
�
remoteuser�
configlistr �repor �
ErrorResponse�HTTP_UNAUTHORIZED� allowpull�method�HTTP_METHOD_NOT_ALLOWED�
configbool� urlscheme�HTTP_FORBIDDEN) �hgweb�req�op�user� deny_read�
allow_read�msg�deny�allowr
r
r �
checkauthz5 s8
�
�r( c @ s e Zd Zddd�ZdS )r Nc C sD |d u rt |�}t�| t�|�� || _|d u rg }|| _|| _d S �N)�_statusmessage� Exception�__init__r �sysstr�code�headers�message)�selfr. r0 r/ r
r
r r, l s
zErrorResponse.__init__)NN)�__name__�
__module__�__qualname__r, r
r
r
r r k s r c @ s* e Zd ZdZdd� Zd
dd�Zdd� Zd S )�continuereadera. File object wrapper to handle HTTP 100-continue.
This is used by servers so they automatically handle Expect: 100-continue
request headers. On first read of the request body, the 100 Continue
response is sent. This should trigger the client into actually sending
the request body.
c C s || _ || _d| _d S )NF)�f�_write� continued)r1 r6 �writer
r
r r, � s
zcontinuereader.__init__���c C s"