SlideShare a Scribd company logo
Authentication in-rails
Experience                            Technologies

                                                       V.P. Engineering
                                                       Dec 2011 - now


                                                       Software Engineer
                                                       August 2010 – Dec 2011


                                                       Software Engineer
Mihir A. Vaidya                                        Feb 2006 – August 2010
Co-Founder and
V.P. Engineering
ReadyPulse
                                                       Software Engineer
https://www.linkedin.com/in/vaidyamihir                May 2004 – Feb 2006
https://twitter.com/mihirvaidya
                                                       Researcher
                                                       May 2003 – May 2004
•

•
•
•
    –
    –
•
    –
    –
        •
            –
            –
            –
            –
            –
            –
    –
        •
•
•
    –

•
•
•
•

    –
•

•
    http_basic_authenticate_with
        :name => "ror",
        :password => "rocks",
        :except=>[:index]
•
    –
    –
    –
        •
        •
        •
        •
    –
        •
        •   current_user, authenticate_user!
    –

•
    –
    –
    –
    –
•
    –
•
    –
    –
        •
•
    –
•
    –
•
    –
•
    –
•
    –
    –
•
•
•
•
•
•
•
•
•
•
•
•
•
    –
    –
    –
•
    –
        •

    –
    –
•
    –
        •
            –
            –
        •
            –                            
            –
                »
                    •   Perform all authentication in a HTML POPUP with your own handler pages before and after
                        Facebook OAuth calls
    –
        •
        •
            –
            –
        •
            –
            –
•
•

•

    –   Sessions#fb_auth

•
•
    –


        •
        •
•
•
    –
•
    –
    –
        •
•
    –
    –                     (session[:user_id])
    –       (current_user, authenticate_user!)
•
•
•

•

•
    –

•
    –   gem „omniauth-twitter‟
    –   gem „omniauth-facebook‟
    –   bundle install

•
    –
          •
          Rails.application.config.middleware.use OmniAuth::Builder do
              provider :twitter,
                             APP_CONFIG[:twitter]['consumer_key'],
                             APP_CONFIG[:twitter]['consumer_secret']
              provider :facebook,
                   APP_CONFIG[:facebook]['app_id'],
                   APP_CONFIG[:facebook]['app_secret'],
                   :client_options => {
                        :ssl => { :ca_file => "#{Rails.root}/config/ca-bundle.crt" }
                   }
          End

•
•                 (/auth/:provider/callback)
    –   request.env[“omniauth.auth”]
•
    –
          •
          •

•
    –
    OmniAuth.config.on_failure = -> env do
     env[ActionDispatch::Flash::KEY] ||= ActionDispatch::Flash::FlashHash.new
     env[ActionDispatch::Flash::KEY][:error] = "Authentication failed, please try again."
     SessionsController.action(:new).call(env) #call whatever controller/action that displays your signup form
    end
•
    –
    –
    –
    –

•
    –
    –
•


    –
•


•
•
    – '/auth/:provider/callback' => 'sessions#create'
•
    –
•

    –

    –
•
•
    –

    provider :identity, on_failed_registration: lambda { |env|
        # lambda is used so that the class IdentitiesController is not cached (important for dev environment).
        # That way, changes to the controller will be picked up automatically since
        #              lamda is the rack application to handle failures and not IndentitiesController#new directly



        IdentitiesController.action(:new).call(env)
    }
•
    –

•
    –
    –
•
•
    –
•
•
    –
•
•
    –
        •
    –
        •
        •
•
    –
•
    –
    –
•
    –
        •
        •
    –
    –
•
    –
        •
•
    –
    –
•
    –

        •
        •
        •
        •
        •
    –

•

•
    –

        •
            –
•
    –

•
    –
    –
    –
        •
            –

    –
•
•
•
    –
    –
        •
        •
•
    –

    –
•
•
    –
•
    –
    –
        •
    –
        •
•
    –

•
    –
    –
        •
        •

        •
•
•
•
•
    –
    –
    –
    –
        •

    –
•
•
    –   
•
    –
    –
•
    –
    –
    –       
•
    –

•
•



•

•
•
•
Authentication in-rails
Authentication in-rails
Authentication in-rails
•
    –
          •
          •
          •
    –
          •
•
    –
          •
                –
                –
                –
    –
          •
                –
                –
                –
•
•
    –   current_user
    –   authenticate_user!
•
    –
    –
    –

    –
        •   password_salt = BCrypt::Engine.generate_salt
        •   password_hash = BCrypt::Engine.hash_secret(password, password_salt)

•

    –
•
    –

•
    –

        •
    –

More Related Content

PDF
Pre auditoria trabajos_alturas
PDF
Jugando al Memory-Cuaresma
PDF
Aar fourmile fire_dct-vct_jan2011_pdf
PDF
Ekaw2010 tutorial3
PDF
CCM IDL, CORBA Component Model IDL
PDF
PDF
IASP World Conference, 2004 Bergamo, Italy
PDF
Oto Brglez - Tips for better tests
Pre auditoria trabajos_alturas
Jugando al Memory-Cuaresma
Aar fourmile fire_dct-vct_jan2011_pdf
Ekaw2010 tutorial3
CCM IDL, CORBA Component Model IDL
IASP World Conference, 2004 Bergamo, Italy
Oto Brglez - Tips for better tests

Similar to Authentication in-rails (20)

PDF
Brute Force - Lior Rotkovitch - f5 SIRT v5.pdf
PDF
Testing mit Codeception: Full-stack testing PHP framework
PPTX
Poisoning Google images
PPTX
DevOpsDaysRiga 2017: Mandi Walls - Building security into your workflow with ...
PPT
IBM Connection - customize it, #dd13
PDF
下吧开发总结
PDF
Leadership Guide, 초보팀장을 위한 리더십 가이드
PPTX
SPSPhilly - SharePoint 2010 Tips & Tricks of the Trade - Avoiding Administrat...
PPTX
SharePoint Saturday Philly - SharePoint 2010 Administrative Blunders
PDF
Getting Started With SharePoint REST API in Nintex Workflows for Office 365 I...
PPTX
Sucuri Webinar: Website Security for Web Agencies
PPTX
Google-image poisoning: How hackers use images to spread malware
KEY
memories of tumblr gear & Tumblrowl
PDF
Chaione Ember.js Training
PPTX
SharePoint 2010 - Tips and Tricks of the Trade - Avoiding Administrative Blun...
PPTX
BSides São Paulo - Trabalho no exterior e segurança de aplicações
KEY
HTML5 History & Features
PDF
Premature optimisation: The Root of All Evil
PDF
DevCommerce Conference 2016: Performance, anti-patterns e stacks pra desenvol...
PDF
Atmosphere 2014: Really large scale systems configuration - Phil Dibowitz
Brute Force - Lior Rotkovitch - f5 SIRT v5.pdf
Testing mit Codeception: Full-stack testing PHP framework
Poisoning Google images
DevOpsDaysRiga 2017: Mandi Walls - Building security into your workflow with ...
IBM Connection - customize it, #dd13
下吧开发总结
Leadership Guide, 초보팀장을 위한 리더십 가이드
SPSPhilly - SharePoint 2010 Tips & Tricks of the Trade - Avoiding Administrat...
SharePoint Saturday Philly - SharePoint 2010 Administrative Blunders
Getting Started With SharePoint REST API in Nintex Workflows for Office 365 I...
Sucuri Webinar: Website Security for Web Agencies
Google-image poisoning: How hackers use images to spread malware
memories of tumblr gear & Tumblrowl
Chaione Ember.js Training
SharePoint 2010 - Tips and Tricks of the Trade - Avoiding Administrative Blun...
BSides São Paulo - Trabalho no exterior e segurança de aplicações
HTML5 History & Features
Premature optimisation: The Root of All Evil
DevCommerce Conference 2016: Performance, anti-patterns e stacks pra desenvol...
Atmosphere 2014: Really large scale systems configuration - Phil Dibowitz
Ad

Recently uploaded (20)

PDF
Electronic commerce courselecture one. Pdf
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Empathic Computing: Creating Shared Understanding
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
cuic standard and advanced reporting.pdf
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PPTX
Big Data Technologies - Introduction.pptx
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPT
Teaching material agriculture food technology
PDF
Unlocking AI with Model Context Protocol (MCP)
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Network Security Unit 5.pdf for BCA BBA.
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
Electronic commerce courselecture one. Pdf
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Empathic Computing: Creating Shared Understanding
Review of recent advances in non-invasive hemoglobin estimation
cuic standard and advanced reporting.pdf
MIND Revenue Release Quarter 2 2025 Press Release
Big Data Technologies - Introduction.pptx
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Digital-Transformation-Roadmap-for-Companies.pptx
Teaching material agriculture food technology
Unlocking AI with Model Context Protocol (MCP)
The AUB Centre for AI in Media Proposal.docx
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Advanced methodologies resolving dimensionality complications for autism neur...
Building Integrated photovoltaic BIPV_UPV.pdf
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Reach Out and Touch Someone: Haptics and Empathic Computing
Network Security Unit 5.pdf for BCA BBA.
“AI and Expert System Decision Support & Business Intelligence Systems”
Ad

Authentication in-rails

  • 2. Experience Technologies V.P. Engineering Dec 2011 - now Software Engineer August 2010 – Dec 2011 Software Engineer Mihir A. Vaidya Feb 2006 – August 2010 Co-Founder and V.P. Engineering ReadyPulse Software Engineer https://www.linkedin.com/in/vaidyamihir May 2004 – Feb 2006 https://twitter.com/mihirvaidya Researcher May 2003 – May 2004
  • 4. – –
  • 5. – – • – – – – – – – •
  • 6. • • – • • •
  • 7. – • • http_basic_authenticate_with :name => "ror", :password => "rocks", :except=>[:index]
  • 8. – – – • • • • – • • current_user, authenticate_user! – • – – – –
  • 9.
  • 10. – – • • – • – • – • – • – – • • • • •
  • 12. • • • – – – • – • – –
  • 13. – • – – • –  – » • Perform all authentication in a HTML POPUP with your own handler pages before and after Facebook OAuth calls – • • – – • – –
  • 14.
  • 15. • • – Sessions#fb_auth •
  • 16. – • •
  • 17. • • – • – – • • – – (session[:user_id]) – (current_user, authenticate_user!) • •
  • 18. • • • – • – gem „omniauth-twitter‟ – gem „omniauth-facebook‟ – bundle install • – • Rails.application.config.middleware.use OmniAuth::Builder do provider :twitter, APP_CONFIG[:twitter]['consumer_key'], APP_CONFIG[:twitter]['consumer_secret'] provider :facebook, APP_CONFIG[:facebook]['app_id'], APP_CONFIG[:facebook]['app_secret'], :client_options => { :ssl => { :ca_file => "#{Rails.root}/config/ca-bundle.crt" } } End • • (/auth/:provider/callback) – request.env[“omniauth.auth”]
  • 19. – • • • – OmniAuth.config.on_failure = -> env do env[ActionDispatch::Flash::KEY] ||= ActionDispatch::Flash::FlashHash.new env[ActionDispatch::Flash::KEY][:error] = "Authentication failed, please try again." SessionsController.action(:new).call(env) #call whatever controller/action that displays your signup form end
  • 20. – – – – • – –
  • 21. – • •
  • 22. – '/auth/:provider/callback' => 'sessions#create' • – • – – •
  • 23. – provider :identity, on_failed_registration: lambda { |env| # lambda is used so that the class IdentitiesController is not cached (important for dev environment). # That way, changes to the controller will be picked up automatically since # lamda is the rack application to handle failures and not IndentitiesController#new directly IdentitiesController.action(:new).call(env) }
  • 24. – • – –
  • 25. • • – • • – • • – • – • • • –
  • 26. – – • – • • – – • – • • – –
  • 27. – • • • • • –
  • 28.  • • – • –
  • 29. – • – – – • – –
  • 30. • • • – – • • • – –
  • 31. • •
  • 32. – – • – • • – • – – • • •
  • 33. • • • • – – – – • –
  • 34. • • –  • – – • – – –  • – •
  • 40. – • • • – • • – • – – – – • – – – • • – current_user – authenticate_user!
  • 41. – – – – • password_salt = BCrypt::Engine.generate_salt • password_hash = BCrypt::Engine.hash_secret(password, password_salt) • –
  • 42. – • – • –