You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 18, 2023. It is now read-only.
311: RFC: read-only access JWT tokens r=psarna a=psarna
I wanted to quickly evaluate how we could add coarse-grained access control to sqld with JWT and came up with this short patch, I'd be grateful for any comments/opinions.
The mechanism of authenticating JWT is extended a little bit. So far we only cared if the token is there and is valid. What JWT offers is an easily extensible mechanism for "claims", which is more or less just a JSON object which allows you to define properties that the token bearer holds. This patch introduces another JWT claim, with a working name "access". If this field is set to "read-only", `sqld` will refuse to execute any requests except ones categorized as reads.
The change turned out to be extremely small and took ~30 minutes tests included, since thanks to `@MarinPostma's` work we already categorize queries anyway.
The class of use cases I have in mind here are browser apps. We certainly don't want to push full access tokens to users' browsers, but it might be just fine to "leak" a read-only token that lets you access the database, but not modify it. To bring a concrete example, one of my demo apps I use for testing sqld (http://sorry.idont.date) would no longer need to run on Cloudflare Workers and could instead fetch data straight from the browser - far edge!
Co-authored-by: Piotr Sarna <[email protected]>
0 commit comments