This is my first question posted here, I hope this goes well. I''m trying to work out a simple authentication system for my first Rails site using authenticate_or_request_with_http_basic. Here is the code I am using right now: def authenticate authenticate_or_request_with_http_basic do |name, pass| name == ''foo'' && pass == ''bar'' end end It works when it is like that, but I would like to be able to expand it out from there (obviously) in order to use the stored usernames and passwords of my users for them to log in. Nothing too serious, but I''m stuck trying to go from here. My User table has fields named ''username'' and ''password'' and I''m looking for some direction on how to incorporate those two fields into the above method so that I will have the users use that. Thanks for any help! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Welcome to Rails blog There is a pretty simple example in Agile web development with ROR, and the first edition of that book is available online for free (Google it) For an extensive system, go here, but it is overwhelmingly complete http://www.railsforum.com/viewtopic.php?id=14216&p=1 Don''t be afraid to post questions. You will find a very helpful bunch of people here. Good luck On May 17, 11:03 pm, Bobnation <boblmart...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> This is my first question posted here, I hope this goes well. > > I''m trying to work out a simple authentication system for my first > Rails site using authenticate_or_request_with_http_basic. Here is the > code I am using right now: > > def authenticate > authenticate_or_request_with_http_basic do |name, pass| > name == ''foo'' && pass == ''bar'' > end > end > > It works when it is like that, but I would like to be able to expand > it out from there (obviously) in order to use the stored usernames and > passwords of my users for them to log in. Nothing too serious, but I''m > stuck trying to go from here. > > My User table has fields named ''username'' and ''password'' and I''m > looking for some direction on how to incorporate those two fields into > the above method so that I will have the users use that. > > Thanks for any help!--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
You would recommend building my own authentication system instead of using the built-in help? Just making sure I understand. On May 18, 2:31 am, Ruby Freak <twscann...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Welcome to Rails blog > > There is a pretty simple example in Agile web development with ROR, > and the first edition of that book is available online for free > (Google it) > > For an extensive system, go here, but it is overwhelmingly completehttp://www.railsforum.com/viewtopic.php?id=14216&p=1 > > Don''t be afraid to post questions. You will find a very helpful bunch > of people here. > > Good luck > > On May 17, 11:03 pm, Bobnation <boblmart...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > This is my first question posted here, I hope this goes well. > > > I''m trying to work out a simple authentication system for my first > > Rails site using authenticate_or_request_with_http_basic. Here is the > > code I am using right now: > > > def authenticate > > authenticate_or_request_with_http_basic do |name, pass| > > name == ''foo'' && pass == ''bar'' > > end > > end > > > It works when it is like that, but I would like to be able to expand > > it out from there (obviously) in order to use the stored usernames and > > passwords of my users for them to log in. Nothing too serious, but I''m > > stuck trying to go from here. > > > My User table has fields named ''username'' and ''password'' and I''m > > looking for some direction on how to incorporate those two fields into > > the above method so that I will have the users use that. > > > Thanks for any help!--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I would recoment http://wiki.rubyonrails.com/rails/pages/LoginGenerator or http://wiki.rubyonrails.org/rails/pages/SaltedHashLoginGenerator On May 19, 4:07 pm, Bobnation <boblmart...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> You would recommend building my own authentication system instead of > using the built-in help? > > Just making sure I understand. > > On May 18, 2:31 am, Ruby Freak <twscann...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Welcome to Rails blog > > > There is a pretty simple example in Agile web development with ROR, > > and the first edition of that book is available online for free > > (Google it) > > > For an extensive system, go here, but it is overwhelmingly completehttp://www.railsforum.com/viewtopic.php?id=14216&p=1 > > > Don''t be afraid to post questions. You will find a very helpful bunch > > of people here. > > > Good luck > > > On May 17, 11:03 pm, Bobnation <boblmart...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > This is my first question posted here, I hope this goes well. > > > > I''m trying to work out a simple authentication system for my first > > > Rails site using authenticate_or_request_with_http_basic. Here is the > > > code I am using right now: > > > > def authenticate > > > authenticate_or_request_with_http_basic do |name, pass| > > > name == ''foo'' && pass == ''bar'' > > > end > > > end > > > > It works when it is like that, but I would like to be able to expand > > > it out from there (obviously) in order to use the stored usernames and > > > passwords of my users for them to log in. Nothing too serious, but I''m > > > stuck trying to go from here. > > > > My User table has fields named ''username'' and ''password'' and I''m > > > looking for some direction on how to incorporate those two fields into > > > the above method so that I will have the users use that. > > > > Thanks for any help!--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 18 May 2008, at 07:03, Bobnation wrote:> > This is my first question posted here, I hope this goes well. > > I''m trying to work out a simple authentication system for my first > Rails site using authenticate_or_request_with_http_basic. Here is the > code I am using right now: > > def authenticate > authenticate_or_request_with_http_basic do |name, pass| > name == ''foo'' && pass == ''bar'' > end > endSetting to one side the question of whether to roll your own authentication thing or use someone else''s, what you want here is to see whether or not a use exists with the supplied combination of name and password. This boils down to just find :first, :conditions => ["username = ? AND password = ?", name, pass] and seeing whether you get back nil (no matching record) or something else. For extra happiness bung this in the User model (eg in a method called authenticate), and look at dynamic finders (User.find_by_username_and_password(name, pass)). Fred> > > It works when it is like that, but I would like to be able to expand > it out from there (obviously) in order to use the stored usernames and > passwords of my users for them to log in. Nothing too serious, but I''m > stuck trying to go from here. > > My User table has fields named ''username'' and ''password'' and I''m > looking for some direction on how to incorporate those two fields into > the above method so that I will have the users use that. > > Thanks for any help! > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
And if you don''t roll your own, I recommend authenticated_system or restful_authentication, the latter of which is just a restful version of the former. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks to everyone for the help and discussion. I''m going to sit on this for a little bit and see what I can come up with. Thanks again! On May 19, 10:50 pm, "Ryan Bigg (Radar)" <radarliste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> And if you don''t roll your own, I recommend authenticated_system or > restful_authentication, the latter of which is just a restful version of the > former.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On May 20, 5:50 am, "Ryan Bigg (Radar)" <radarliste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> And if you don''t roll your own, I recommend authenticated_system or > restful_authentication, the latter of which is just a restful version of the > former.I second you on that, also Bobnation might want to check out the great tutorial about the RESTful Authentication plugin here : http://www.railsforum.com/viewtopic.php?id=14216 After going through the tutorial, Bobnation, you''ll have understood most of the issues of an authenticated login system AND the RESTful way of doing things in Rails 2.0. Hardly a waste of time ;) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Bobnation wrote:> Thanks to everyone for the help and discussion. I''m going to sit on > this for a little bit and see what I can come up with. Thanks again! > > On May 19, 10:50 pm, "Ryan Bigg (Radar)" <radarliste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: >> And if you don''t roll your own, I recommend authenticated_system or >> restful_authentication, the latter of which is just a restful version of the >> former.I saw a link to a restful_authentication tutorial from the ruby forums in this thread and thought I''d add my own tutorial in case you find it helpful. I won''t try and tell you mine''s better, just different, and I''ve always found that learning something in more than one way helps me really get a grasp of the subject. http://railsdotnext.com/ It''s in blog format so it reads back-to-front. Step one is here: http://railsdotnext.com/2008/02/16/web-bookmarks-on-rails-step-one/ The tutorial has more commentary/explanatory text than most. It''s written for the Linux command line and has instructions for keeping track of things in subversion along the way, though it would be easy enough to just skip those steps. - Aaron --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks, your tutorial looks really interesting so I might peruse it to try and pick things form it that I might need. Right now I think I''m in the middle of knowing a little Rails but not enough to really get going ... so the frustrating stage. I''m hoping I''ll get through this and then get to the fun part. :) On May 21, 8:35 am, Aaron Brown <aarondaltonbr...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Bobnation wrote: > > Thanks to everyone for the help and discussion. I''m going to sit on > > this for a little bit and see what I can come up with. Thanks again! > > > On May 19, 10:50 pm, "Ryan Bigg (Radar)" <radarliste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > wrote: > >> And if you don''t roll your own, I recommend authenticated_system or > >> restful_authentication, the latter of which is just a restful version of the > >> former. > > I saw a link to a restful_authentication tutorial from the ruby forums > in this thread and thought I''d add my own tutorial in case you find it > helpful. I won''t try and tell you mine''s better, just different, and > I''ve always found that learning something in more than one way helps me > really get a grasp of the subject. > > http://railsdotnext.com/ > > It''s in blog format so it reads back-to-front. Step one is here:http://railsdotnext.com/2008/02/16/web-bookmarks-on-rails-step-one/ > > The tutorial has more commentary/explanatory text than most. It''s > written for the Linux command line and has instructions for keeping > track of things in subversion along the way, though it would be easy > enough to just skip those steps. > > - Aaron--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---