Ë
    ûûàgà  ã                   ój   — d dl mZ d dlmZ d dlmZ d dlmZmZ  G d„ de«      Z	 G d„ de«      Z
e
gZy	)
é    )ÚHttpResponseRedirect)Úreverse)Ú	urlencode)ÚProviderÚProviderAccountc                   ó   — e Zd Zy)ÚSAMLAccountN)Ú__name__Ú
__module__Ú__qualname__© ó    úk/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/allauth/socialaccount/providers/saml/provider.pyr	   r	      s   „ Ør   r	   c                   óv   ‡ — e Zd ZdZdZdZeZdgddgdgdd	gd
gdgdœZˆ fd„Z	d„ Z
d„ Zd„ Zd„ Zd„ Zdd„Zˆ xZS )ÚSAMLProviderÚsamlÚSAMLTz,urn:oasis:names:tc:SAML:attribute:subject-idz!urn:oid:0.9.2342.19200300.100.1.3zBhttp://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddressz'http://schemas.auth0.com/email_verifiedz?http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givennamezurn:oid:2.5.4.42zurn:oid:2.5.4.4z!http://schemas.auth0.com/nickname)ÚuidÚemailÚemail_verifiedÚ
first_nameÚ	last_nameÚusernamec                 ó¦   •— t        ‰| �  |i |¤Ž | j                  j                  xs$ | j                  j                  xs | j                  | _        y ©N)ÚsuperÚ__init__ÚappÚnameÚ	client_id)ÚselfÚargsÚkwargsÚ	__class__s      €r   r   zSAMLProvider.__init__(   s<   ø€ Ü‰Ñ˜$Ð) &Ò)Ø—H‘H—M‘MÒD T§X¡X×%7Ñ%7ÒD¸4¿9¹9ˆ�	r   c                 ór   — t        dd| j                  j                  i¬«      }|r|dz   t        |«      z   }|S )NÚ
saml_loginÚorganization_slug)r#   ú?)r   r   r    r   )r!   Úrequestr#   Úurls       r   Úget_login_urlzSAMLProvider.get_login_url,   s9   € Ü�lÐ,?ÀÇÁ×ASÑASÐ+TÔUˆÙØ˜‘)œi¨Ó/Ñ/ˆCØˆ
r   c                 ó"   — |j                  «       S r   )Úget_attributes)r!   Údatas     r   Úextract_extra_datazSAMLProvider.extract_extra_data2   s   € Ø×"Ñ"Ó$Ð$r   c                 ój   — | j                  |«      j                  d«      }|€|j                  «       }|S )u·  http://docs.oasis-open.org/security/saml-subject-id-attr/v1.0/csprd01/saml-subject-id-attr-v1.0-csprd01.html

        Quotes:

        "While the Attributes defined in this profile have as a goal the
        explicit replacement of the <saml:NameID> element as a means of subject
        identification, it is certainly possible to compose them with existing
        NameID usage provided the same subject is being identified. This can
        also serve as a migration strategy for existing applications."


        "SAML does not define an identifier that meets all of these
        requirements well. It does standardize a kind of NameID termed
        â€œpersistentâ€� that meets some of them in the particular case of so-called
        â€œpairwiseâ€� identification, where an identifier varies by relying
        party. It has seen minimal adoption outside of a few contexts, and fails
        at the â€œcompactâ€� and â€œsimple to handleâ€� criteria above, on top of the
        disadvantages inherent with all NameID usage."

        Overall, our strategy is to prefer a uid resulting from explicit
        attribute mappings, and only if there is no such uid fallback to the
        NameID.
        r   )Ú_extractÚgetÚ
get_nameid)r!   r.   r   s      r   Úextract_uidzSAMLProvider.extract_uid5   s3   € ð0 �m‰m˜DÓ!×%Ñ% eÓ,ˆØˆ;Ø—/‘/Ó#ˆCØˆ
r   c                 óL   — | j                  |«      }|j                  dd «       |S )Nr   )r1   Úpop)r!   r.   Úrets      r   Úextract_common_fieldsz"SAMLProvider.extract_common_fieldsR   s#   € Ø�m‰m˜DÓ!ˆØ�‰��tÔØˆ
r   c                 ó2  — | j                   j                  }|j                  «       }i }|j                  d| j                  «      }|j                  «       D ]L  \  }}t        |t        «      r|g}|D ]/  }|j                  |d «      }	|	€Œt        |	«      dkD  sŒ'|	d   ||<    ŒL ŒN |j                  d«      }
|
r|
j                  «       dv }
|
|d<   |j                  d«      s8|j                  «       dk(  s|j                  dd«      r|j                  «       |d<   |S )	NÚattribute_mappingr   r   )ÚtrueÚ1ÚtÚyÚyesr   z6urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddressÚuse_nameid_for_emailF)r   Úsettingsr-   r2   Údefault_attribute_mappingÚitemsÚ
isinstanceÚstrÚlenÚlowerÚget_nameid_formatr3   )r!   r.   Úprovider_configÚraw_attributesÚ
attributesr:   ÚkeyÚprovider_keysÚprovider_keyÚattribute_listr   s              r   r1   zSAMLProvider._extractW   s4  € ØŸ(™(×+Ñ+ˆØ×,Ñ,Ó.ˆØˆ
Ø+×/Ñ/Ø ×!?Ñ!?ó
Ðð #4×"9Ñ"9Ó";ò 	ÑˆC�Ü˜-¬Ô-Ø!. �Ø -ò �Ø!/×!3Ñ!3°LÀ$Ó!G�Ø!Ñ-´#°nÓ2EÈÓ2IØ&4°QÑ&7�J˜s‘OÙñ	ð	ð $Ÿ™Ð(8Ó9ˆÙØ+×1Ñ1Ó3Ð7UÐUˆNØ+9ˆJÐ'Ñ(ð �~‰~˜gÔ&Ø×"Ñ"Ó$ØGòHð ×"Ñ"Ð#9¸5ÔAà"&§/¡/Ó"3ˆJ�wÑàÐr   c                 ó¦   — ddl m}  ||| «      }|j                  d¬«      } | j                  ||||fd|j	                  «       i|¤Ž t        |«      S )Nr   )Ú
build_authÚ )Ú	return_toÚstate_id)Ú*allauth.socialaccount.providers.saml.utilsrQ   ÚloginÚstash_redirect_stateÚget_last_request_idr   )	r!   r)   ÚprocessÚnext_urlr.   r#   rQ   ÚauthÚredirects	            r   r\   zSAMLProvider.redirectw   si   € ÝIá˜' 4Ó(ˆð —:‘:¨�:Ó+ˆØ!ˆ×!Ñ!ØØØØñ		
ð
 ×-Ñ-Ó/ð	
ð ò	
ô $ HÓ-Ð-r   )NN)r
   r   r   Úidr   Úsupports_redirectr	   Úaccount_classrB   r   r+   r/   r4   r8   r1   r\   Ú__classcell__)r$   s   @r   r   r      sˆ   ø„ Ø	€BØ€DØÐØ€Mð ;ð
ð 0ØPð
ð
 6ð
ð NØð
ð
 ð
ð 0ð
ñ%!Ðô.Eòò%òò:ò
÷@.r   r   N)Údjango.httpr   Údjango.urlsr   Údjango.utils.httpr   Ú$allauth.socialaccount.providers.baser   r   r	   r   Úprovider_classesr   r   r   ú<module>rf      s6   ðÝ ,Ý Ý 'ç Jô	�/ô 	ôz.�8ô z.ðz !�>Ñ r   