duct-framework / module.ataraxy

Duct module and router for the Ataraxy routing library
5 stars 4 forks source link

Some example with middleware.buddy? #4

Closed hden closed 6 years ago

hden commented 6 years ago

I can't seem to get it to work.

{:duct.core/project-ns   foo
 :duct.module/ataraxy    {"/" ^:auth/basic[:index]}
 :foo.handler/index      {}
 :duct.middleware.buddy/authentication
 {:backend :basic
  :realm   "Example"
  :authfn  #ig/ref :example.auth/basic}
 :example.auth/basic {}}

Thanks in advance.

weavejester commented 6 years ago

Your Buddy authentication middleware is:

:duct.middleware.buddy/authentication

But the Ataraxy module expects the middleware to be in the following form to be included automatically (see the README):

:foo.middleware[.<namespace>]/<name>

This means you'll need to put the middleware binding in manually. If you take a look at the advanced section of the README, it shows you an example. In your case, you want something like:

:duct.module/ataraxy  {"/" ^:auth/basic [:index]}
:duct.handler/ataraxy {:auth/basic #ig/ref :duct.middleware.buddy/authentication}

Also note that the Buddy authentication doesn't limit access to pages. For that, the restrict function is necessary.

hden commented 6 years ago

Cool. Thanks!