Re: Interactive form workflow with Friend, can't log in

2012-11-13 Thread Haim Ashkenazi
Hi

On Mon, Nov 12, 2012 at 9:23 PM, Thorsten Wilms t...@freenet.de wrote:

 On 11/12/2012 03:20 PM, Chas Emerick wrote:

 Looks like you're not using the keyword-params middleware, which
 Friend requires (among others).  Please check the last paragraph in
 the 'Authentication' section here:

 https://github.com/cemerick/**friend/#authenticationhttps://github.com/cemerick/friend/#authentication

 Once you add that, then the interactive-form middleware will pick up
 the form data you're submitting.


 I tried to make sense of that in wrapping my main handler in authenticate
 in wrap-keyword-params, later also adding wrap-session, wrap-params and
 wrap-nested params.

 I still get a redirect to http://localhost:8080/login?**
 login_failed=Yusername=http://localhost:8080/login?login_failed=Yusername=

 So please, how/where shall I *add* wrap-keyword-params (and the others?)
 exactly?

Here's how you wrap your application with middleware (root-routes is your
main routes:

(def app
  (- #'root-routes
   (friend/authenticate …)
   (wrap-keyword-params)
   (wrap-params)
   …))

Now following your example you can
(web/start app)

note that the above set of middleware are just sample. I have no idea if
this is all you need. If you'll use the hiccup library you have a
'handler/site' function that includes many of the required middleware you
need for a website (you can also just check the documentation to see the
list of middleware it uses).

In order to learn more about middleware check the *middleware* section here:
https://github.com/ring-clojure/ring/wiki/Concepts

Also, the friend repository has a mock application you can check:
https://github.com/cemerick/friend/blob/master/test/test_friend/mock_app.clj

HTH
-- 
Haim

-- 
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

Re: Interactive form workflow with Friend, can't log in

2012-11-13 Thread Thorsten Wilms

On 11/13/2012 12:28 PM, Haim Ashkenazi wrote:

Here's how you wrap your application with middleware (root-routes is
your main routes:

(def app
   (- #'root-routes
(friend/authenticate …)
(wrap-keyword-params)
(wrap-params)
…))

Now following your example you can
(web/start app)


Thank you! I had something similar already, but my testing got thwarted 
by expecting too much of ring-reload. Now the following does the trick:


(def secured-app
  (- #'root-routes
  (friend/authenticate {:credential-fn (partial 
creds/bcrypt-credential-fn users)

:workflows [(workflows/interactive-form)]})
  wrap-keyword-params
  wrap-params
  (wrap-session {:store (immutant-session/servlet-store)})))

(web/start secured-app :reload true)


Finding this example helped:
https://github.com/marianoguerra/immutant-recipes/tree/master/friend-acl


--
Thorsten Wilms

thorwil's design for free software:
http://thorwil.wordpress.com/

--
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


Interactive form workflow with Friend, can't log in

2012-11-12 Thread Thorsten Wilms

Hi!

I'm trying to use Friend with the interactive form workflow. Whenever I 
try to login, I get a redirect to

http://localhost:8080/login?login_failed=Yusername=

The body of the POST my form generates does include username and password.

My code:
https://www.refheap.com/paste/6569

This version does not specify encoding and thus falls back to some 
windows encoding, but a later version with a full html5 body with utf-8 
shows the same result.


Where's my mistake, or what can I do to further diagnose the problem?


--
Thorsten Wilms

thorwil's design for free software:
http://thorwil.wordpress.com/

--
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


Re: Interactive form workflow with Friend, can't log in

2012-11-12 Thread Chas Emerick
Looks like you're not using the keyword-params middleware, which Friend 
requires (among others).  Please check the last paragraph in the 
'Authentication' section here:

https://github.com/cemerick/friend/#authentication

Once you add that, then the interactive-form middleware will pick up the form 
data you're submitting.

Cheers,

- Chas

--
http://cemerick.com
[Clojure Programming from O'Reilly](http://www.clojurebook.com)

On Nov 12, 2012, at 7:59 AM, Thorsten Wilms wrote:

 Hi!
 
 I'm trying to use Friend with the interactive form workflow. Whenever I try 
 to login, I get a redirect to
 http://localhost:8080/login?login_failed=Yusername=
 
 The body of the POST my form generates does include username and password.
 
 My code:
 https://www.refheap.com/paste/6569
 
 This version does not specify encoding and thus falls back to some windows 
 encoding, but a later version with a full html5 body with utf-8 shows the 
 same result.
 
 Where's my mistake, or what can I do to further diagnose the problem?
 
 
 -- 
 Thorsten Wilms
 
 thorwil's design for free software:
 http://thorwil.wordpress.com/
 
 -- 
 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

-- 
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


Re: Interactive form workflow with Friend, can't log in

2012-11-12 Thread Thorsten Wilms

On 11/12/2012 03:20 PM, Chas Emerick wrote:

Looks like you're not using the keyword-params middleware, which
Friend requires (among others).  Please check the last paragraph in
the 'Authentication' section here:

https://github.com/cemerick/friend/#authentication

Once you add that, then the interactive-form middleware will pick up
the form data you're submitting.


I tried to make sense of that in wrapping my main handler in 
authenticate in wrap-keyword-params, later also adding wrap-session, 
wrap-params and wrap-nested params.


I still get a redirect to 
http://localhost:8080/login?login_failed=Yusername=


So please, how/where shall I *add* wrap-keyword-params (and the others?) 
exactly?



--
Thorsten Wilms

thorwil's design for free software:
http://thorwil.wordpress.com/

--
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