
    ^ht                       S r SSKJr  SSKrSSKrSSKrSSKrSSKrSSKrSSK	r
SSKrSSKJrJr  SSKJr  SSKJrJrJr  SSKJrJrJrJrJrJrJrJrJr  SSKJ r   SS	K!J"r"  S
SK#J$r$J%r%  S
SK&J'r'  \RP                  " S5      r)\
RT                  S   r+\ " S S5      5       r,SS jr- " S S\ 5      r. " S S\.5      r/ " S S\/5      r0g)zIdentity Provider interface

This defines the _authentication_ layer of Jupyter Server,
to be used in combination with Authorizer for _authorization_.

.. versionadded:: 2.0
    )annotationsN)asdict	dataclass)Morsel)escapehttputilweb)	BoolDictEnumList
TraitErrorTypeUnicodedefaultvalidate)LoggingConfigurable)_i18n   )passwd_checkset_password)get_anonymous_usernamez[^A-Za-z0-9]namedisplay_nameinitials
avatar_urlcolorc                  v    \ rS rSr% SrS\S'   SrS\S'   SrS\S'   SrS	\S
'   Sr	S	\S'   Sr
S	\S'   S rS rSrg)User&   zaObject representing a User

This or a subclass should be returned from IdentityProvider.get_user
strusername r   r   N
str | Noner   r   r   c                $    U R                  5         g N)fill_defaultsselfs    V/home/james-whalen/.local/lib/python3.13/site-packages/jupyter_server/auth/identity.py__post_init__User.__post_init__>   s        c                    U R                   (       d  SU  3n[        U5      eU R                  (       d  U R                   U l        U R                  (       d  U R                  U l        gg)zFill out default fields in the identity model

- Ensures all values are defined
- Fills out derivative values for name fields fields
- Fills out null values for optional fields
z!user.username must not be empty: N)r#   
ValueErrorr   r   )r*   msgs     r+   r(   User.fill_defaultsA   sO     }}5dV<CS/! yyDI   $		D !r.   )r   r   )__name__
__module____qualname____firstlineno____doc____annotations__r   r   r   r   r   r,   r(   __static_attributes__ r.   r+   r    r    &   sO    
 M D#N L#  Hj!J
!E:
*r.   r    c                R   [        U [        5      (       a	  [        U S9$ [        U [        5      (       aF  0 nSU ;  a  SU ;   a  U S   US'   [        R                   H  nX ;   d  M
  X   X'   M      [        S0 UD6$ SU  3n[        U5      e! [
         a    SU  3n[        U5      Sef = f)zBackward-compatibility for LoginHandler.get_user

Prior to 2.0, LoginHandler.get_user could return anything truthy.

Typically, this was either a simple string username,
or a simple dict.

Make some effort to allow common patterns to keep working.
)r#   r#   r   zUnrecognized user: Nr:   )
isinstancer"   r    dict__dataclass_fields__	TypeErrorr0   )got_userkwargsfieldr1   s       r+   _backward_compat_userrC   U   s     (C  X&&	Hd	#	#X%&H*<!)&!1F:..E  ( /	,>&>!
 $H:.o  	,'z2CS/t+	,s   /
B
 
B&c            	      n   \ rS rSr% Sr\" SS\" S5      S9rS\S'   \	" S\" S	5      S9r
\" S
SS\" S5      S9rS\S'   \	" S\" S5      S9r\" S\" S5      S9R                  SS9rS\S'   \" S\R$                  S\" S5      S9r\" S\R$                  S\" S5      S9r\" \" \" \R2                  " \5      5      5      S/S\" S5      S9rSr\" S5      S 5       r\" S5      S  5       r \" S5      r!S!\S"'   S>S# jr"S?S$ jr#      S@S% jr$SAS& jr%SBS' jr&SCS( jr'SDS) jr(SES* jr)SFS+ jr*SGS, jr+SHS- jr,SIS. jr- SJ         SKS/ jjr.SCS0 jr/    S>S1 jr0\1Rd                  " S2\1Rf                  5      r4SLS3 jr5S?S4 jr6SMS5 jr7SNS6 jr8SNS7 jr9 SO     SPS8 jjr:S?S9 jr;\<S: 5       r=\<S; 5       r>\<S< 5       r?S=r@g
)QIdentityProviderr   a  
Interface for providing identity management and authentication.

Two principle methods:

- :meth:`~jupyter_server.auth.IdentityProvider.get_user` returns a :class:`~.User` object
  for successful authentication, or None for no-identity-found.
- :meth:`~jupyter_server.auth.IdentityProvider.identity_model` turns a :class:`~jupyter_server.auth.User` into a JSONable dict.
  The default is to use :py:meth:`dataclasses.asdict`,
  and usually shouldn't need override.

Additional methods can customize authentication.

.. versionadded:: 2.0
r$   TzJName of the cookie to set for persisting login. Default: username-${Host}.confighelpzstr | Unicode[str, str | bytes]cookie_nameziExtra keyword arguments to pass to `set_secure_cookie`. See tornado's set_secure_cookie docs for details.NzSpecify whether login cookie should have the `secure` property (HTTPS-only).Only needed when protocol-detection gives the wrong answer due to proxies.)
allow_nonerH   rI   z+bool | Bool[bool | None, bool | int | None]secure_cookieziExtra keyword arguments to pass to `get_secure_cookie`. See tornado's get_secure_cookie docs for details.z<generated>a  Token used for authenticating first-time connections to the server.

        The token can be read from the file referenced by JUPYTER_TOKEN_FILE or set directly
        with the JUPYTER_TOKEN environment variable.

        When no password is enabled,
        the default is to generate a new, random token.

        Setting to an empty string disables authentication altogether, which is NOT RECOMMENDED.

        Prior to 2.0: configured as ServerApp.token
        )rI   )rH   tokenz*jupyter_server.auth.login.LoginFormHandlerz'The login handler class to use, if any.)default_valueklassrH   rI   z(jupyter_server.auth.logout.LogoutHandlerz The logout handler class to use.r   z5List of fields in the User model that can be updated.)traitrN   rH   rI   Fc                   [         R                  " S5      (       a  SU l        [         R                  S   $ [         R                  " S5      (       a=  SU l        [	        [         R                  S   5       nUR                  5       sS S S 5        $ U R                  (       d  SU l        gSU l        [        R                  " [         R                  " S5      5      R                  S5      $ ! , (       d  f       Ng= f)NJUPYTER_TOKENFJUPYTER_TOKEN_FILEr$   T   ascii)osgetenvtoken_generatedenvironopenread
need_tokenbinasciihexlifyurandomdecode)r*   
token_files     r+   _token_defaultIdentityProvider._token_default   s    99_%%#(D ::o..99)**#(D bjj!567:!( 87#(D #'D ##BJJrN3::7CC 87s   4C''
C5updatable_fieldsc                    [        [        R                  " [        5      5      nUS    Vs/ s H  o3U;  d  M
  UPM     nnU(       a  SU 3n[	        U5      eUS   $ s  snf )z7Validate that all fields in updatable_fields are valid.valuez$Invalid fields in updatable_fields: )listtget_argsUpdatableFieldr   )r*   proposalvalid_updatable_fieldsrB   invalid_fieldsr1   s         r+   _validate_updatable_fields+IdentityProvider._validate_updatable_fields   sl     "&ajj&@!A'0
0eAW4WE0 	 
 88HICS/!  
s
   	AAz%bool | Bool[bool, t.Union[bool, int]]r\   c                $    U R                  U5      $ )zGet the authenticated user for a request

Must return a :class:`jupyter_server.auth.User`,
though it may be a subclass.

Return None if the request is not authenticated.

_may_ be a coroutine
)	_get_userr*   handlers     r+   get_userIdentityProvider.get_user   s     ~~g&&r.   c                  #    [        USS5      (       a%  [        R                  " [        UR                  5      $ U R                  U5      n[        U[        R                  5      (       a
  UI Sh  vN nUnU R                  U5      n[        U[        R                  5      (       a
  UI Sh  vN nUnU=(       d    UnUb   Ub  Xe:w  a  U R                  X5        SUl
        Uc  U R                  U5      nUR                  U5      nUb/  U R                  R                  SU 35        U R                  U5        U R                   (       d"  U R#                  U5      nU R                  X5        U$  N N7f)Get the user._jupyter_current_userNTz&Clearing invalid/expired login cookie )getattrrh   castr    rx   get_user_tokenr<   	Awaitableget_user_cookieset_login_cookie_token_authenticatedget_cookie_name
get_cookielogwarningclear_login_cookieauth_enabledgenerate_anonymous_user)	r*   rs   _token_user
token_user_cookie_usercookie_useruserrJ   cookies	            r+   rq   IdentityProvider._get_user   sP    73T::66$ = =>>>B>Q>QRY>Zk1;;// ++K"-
++G4lAKK00!--L#/ ([
 6 "%%g4 ,0G(< ..w7K''4F!  #I+!WX''0$$ 33G< %%g4I , .s%   A-E0/E,0;E0+E.,CE0.E0c                    U R                  U5        [        R                  " [        UR                  5      nU R                  X25      nU R                  U5        U$ )z3Update user information and persist the user model.)check_updaterh   rz   r    current_userupdate_user_modelpersist_user_model)r*   rs   	user_datar   updated_users        r+   update_userIdentityProvider.update_user(  sL     	)$vvdG$8$89--lF(r.   c                V    U H#  nX R                   ;  d  M  SU S3n[        U5      e   g)z2Raises if some fields to update are not updatable.zField z is not updatableN)rd   r0   )r*   r   rB   r1   s       r+   r   IdentityProvider.check_update2  s1    E111ug%67 o% r.   c                    [         ezUpdate user information.NotImplementedError)r*   r   r   s      r+   r   "IdentityProvider.update_user_model9      !!r.   c                    [         e)z'Persist the user model (i.e. a cookie).r   rr   s     r+   r   #IdentityProvider.persist_user_model=  r   r.   c                    [        U5      $ )z"Return a User as an Identity model)r   )r*   r   s     r+   identity_modelIdentityProvider.identity_modelA  s     d|r.   c                    / nU R                   (       a  UR                  SU R                  45        U R                  (       a  UR                  SU R                  45        U$ )zgReturn list of additional handlers for this identity provider

For example, an OAuth callback handler.
z/loginz/logout)login_availableappendlogin_handler_classlogout_availablelogout_handler_class)r*   handlerss     r+   get_handlersIdentityProvider.get_handlersF  sN    
 OOY(@(@AB  OOZ)B)BCDr.   c                    [         R                  " UR                  UR                  UR                  UR
                  UR                  S.5      nU$ )zSerialize a user to a string for storage in a cookie

If overriding in a subclass, make sure to define user_from_cookie as well.

Default is just the user's username.
)r#   r   r   r   r   )jsondumpsr#   r   r   r   r   )r*   r   r   s      r+   user_to_cookieIdentityProvider.user_to_cookieR  sC      MM		 $ 1 1 MM
 r.   c           	     l    [         R                  " U5      n[        US   US   US   US   SUS   5      $ )zInverse of user_to_cookier#   r   r   r   Nr   )r   loadsr    )r*   cookie_valuer   s      r+   user_from_cookie!IdentityProvider.user_from_cookiee  sF    zz,'L M
 	
r.   c                    U R                   (       a  U R                   $ [        R                  SSUR                  R                   35      $ )zReturn the login cookie name

Uses IdentityProvider.cookie_name, if defined.
Default is to generate a string taking host into account to avoid
collisions for multiple servers on one hostname with different ports.
-z	username-)rJ   _non_alphanumsubrequesthostrr   s     r+   r    IdentityProvider.get_cookie_nameq  s>     ### $$SIgoo6J6J5K*LMMr.   c                   0 nUR                  U R                  5        UR                  SS5        U R                  nUc  UR                  R
                  S:H  nU(       a  UR                  SS5        UR                  SUR                  5        U R                  U5      nUR                  " XPR                  U5      40 UD6  g)z9Call this on handlers to set the login cookie for successhttponlyTNhttpssecurepath)
updatecookie_options
setdefaultrL   r   protocolbase_urlr   set_secure_cookier   )r*   rs   r   r   rL   rJ   s         r+   r~   !IdentityProvider.set_login_cookie}  s    d112!!*d3 ** #OO44?M%%h5!!&'*:*:;**73!!+/B/B4/H[N[r.   c                   [         R                  " U5      n[        R                  R                  [        R                  R
                  S9[        R                  " SS9-
  n[        5       nUR                  USS5        [        R                  " U5      US'   X6S'   U(       a  XFS'   UR                  S	UR                  5       5        g
)aI  Deletes the cookie with the given name.

Tornado's cookie handling currently (Jan 2018) stores cookies in a dict
keyed by name, so it can only modify one cookie with a given name per
response. The browser can store multiple cookies with the same name
but different domains and/or paths. This method lets us clear multiple
cookies with the same name.

Due to limitations of the cookie protocol, you must pass the same
path and domain to clear a cookie as were used when that cookie
was set (but there is no way to find out on the server side
which values were used for a given cookie).
)tzim  )daysr$   z""expiresr   domainz
Set-CookieN)r   
native_strdatetimenowtimezoneutc	timedeltar   setr   format_timestamp
add_headerOutputString)r*   rs   r   r   r   r   morsels          r+   _force_clear_cookie$IdentityProvider._force_clear_cookie  s        &##''8+<+<+@+@'AHDVDV\_D`` &

4T"$55g>yv%8<)<)<)>?r.   c                    0 nUR                  U R                  5        UR                  SUR                  5      nU R	                  U5      nUR                  XCS9  U(       a  US:w  a  U R                  X5        ggg)z<Clear the login cookie, effectively logging out the session.r   )r   /N)r   r   r   r   r   clear_cookier   )r*   rs   r   r   rJ   s        r+   r   #IdentityProvider.clear_login_cookie  st    d112((1A1AB**73[4DCK
 $$W:  4r.   c                R   UR                   " U R                  U5      40 U R                  D6nU(       d  gUR                  5       n U R	                  U5      $ ! [
         aE  nU R                  R                  SU 3SS9  U R                  R                  SU 35         SnAgSnAff = f)zKGet user from a cookie

Calls user_from_cookie to deserialize cookie value
Nz)Error unpacking user from cookie: cookie=T)exc_infoz"Error unpacking user from cookie: )	get_secure_cookier   get_secure_cookie_kwargsr`   r   	Exceptionr   debugerror)r*   rs   _user_cookieuser_cookiees        r+   r}    IdentityProvider.get_user_cookie  s     00  )
++
 "))+	((55 	HHNNF{mT_cNdHHNN?sCD		s   A 
B&!;B!!B&z(token|bearer)\s+(.+)c                    UR                  SS5      nU(       dW  U R                  R                  UR                  R                  R                  SS5      5      nU(       a  UR                  S5      nU$ )z{Get the user token from a request

Default:

- in URL parameters: ?token=<token>
- in header: Authorization: token <token>
rM   r$   Authorization   )get_argumentauth_header_patmatchr   headersgetgroup)r*   rs   
user_tokenms       r+   	get_tokenIdentityProvider.get_token  s]     ))'26
$$**7??+B+B+F+FXZ+[\AWWQZ
r.   c                  #    [         R                  " SUR                  5      nU(       d  gU R                  U5      nSnX2:X  a2  U R                  R                  SUR                  R                  5        SnU(       aR  U R                  U5      n[        U[         R                  5      (       a
  UI Sh  vN nUnUc  U R                  U5      nU$ g N7f)zvIdentify the user based on a token in the URL or Authorization header

Returns:
- uuid if authenticated
- None if not
r%   NFz-Accepting token-authenticated request from %sT)rh   rz   rM   r   r   r   r   	remote_ipr}   r<   r|   r   )r*   rs   rM   r   authenticated_userr   s          r+   r{   IdentityProvider.get_user_token  s      |W]]3^^G,
HHNN?)) !M ((1E%--# %D|33G<K $s   B0C2C3Cc                    [         R                  " 5       R                  n[        5       nSU 3=pESUS    3nSnUR                  R                  SU 35        [        X$XVSU5      $ )zmGenerate a random anonymous user.

For use when a single shared token is used,
but does not identify a user.
z
Anonymous Ar   Nz5Generating new user for token-authenticated request: )uuiduuid4hexr   r   r   r    )r*   rs   user_idmoonr   r   r   r   s           r+   r   (IdentityProvider.generate_anonymous_user  sm     **,""%' *4&11tAwi=QRYQZ[\G<4GGr.   c                .    U R                  U5      (       + $ )a  Should the Handler check for CORS origin validation?

Origin check should be skipped for token-authenticated requests.

Returns:
- True, if Handler must check for valid CORS origin.
- False, if Handler should skip origin check since requests are token-authenticated.
)is_token_authenticatedrr   s     r+   should_check_origin$IdentityProvider.should_check_origin  s     ..w777r.   c                4    UR                     [        USS5      $ )zReturns True if handler has been token authenticated. Otherwise, False.

Login with a token is used to signal certain things, such as:

- permit access to REST API
- xsrf protection
- skip origin-checks for scripts
r   F)r   ry   rr   s     r+   r  'IdentityProvider.is_token_authenticated  s     	w 6>>r.   c                (   UR                   (       dT  SnUc  UR                  R                  U S35        U R                  (       d  UR                  R                  U S35        ggU R                  (       d  UR                  R                  S5        gg)znCheck the application's security.

Show messages, or abort if necessary, based on the security configuration.
z<WARNING: The Jupyter server is listening on all IP addressesNz3 and not using encryption. This is not recommended.zK and not using authentication. This is highly insecure and not recommended.z`All authentication is disabled.  Anyone who can connect to this server will be able to run code.)ipr   r   r   )r*   appssl_optionsr   s       r+   validate_security"IdentityProvider.validate_security(  s     vvTG"7)+^ _`$$i  C C %
 ""GGOOT #r.   c                :   UR                  SSS9nSnU R                  (       d,  U R                  R                  S5        U R	                  U5      $ U R
                  (       a:  U R
                  U:X  a*  [        R                  " [        U R                  U5      5      $ U$ )OProcess login form data

Return authenticated User if successful, None if not.
passwordr$   r   N6Accepting anonymous login because auth fully disabled!)
r   r   r   r   r   rM   rh   rz   r    user_for_token)r*   rs   typed_passwordr   s       r+   process_login_form#IdentityProvider.process_login_form@  s~    
 !--j"-E  HHUV//88::$**666$ 3 3N CDDr.   c                    g)zIs authentication enabled?

Should always be True, but may be False in rare, insecure cases
where requests with no auth are allowed.

Previously: LoginHandler.get_login_available
Tr:   r)   s    r+   r   IdentityProvider.auth_enabledP  s     r.   c                    U R                   $ z\Whether a LoginHandler is needed - and therefore whether the login page should be displayed.r   r)   s    r+   r    IdentityProvider.login_available[          r.   c                    g)z"Whether a LogoutHandler is needed.Tr:   r)   s    r+   r   !IdentityProvider.logout_available`  s     r.   )rX   )rs   web.RequestHandlerreturnz&User | None | t.Awaitable[User | None]rs   r#  r$  User | None)rs   r#  r   dict[UpdatableField, str]r$  r    )r   r'  r$  Noner   r    r   r'  r$  r    rs   r#  r$  r(  )r   r    r$  zdict[str, t.Any])r$  zlist[tuple[str, object]])r   r    r$  r"   )r   r"   r$  r&  )rs   r#  r$  r"   )rs   r#  r   r    r$  r(  )r   N)
rs   r#  r   r"   r   r"   r   r%   r$  r(  )rs   r#  r$  r%   )rs   r#  r$  r    rs   r#  r$  boolr'   r  t.Anyr  zdict[str, t.Any] | Noner$  r(  )Ar3   r4   r5   r6   r7   r   r   rJ   r8   r   r   r
   rL   r   tagrM   r   r	   RequestHandlerr   r   r   r   rg   rh   ri   rj   rd   rX   r   rb   r   rn   r\   rt   rq   r   r   r   r   r   r   r   r   r   r~   r   r   r}   recompile
IGNORECASEr   r   r{   r   r  r  r  r  propertyr   r   r   r9   r:   r.   r+   rE   rE   r   s     4;
_`4K0  A
N BFY
	BM>   $A
  .5
.  
cc! 
* $ B  <=	  @  56	 4

>234iJK	 OWD D   !	! "	! 9=T
J5B
'+Z)6O	&""

&


N\" ]a@)@14@<?@OY@	@6;)	/. jj!92==IO !FH	8?  04 - 
	0    ! !  r.   rE   c                    ^  \ rS rSrSr\" SS\" S5      S9r\" SS\" S5      S9r	\" SS\" S	5      S9r
\" S
5      S 5       r\" S5      S 5       r\SS j5       r\SS j5       rSS jrSS jrS rSS jr S     SU 4S jjjrSrU =r$ )PasswordIdentityProviderif  zA password identity provider.r$   Ta  
            Hashed password to use for web authentication.

            To generate, type in a python/IPython shell:

                from jupyter_server.auth import passwd; passwd()

            The string should be of the form type:salt:hashed-password.
            rG   Fao  
            Forces users to use a password for the Jupyter server.
            This is useful in a multi user environment, for instance when
            everybody in the LAN can access each other's machine through ssh.

            In such a case, serving on localhost is not secure since
            any user can connect to the Jupyter server via ssh.

            a  
            Allow password to be changed at login for the Jupyter server.

            While logging in with a token, the Jupyter server UI will give the opportunity to
            the user to enter a new password at the same time that will replace
            the token login mechanism.

            This can be set to False to prevent changing password from the UI/API.
            r\   c                6    [        U R                  5      (       + $ r'   )r,  hashed_passwordr)   s    r+   _need_token_default,PasswordIdentityProvider._need_token_default  s    ,,---r.   rd   c                
    / SQ$ )Nr   r:   r)   s    r+   _default_updatable_fields2PasswordIdentityProvider._default_updatable_fields  s    
 	
r.   c                    U R                   $ r  r  r)   s    r+   r   (PasswordIdentityProvider.login_available  r   r.   c                R    [        U R                  =(       d    U R                  5      $ )z"Return whether any auth is enabled)r,  r8  rM   r)   s    r+   r   %PasswordIdentityProvider.auth_enabled  s     D((6DJJ77r.   c                V    U R                    H  nX2;   d  M
  [        XX#   5        M     U$ r   )rd   setattr)r*   r   r   rB   s       r+   r   *PasswordIdentityProvider.update_user_model  s-    **E!Y-=> + r.   c                :    U R                  XR                  5        g)z#Persist the user model to a cookie.N)r~   r   rr   s     r+   r   +PasswordIdentityProvider.persist_user_model  s    g';';<r.   c                .    [        U R                  U5      $ )z1Check password against our stored hashed password)r   r8  )r*   r  s     r+   r   %PasswordIdentityProvider.passwd_check  s    D00(;;r.   c                   UR                  SSS9nUR                  SSS9nSnU R                  (       d,  U R                  R                  S5        U R	                  U5      $ U R                  U5      (       a  U(       d  U R	                  U5      $ U R                  (       a  U R                  U:X  a  U R	                  U5      nU(       a  U R                  (       a{  UR                  R                  SS5      n[        R                  R                  US5      n[        X6S	9U l        U R                  R                  [!        S
5      R#                  US95        U$ )r  r  r$   r  new_passwordNr  
config_dirzjupyter_server_config.json)config_filezWrote hashed password to {file})file)r   r   r   r   r   r   rM   allow_password_changesettingsr   rV   r   joinr   r8  infor   format)r*   rs   r  rJ  r   rK  rL  s          r+   r  +PasswordIdentityProvider.process_login_form  s   
 !--j"-E++NB+G  HHUV//88^,,\//88ZZDJJ.8//8D : :$--11,C
 ggll:7ST'3L'Z$e$EFMMS^M_`r.   c                p  > [         TU ]  X5        U R                  (       a  U R                  (       d  U R                  R                  [        S5      5        U R                  R                  [        S5      5        U R                  R                  [        S5      5        [        R                  " S5        ggg)zHandle security validation.>Jupyter servers are configured to only be run with a password.1Hint: run the following command to set a password)	$ python -m jupyter_server.auth passwordr   N)	superr  password_requiredr8  r   criticalr   sysexit)r*   r  r  	__class__s      r+   r  *PasswordIdentityProvider.validate_security  s     	!#3!!4+?+?HHVW HHe$WXYHHe$PQRHHQK ,@!r.   )r8  r$  r,  r)  r*  r%  r'   r-  )r3   r4   r5   r6   r7   r   r   r8  r
   rY  rN  r   r9  r<  r4  r   r   r   r   r   r  r  r9   __classcell__)r]  s   @r+   r6  r6  f  s    '


O  

  !

  \. .  
 !
 ! ! 8 8=<6 04 - 
	 r.   r6  c                      \ rS rSrSr\" 5       r\" S5      S 5       r\" S5      S 5       r	\
S 5       rSS jr\
SS	 j5       rSS
 jrSS jr S     SS jjrSrg)LegacyIdentityProvideri  zLegacy IdentityProvider for use with custom LoginHandlers

Login configuration has moved from LoginHandler to IdentityProvider
in Jupyter Server 2.0.
rO  c                4    U R                   U R                  S.$ )N)rM   r  )rM   r8  r)   s    r+   _default_settings(LegacyIdentityProvider._default_settings  s     ZZ,,
 	
r.   r   c                    SSK Jn  U$ )Nr   )LegacyLoginHandler)loginrg  )r*   rg  s     r+   _default_login_handler_class3LegacyIdentityProvider._default_login_handler_class  s    -!!r.   c                    U R                   $ r'   )r   r)   s    r+   r   #LegacyIdentityProvider.auth_enabled  s    ###r.   c                V    U R                   R                  U5      nUc  g[        U5      $ )rw   N)r   rt   rC   )r*   rs   r   s      r+   rt   LegacyIdentityProvider.get_user  s+    ''009<$T**r.   c                ^    [        U R                  R                  U R                  5      5      $ r'   )r,  r   get_login_availablerO  r)   s    r+   r   &LegacyIdentityProvider.login_available
  s*    $$88
 	
r.   c                J    [        U R                  R                  U5      5      $ )zWhether we should check origin.)r,  r   r  rr   s     r+   r  *LegacyIdentityProvider.should_check_origin  s    D,,@@IJJr.   c                J    [        U R                  R                  U5      5      $ )z#Whether we are token authenticated.)r,  r   r  rr   s     r+   r  -LegacyIdentityProvider.is_token_authenticated  s    D,,CCGLMMr.   Nc                   U R                   (       a  U R                  (       d  U R                  R                  [	        S5      5        U R                  R                  [	        S5      5        U R                  R                  [	        S5      5        [
        R                  " S5        U R                  R                  X5        g)zValidate security.rU  rV  rW  r   N)	rY  r8  r   rZ  r   r[  r\  r   r  )r*   r  r  s      r+   r  (LegacyIdentityProvider.validate_security  s     !!4+?+?HHVW HHe$WXYHHe$PQRHHQK  22	
r.   r:   r%  r_  r+  r'   r-  )r3   r4   r5   r6   r7   r   rO  r   rd  ri  r4  r   rt   r   r  r  r  r9   r:   r.   r+   rb  rb    s     vHZ
 
 "#" $"
 $ $+ 
 
KN 04

 -
 
	
 
r.   rb  )r@   r.  r$  r    )1r7   
__future__r   r]   r   r   rV   r1  r[  typingrh   r   dataclassesr   r   http.cookiesr   tornador   r   r	   	traitletsr
   r   r   r   r   r   r   r   r   traitlets.configr   jupyter_server.transutilsr   securityr   r   utilsr   r2  r   Literalrj   r    rC   rE   r6  rb  r:   r.   r+   <module>r     s    #    	 	 
   )  ) ) Z Z Z 0 + 0 )

?+ TU +* +* +*\:q* qh/ DA
5 A
r.   