Possible to do personalized analytics?

Hi,

Suppose I have some analytics app that requires authentication (either through bokeh’s authenticator or Django’s authentication system)… Is there a way to pass this user information to panel in order to offer personalized analytics?

This would be useful for things like returning to a user’s last dashboard state, or offer the ability for them to access 3rd party services with some API credentials they had saved to our database.

2 Likes

I would look in two places.

  1. I know Phillip is working on easy Auth for Panel. So you can look for that Pr on github and see if there is anything in the new code you can use. If not do a feature request.

I would expect something like a user, user I’d or user token to be available as a secure cookie in the request. I would expect you could get access to that.

  1. I have tried implementing Auth a described in the bokeh docs. Both simple Auth and azure ad Auth. I did an implementation based on msal package. Again that was based on setting a secure user cookie.

I also need to be able to get the user. But for personalization of the app, restricting access and using the user token to get access to data services.

If possible, please share your findings. Thanks.

2 Likes

Thanks for your input!
I’ll check on what Philip is up to.

Will make sure to share if I find a solution.

1 Like

A little update on that:

On Github, I found some examples on pn.state, and how it includes ‘pn.state.cookies’, which lets you access the current browser cookies.

And if you use i.e. the bokeh auth module, you get to access the currently logged-in user like this:

{'__cfduid': 'da5f2e71beec882f8fdc38319330a61561593875339', 'csrftoken': 'UqBRAZ4jtuG2hcSoIz2hVVLfJOe8wVXQM715x3IzoTNRBXymLz5MEqdoNwNaDSbw', 'sessionid': 'wo5bb5j1wzsrwkhflwqrr361ncqlfsbi', '_xsrf': '2|1bde6561|c8dc9804ebbfad296666ba8028d83764|1595704372', 'user': '"bokeh"'}

You can then just extract that user from within the panel app with

pn.state.cookies['user']

Example:

Also, it looks like the next version of Panel will support OAuth.

Haven’t tried it with Django yet. Ultimately, I’d want to get the currently logged in Django user instead of using bokeh’s auth module.

1 Like