Identity#

Starting with JupyterLab v3.6, user identity builds on top of theIdentityProvider and the endpoint/api/meintroduced in Jupyter Server v2 as part of the authentication. The/api/me endpoint returns a dictionarywith the user’s identity and their permissions. Please check out itsdocumentationto know more about the identity model implemented in Jupyter Server.

The user identity API was included in JupyterLab as part of the service package by adding a new service calledUserManager to theServiceManager.This new service periodically requests the user identity to the/api/me endpoint and keeps the information in memory until the next request. Nevertheless, it is alwayspossible to refresh the information manually by calling therefreshUser method. Once the service is ready,it is possible to access the user’s identity through the propertyidentity or listen for changes by subscribingto the signaluserChanged.

Example:

constextension:JupyterFrontEndPlugin<void>={id:'jupyterlab-extension',autoStart:true,activate:(app:JupyterFrontEnd)=>{constuser=app.serviceManager.user;user.ready.then(()=>{console.debug('Identity:',user.identity);console.debug('Permissions:',user.permissions);});}};