shaarli / Shaarli

The personal, minimalist, super-fast, database free, bookmarking service - community repo
https://shaarli.readthedocs.io/
Other
3.4k stars 287 forks source link

Generate JWT tokens from within Shaarli #1240

Open rasberry opened 5 years ago

rasberry commented 5 years ago

As far as I can tell, the only wat to access the Shaarli api involves generating a JWT externally to the shaarli application. I would prefer to have Shaarli to expose an end-point to generate a JWT token. This would make it easier to develop browser plugins since a separate server-side JWT generator is not required. The current secret mechanism works ok for server-side apps, but it's not great for browser based ones.

more detail below. Let me know what you think.

tl;dr

current option

The only current way to give 3rd party apps access to the api is to share the api secret with the 3rd party app. This is less than ideal

enhancement - simple version

This implementation would give an application access to the Shaarli api once a user is logged in. The use case for me is browser plugins

enhancement - more complex version

This implementation allows more general access to Shaarli, but would require a decent amount of development. The idea here is to implement fine-grained app access that the user can approve or deny.

virtadpt commented 5 years ago

This. I had to write a separate daemon to generate JWT for an integration I'm debugging.

ArthurHoaro commented 5 years ago

Thanks for this interesting feedback. I'm not an expert on the subject, but from what I understand what you're describing is more or less the workflow of the OAuth2 protocol's mechanism, right? When we chose a simple JWT auth for the API, I thought it was appropriate for a single user tool such as Shaarli. But I agree that storing the secret key locally for a client sided app isn't really secured...

Now regarding your solutions, the simple one seems nice, but is even less secured. Take the example of browser addons. If I'm logged in Shaarli on this browser, and checked the "Remember me" checkbox, any addon will be able to generate a valid JWT token without any action from me.

The more complex one is the way to go, but as you said it requires a bit of dev, which IMO isn't a priority. As far as I know, there is only one app which uses the REST API, not including our python client.