I'm working on an JSON/HTTP backend that uses cookie/access token based authentication, modelled after https://haskell-servant.readthedocs.io/en/stable/tutorial/Authentication.html#generalized-authentication
Now I would like to add role based authorization to the mix. The User datatype that I use in my AuthHandler has a role attribute.
As far as I understand it, the user object is added to the context when the authentication handler runs. So I would like to access this user object.
Unfortunately, I can't really wrap my head around HasContextEntry
and
getContextEntry
- I only manage to produce compile errors, mostly something like this:
Could not deduce (HasContextEntry context val0)
arising from a use of ‘getContextEntry’
from the context (FromHttpApiData String,
HasServer api context,
HasContextEntry context (AuthHandler Request User))
bound by the instance declaration
My main issue is the TODO in Authorization.hs
- what do I need to do to fetch the user object
from the context?
Thanks in advance for any pointers :-))