Good morning! I have small issue, where it seems that duct.middleware.buddy/authentication middleware is not applied.
:duct.router/ataraxy
{
:routes {
[:get "/dashboard"] ^:session-auth [:happypacker.handler.dashboard/index]}
:middleware {:session-auth #ig/ref :duct.middleware.buddy/authentication}}
:duct.middleware.buddy/authentication {:backend :session}}
I can now visit "/dasboard" route without having :identity key in my session. If I am not mistaken, this should be working. I'm going to try and write a test middleware and see if it also doesn't get applied.AFAIK, you need to
• authenticate (try to validate the credentials, or set :identity key as nil)
• authorize (= actually checks if the :identity key exist)
For example, /dashboard endpoint is available for authorized user but /status endpoint might be open for everyone.
I'm already authenticating manually via login handler , where i set the :identity key inside :session map of the request. I checked buddy source code. And like you said buddy.auth.wrap-authentication middleware is in my case only checking if :identity key is present in the session. When present it also adds another :identity key to the root of the request map and then one can just use buddy.auth/authenticated? on the request. I need to supply additional data inside config to tell the middleware how to handle unauthenticated requests.
So nothing wrong with duct. I just had some misconceptions about how buddy works.
This step does not raise any exceptions and is completely transparent to the user. The authentication process responsibility is to determine if a request is anonymous or is authenticated, nothing more.
This is from the docs: So yea..I should just RTFD next time 🤓