404

[ Avaa Bypassed ]




Upload:

Command:

elspacio@13.59.58.68: ~ $
3

�k�Z��@s�ddlZddlZddlZddlmZddlmZmZmZm	Z	ddl
mZmZm
Z
ddlmZmZmZmZddlmZmZmZmZGdd	�d	e�Ze�ZejZejZejZejZejZdS)
�N)�Mapping�)�	Algorithm�get_default_algorithms�
has_crypto�requires_cryptography)�binary_type�string_types�	text_type)�DecodeError�InvalidAlgorithmError�InvalidSignatureError�InvalidTokenError)�base64url_decode�base64url_encode�force_bytes�
merge_dictc@s|eZdZdZddd�Zedd��Zdd�Zd	d
�Zdd�Z	ddd�Z
d dd�Zdd�Zdd�Z
d!dd�Zdd�Zdd�ZdS)"�PyJWSZJWTNcCsjt�|_|dk	rt|�nt|j�|_x(t|jj��D]}||jkr4|j|=q4W|sVi}t|j�|�|_dS)N)	r�_algorithms�set�_valid_algs�list�keysr�_get_default_options�options)�self�
algorithmsr�key�r�/usr/lib/python3.6/api_jws.py�__init__s
zPyJWS.__init__cCsddiS)N�verify_signatureTrrrrrr#szPyJWS._get_default_optionscCs>||jkrtd��t|t�s$td��||j|<|jj|�dS)zW
        Registers a new Algorithm for use when creating and verifying tokens.
        z Algorithm already has a handler.z!Object is not of type `Algorithm`N)r�
ValueError�
isinstancer�	TypeErrorr�add)r�alg_id�alg_objrrr�register_algorithm)s


zPyJWS.register_algorithmcCs*||jkrtd��|j|=|jj|�dS)z�
        Unregisters an Algorithm for use when creating and verifying tokens
        Throws KeyError if algorithm is not registered.
        zJThe specified algorithm could not be removed because it is not registered.N)r�KeyErrorr�remove)rr&rrr�unregister_algorithm6s
zPyJWS.unregister_algorithmcCs
t|j�S)zM
        Returns a list of supported values for the 'alg' parameter.
        )rr)rrrr�get_algorithmsBszPyJWS.get_algorithms�HS256cCs�g}|dkrd}||jkr|j|d�}|r>|j|�|j|�ttj|d	|d��}|jt|��|jt|��dj	|�}	y$|j
|}
|
j|�}|
j|	|�}Wn8t
k
r�tr�|tkr�td|��ntd��YnX|jt|��dj	|�S)
NZnone)�typ�alg�,�:)Z
separators�cls�.zFAlgorithm '%s' could not be found. Do you have cryptography installed?zAlgorithm not supported)r0r1)r�
header_typ�_validate_headers�updater�json�dumps�appendr�joinr�prepare_keyZsignr)rr�NotImplementedError)r�payloadr�	algorithm�headersZjson_encoderZsegments�headerZjson_header�
signing_inputr'�	signaturerrr�encodeHs8







zPyJWS.encode�Tc
Ksnt|j|�}|d}|r*|r*tjd	t�|j|�\}	}
}}|sRtjdtdd�n|rj|j|	|
||||�|	S)
Nr!z.It is strongly recommended that you pass in a z;value for the "algorithms" argument when calling decode(). z4This argument will be mandatory in a future version.zSThe verify parameter is deprecated. Please use verify_signature in options instead.�)�
stacklevelziIt is strongly recommended that you pass in a value for the "algorithms" argument when calling decode(). z�It is strongly recommended that you pass in a value for the "algorithms" argument when calling decode(). This argument will be mandatory in a future version.)rr�warnings�warn�DeprecationWarning�_load�_verify_signature)
rZjwsr�verifyrr�kwargsZmerged_optionsr!r=rAr@rBrrr�decodexs
zPyJWS.decodecCs|j|�d}|j|�|S)z�Returns back the JWT header parameters as a dict()

        Note: The signature is not verified so the header parameters
        should not be fully trusted until signature verification is complete
        rE)rJr5)r�jwtr?rrr�get_unverified_header�s
zPyJWS.get_unverified_headerc2Csht|t�r|jd�}tt|�t�s0tdjt���y$|jdd�\}}|j	dd�\}}Wnt
k
rptd��YnXyt|�}Wn"tt
jfk
r�td��YnXytj|jd��}Wn.t
k
r�}ztd|��WYdd}~XnXt|t�s�td��yt|�}	Wn$tt
jfk
�r(td	��YnXyt|�}
Wn$tt
jfk
�rZtd
��YnX|	|||
fS)Nzutf-8z'Invalid token type. Token must be a {0}r3rzNot enough segmentszInvalid header paddingzInvalid header string: %sz,Invalid header string: must be a json objectzInvalid payload paddingzInvalid crypto padding)r#r
rC�
issubclass�typerr�format�rsplit�splitr"rr$�binascii�Errorr7�loadsrNr)rrOrAZcrypto_segmentZheader_segmentZpayload_segmentZheader_datar@�er=rBrrrrJ�s:


zPyJWS._loadc	Csr|jd�}|dk	r"||kr"td��y.|j|}|j|�}|j|||�sNtd��Wntk
rltd��YnXdS)Nr/z&The specified alg value is not allowedzSignature verification failedzAlgorithm not supported)�getrrr;rLr
r))	rr=rAr@rBrrr/r'rrrrK�s


zPyJWS._verify_signaturecCsd|kr|j|d�dS)N�kid)�
_validate_kid)rr?rrrr5�szPyJWS._validate_headerscCst|t�std��dS)Nz(Key ID header parameter must be a string)r#r	r)rr[rrrr\�s
zPyJWS._validate_kid)NN)r-NN)rDTNN)rDN)�__name__�
__module__�__qualname__r4r �staticmethodrr(r+r,rCrNrPrJrKr5r\rrrrrs


/
(
r) rVr7rG�collectionsrrrrrr�compatrr	r
�
exceptionsrrr
rZutilsrrrr�objectrZ_jws_global_objrCrNr(r+rPrrrr�<module>sO

Filemanager

Name Type Size Permission Actions
__init__.cpython-36.opt-1.pyc File 1.02 KB 0644
__init__.cpython-36.pyc File 1.02 KB 0644
__main__.cpython-36.opt-1.pyc File 3.48 KB 0644
__main__.cpython-36.pyc File 3.48 KB 0644
algorithms.cpython-36.opt-1.pyc File 10.84 KB 0644
algorithms.cpython-36.pyc File 10.84 KB 0644
api_jws.cpython-36.opt-1.pyc File 6.24 KB 0644
api_jws.cpython-36.pyc File 6.24 KB 0644
api_jwt.cpython-36.opt-1.pyc File 5.85 KB 0644
api_jwt.cpython-36.pyc File 5.85 KB 0644
compat.cpython-36.opt-1.pyc File 1.39 KB 0644
compat.cpython-36.pyc File 1.39 KB 0644
exceptions.cpython-36.opt-1.pyc File 2.05 KB 0644
exceptions.cpython-36.pyc File 2.05 KB 0644
utils.cpython-36.opt-1.pyc File 3.04 KB 0644
utils.cpython-36.pyc File 3.04 KB 0644