o
    BZœc‰  ã                   @   sD   d dl mZ d dlmZ d dlmZ d dlmZ G dd„ deƒZdS )é    )Úurlparse)ÚDisallowedRedirect)ÚHttpResponse)Ú
iri_to_uric                       s8   e Zd ZdZdZ‡ fdd„Zedd„ ƒZdd„ Z‡  Z	S )	ÚOAuth2ResponseRedirectzÊ
    An HTTP 302 redirect with an explicit list of allowed schemes.
    Works like django.http.HttpResponseRedirect but we customize it
    to give us more flexibility on allowed scheme validation.
    i.  c                    s2   t ƒ j|i |¤Ž t|ƒ| d< || _|  |¡ d S ©NÚLocation)ÚsuperÚ__init__r   Úallowed_schemesÚvalidate_redirect)ÚselfÚredirect_tor   ÚargsÚkwargs©Ú	__class__© úJ/var/www/chikooza/env/lib/python3.10/site-packages/oauth2_provider/http.pyr
      s   zOAuth2ResponseRedirect.__init__c                 C   s   | d S r   r   )r   r   r   r   Úurl   s   zOAuth2ResponseRedirect.urlc                 C   s:   t t|ƒƒ}|jstdƒ‚|j| jvrtd |j¡ƒ‚d S )Nz&OAuth2 redirects require a URI scheme.z(Redirect to scheme {!r} is not permitted)r   ÚstrÚschemer   r   Úformat)r   r   Úparsedr   r   r   r      s   
ÿÿz(OAuth2ResponseRedirect.validate_redirect)
Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ústatus_coder
   Úpropertyr   r   Ú__classcell__r   r   r   r   r      s    
r   N)	Úurllib.parser   Údjango.core.exceptionsr   Údjango.httpr   Údjango.utils.encodingr   r   r   r   r   r   Ú<module>   s
    