
    )Jf                     l    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	dS )	    )reverse)	urlencode)ProviderProviderAccountc                        e Zd Z fdZ xZS )SAMLAccountc                 D    t                                                      S N)superto_str)self	__class__s    p/home/alex/cs2snipeproduction/venv/lib/python3.11/site-packages/allauth/socialaccount/providers/saml/provider.pyr   zSAMLAccount.to_str   s    ww~~    )__name__
__module____qualname__r   __classcell__r   s   @r   r   r      s8                         r   r   c                   j     e 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 xZS )SAMLProvidersamlSAMLz,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                      j        |i | | j        j        p| j        j        p| j        | _        d S r
   )r   __init__appname	client_id)r   argskwargsr   s      r   r!   zSAMLProvider.__init__'   s?    $)&)))HMDTX%7D49			r   c                 n    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+   sB    l,?AS+TUUU 	0)i///C
r   c                 *    |                                 S r
   )get_attributes)r   datas     r   extract_extra_datazSAMLProvider.extract_extra_data1   s    ""$$$r   c                     |                      |                              d          }||                                }|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   r0   r   s      r   extract_uidzSAMLProvider.extract_uid4   s<    0 mmD!!%%e,,;//##C
r   c                 \    |                      |          }|                    dd            |S )Nr   )r3   pop)r   r0   rets      r   extract_common_fieldsz"SAMLProvider.extract_common_fieldsQ   s,    mmD!!t
r   c                 J   | j         j        }|                                }i }|                    d| j                  }|                                D ]Z\  }}t          |t                    r|g}|D ]:}|                    |d           }	|	 t          |	          dk    r|	d         ||<    n;[|                    d          }
|
r|
	                                dv }
|
|d<   |                    d          s/|
                                dk    r|                                |d<   |S )Nattribute_mappingr   r   )true1tyyesr   z6urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress)r"   settingsr/   r4   default_attribute_mappingitems
isinstancestrlenlowerget_nameid_formatr5   )r   r0   provider_configraw_attributes
attributesr<   keyprovider_keysprovider_keyattribute_listr   s              r   r3   zSAMLProvider._extractV   sX   (+,,..
+//!?
 
 #4"9"9";"; 	 	C--- 0!. -  !/!3!3L$!G!G!-#n2E2E2I2I&4Q&7JsOE#(899 	:+11337UUN+9J'( w''	4&&((GH H #'//"3"3Jwr   )r   r   r   idr#   r   account_classrC   r!   r-   r1   r6   r:   r3   r   r   s   @r   r   r      s        	BDM ;
 0P

 6
 N

 
 0
%! !.E E E E E  % % %  :  
      r   r   N)
django.urlsr   django.utils.httpr   $allauth.socialaccount.providers.baser   r   r   r   provider_classes r   r   <module>rX      s          ' ' ' ' ' ' J J J J J J J J         /      
g g g g g8 g g gT !>   r   