
    $gj                     Z    d Z ddlZddlmZ  ej        d          Z G d de          ZdS )a=  
CAS OIDC backend
https://apereo.github.io/cas/6.6.x/authentication/OIDC-Authentication.html

Backend for authenticating with Apereo CAS using OIDC. This backend handles
the minor implementation differences between the Apereo CAS OIDC server
implementation and the standard OIDC implementation in Python Social Auth.
    N   )OpenIdConnectAuthsocialc                   2    e Zd ZdZdZdZd Zd Zd Zd Z	dS )	CASOpenIdConnectAutha  
    Open ID Connect backends for use with Apereo CAS.
    Currently only the code response type is supported.

    It can also be directly instantiated as a generic OIDC backend.
    To use it you will need to set at minimum:

    SOCIAL_AUTH_CAS_OIDC_ENDPOINT = 'https://.....'  # endpoint without /.well-known/openid-configuration
    SOCIAL_AUTH_CAS_KEY = '<client_id>'
    SOCIAL_AUTH_CAS_SECRET = '<client_secret>'
    casTc                 v    |                      d| j                  }t                              d|            |S )NOIDC_ENDPOINTzbackend: CAS, endpoint: )settingr
   loggerdebug)selfendpoints     X/var/www/html/netbox-4.1.3/venv/lib/python3.11/site-packages/social_core/backends/cas.pyoidc_endpointz"CASOpenIdConnectAuth.oidc_endpoint!   s8    <<1CDD:::;;;    c                 l    t                               d| d|            |                    d          S )Nz,backend: CAS, method: get_user_id, details: z, username)r   r   get)r   detailsresponses      r   get_user_idz CASOpenIdConnectAuth.get_user_id&   s?    P7PPhPP	
 	
 	
 {{:&&&r   c                     |                      |                                 dd| i          }t                              d|            |                    di           S )NAuthorizationzBearer )headerszbackend: CAS, user_data: 
attributes)get_jsonuserinfo_urlr   r   r   )r   access_tokenargskwargsdatas        r   	user_datazCASOpenIdConnectAuth.user_data,   sj    }}/;S\;S;S)T  
 
 	777888xxb)))r   c                    |                      d| j                  }t                              d|            |                     |                    d                    }|                    |          |                    d          |                    d          |                    d          |                    d          dS )	NUSERNAME_KEYzbackend: CAS, username_key: r   emailname
given_namefamily_name)r   r&   fullname
first_name	last_name)r   r%   r   r   r#   r   )r   r   username_keyr   s       r   get_user_detailsz%CASOpenIdConnectAuth.get_user_details3   s    ||ND4EFFBLBBCCC^^HLL$@$@AA
"|44^^G,,"v..$..66#66
 
 	
r   N)
__name__
__module____qualname____doc__r'   STATE_PARAMETERr   r   r#   r.    r   r   r   r      sf        
 
 DO  
' ' '* * *

 

 

 

 

r   r   )r2   loggingopen_id_connectr   	getLoggerr   r   r4   r   r   <module>r8      ss      . . . . . .		8	$	$,
 ,
 ,
 ,
 ,
, ,
 ,
 ,
 ,
 ,
r   