Using Cerbos from client code (server exposed to w...
# community
Using Cerbos from client code (server exposed to web over HTTP)
Just got set up with Cerbos, super quick and easy, very impressed. Thanks for the great docs šŸ™‚ For our experiment we're using it from frontend code using the
module. This obviously means that the Cerbos server is exposed to the public internet. I'm a bit uncomfortable with this, but you support this pattern so I thought there must be some sense to it!
Only one question really, I assume JWT is the only method available for security on the HTTP endpoint?
Hey, I'll point you to a couple of replies to similar questions: ā€¢ ā€¢ Let me know if you need further clarifications
So if I understand correctly, using JWT in the config won't actually block non-JWT requests, it's purely for convenience?
Is it on your roadmap to enable
'ing requests with no/bad jwt?
the result will always be DENY if the jwt isn't valid afaik
The JWT config in Cerbos is not for restricting access to the API. It's an additional data source you can use to write policy rules. If your authenticated users have some of their attributes already stored in a JWT, then you can forward that to Cerbos and avoid having to manually copy those attributes to the
of the API request.
Just did a quick test and sending an invalid JWT responded with
Copy code
  "code": 3,
  "message": "failed to extract auxData"
That's good enough for me! At least we'll have some clarity around bogus requests and whatnot. It would be great if we could other non-essential endpoints in production (eg the html docs, swagger.json) but I recognise this isn't much of a security concern... šŸ™‚
Quick follow-up question! Is there to way to use symmetric HS256 keys (our keys are signed server-side) or is it asymmetric only? (Did my test with RS256 and docs seem to suggest that's the only supported method.) (Won't really be a problem, just curious!)
I haven't tested that but it should be possible. All the standard JWT algorithms are supported.
I ask because it wants a JWK, and I'm not sure it's possible to create a JWK for a symmetric HS key...
You could provide a PEM file as well.
Do you have any advice on how this might work? Have just tried with an Auth0 HS key and PEM but I get
Copy code
"error":"failed to parse JWT: key provider 0 failed: failed to find matching key: no key ID (\"kid\") specified in token"
Which isn't surprising, since an HS key doesn't have a
Apologies for the confusion. I checked the code and it appears that we can't parse tokens that don't have a
No problem, thanks for the pointers @Charith (Cerbos)! We'll figure out a workaround.