I am getting closer, I think. I changed the keys from keywords to strings and that seemed to let me login. But if I go to /logout, I get:
2013-01-16 11:37:25.875:WARN:oejs.AbstractHttpConnection:/logout java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IPersistentMap at clojure.lang.RT.dissoc(RT.java:747) at clojure.core$dissoc.invoke(core.clj:1405) at clojure.lang.AFn.applyToHelper(AFn.java:163) at clojure.lang.RestFn.applyTo(RestFn.java:132) at clojure.core$apply.invoke(core.clj:603) at clojure.core$update_in.doInvoke(core.clj:5472) at clojure.lang.RestFn.invoke(RestFn.java:467) at cemerick.friend$logout_STAR_.invoke(friend.clj:69) at cemerick.friend$logout$fn__496.invoke(friend.clj:76) at compojure.core$routing$fn__260.invoke(core.clj:106) at clojure.core$some.invoke(core.clj:2390) at compojure.core$routing.doInvoke(core.clj:106) at clojure.lang.RestFn.applyTo(RestFn.java:139) at clojure.core$apply.invoke(core.clj:603) at compojure.core$routes$fn__264.invoke(core.clj:111) at cemerick.friend$authenticate_STAR_.invoke(friend.clj:195) at cemerick.friend$authenticate$fn__526.invoke(friend.clj:207) at ring.middleware.resource$wrap_resource $fn__15.invoke(resource.clj:17) at ring.middleware.session$wrap_session $fn__170.invoke(session.clj:43) at ring.middleware.cookies$wrap_cookies $fn__108.invoke(cookies.clj:160) at ring.middleware.cookies$wrap_cookies $fn__108.invoke(cookies.clj:160) at ring.middleware.keyword_params$wrap_keyword_params $fn__139.invoke(keyword_params.clj:27) at ring.middleware.nested_params$wrap_nested_params $fn__321.invoke(nested_params.clj:65) at ring.middleware.params$wrap_params $fn__113.invoke(params.clj:55) at clojure.lang.Var.invoke(Var.java:415) at ring.adapter.jetty$proxy_handler$fn__355.invoke(jetty.clj: 18) at ring.adapter.jetty.proxy $org.eclipse.jetty.server.handler.AbstractHandler$0.handle(Unknown Source) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java: 111) at org.eclipse.jetty.server.Server.handle(Server.java:349) at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java: 452) at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java: 884) at org.eclipse.jetty.server.AbstractHttpConnection $RequestHandler.headerComplete(AbstractHttpConnection.java:93\ 8) at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java: 634) at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:230) at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java: 76) at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java: 609) at org.eclipse.jetty.io.nio.SelectChannelEndPoint $1.run(SelectChannelEndPoint.java:45) at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java: 599) at org.eclipse.jetty.util.thread.QueuedThreadPool $3.run(QueuedThreadPool.java:534) at java.lang.Thread.run(Thread.java:722) I think going to /logout should erase the session values and then redirect to the homepage? On 16 Sty, 11:31, larry google groups <lawrencecloj...@gmail.com> wrote: > Oh, I think I figured this out. I re-read this: > > https://github.com/cemerick/friend/#authentication > > And I see the keys here are strings: > > (def users {"root" {:username "root" > :password (creds/hash-bcrypt "admin_password") > :roles #{::admin}} > "jane" {:username "jane" > :password (creds/hash-bcrypt "user_password") > :roles #{::user}}}) > > I switched to keywords when I implemented this in my own code. When I > copy and paste this map (above) into my code, and use "root" and > "admin_password" to login, it seems to work. > > On 16 Sty, 11:20, larry google groups <lawrencecloj...@gmail.com> > wrote: > > > > > > > > > > You're still not using wrap-keyword-params. > > > Thanks. I changed the routes so I now have: > > > (def app > > (-> app-routes > > (friend/authenticate {:credential-fn (partial creds/bcrypt- > > credential-fn (:users @interactions)) > > :workflows [(workflows/interactive- > > form)]}) > > (wrap-resource "public") > > (wrap-session {:cookie-name "discovery-session" :cookie-attrs > > {:max-age 10000 }}) > > (wrap-cookies) > > (wrap-keyword-params) > > (wrap-nested-params) > > (wrap-params))) > > > Then I go here with my browser: > > > localhost:40000/login > > > and I copy and paste the username and password from the :users map > > inside of @interactions. Then I hit the submit button. I get > > redirected back to the login page. The URL is now: > > >http://localhost:40000/login?&login_failed=Y&username=lawrence > > > I am trying to think of what I can change so I can see some of the > > intermediate steps. How do I debug this and find out what the point of > > failure is? Part of me is thinking that I could clone Friend from > > github and build my own custom version of it, with debugging code > > throughout it. But most of me thinks that is stupid, since it works > > for others, so the problem can not be in Friend, it must be something > > that I am doing. > > > ---- lawrence > > > On 16 Sty, 09:55, Chas Emerick <c...@cemerick.com> wrote: > > > > On Jan 16, 2013, at 9:07 AM, larry google groups wrote: > > > > > I define a var with user info like this: > > > > > (ns kiosks-clojure.fake-data-for-development > > > > (:require [cemerick.friend :as friend] > > > > (cemerick.friend [workflows :as workflows] > > > > [credentials :as creds]))) > > > > (def fake-data > > > > { > > > > :users {:root {:username "la...@wonderful.com" > > > > :password (creds/hash-bcrypt "admin_password") > > > > :roles #{::admin} > > > > :created_at "2013-01-08 14:00:00" > > > > :telephone-numbers [{:country "USA" :number "434 825 > > > > 7694"} > > > > {:country "USA" :number "732 364 > > > > 3640"}]} > > > > :jane {:username "j...@wonderful.com" > > > > :password (creds/hash-bcrypt "user_password") > > > > :roles #{::user} > > > > :created_at "2013-01-10 16:40:34" > > > > :telephone-numbers []}} > > > > }) > > > > > Then in my core namespace, I add this to an atom: > > > > > (def interactions (atom fd/fake-data)) > > > > > And then later I fetch this and add this to the authentication of > > > > friend: > > > > > (def app > > > > (-> app-routes > > > > (friend/authenticate {:credential-fn (partial creds/bcrypt- > > > > credential-fn (:users @interactions)) > > > > :workflows [(workflows/interactive- > > > > form)]}) > > > > (wrap-resource "public") > > > > (wrap-session {:cookie-name "discovery-session" :cookie-attrs > > > > {:max-age 10000 }}) > > > > (wrap-cookies) > > > > (wrap-params))) > > > > > Any thoughts about where I should try to debug this? > > > > You're still not using wrap-keyword-params. > > > > - Chas -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en