SlideShare una empresa de Scribd logo
1 de 28
Warden
General Rack Authentication
Many Web Apps Need
1. A User
2. A way to associate it
     with a request
Many Solutions Exist
•                            •
    Restful Authentication       Basic Auth

•                            •
    AuthLogic                    Digest

•                            •
    Merbful Authentication       LAPD

•                            •
    Merb-Auth                    CAS

•   Home Grown

•   OpenID
Why Another One?
Rack
Rack Router
class SimpleRack
  include Rack::Router::Routable

  def initialize
    prepare do |r|
      r.map quot;/quot;, :to => router { |c| c.map quot;/helloquot;, :to => ChildApp }
      r.map quot;/helloquot;, :to => ParentApp
      r.map quot;/onequot;, :to => lambda { |env| do_one(env) }
      r.map quot;/twoquot;, :to => lambda { |env| do_two(env) }
    end
  end

  def do_one(env)
    # Stuff
  end

  def do_two(env)
    # Stuff
  end
end
Mountable Apps
How Will Your
Authentication Cope?
Apps Usually Need a
      “User”
Current Breed Will
Conflict Between Apps
Warden
• Injects a very lazy proxy into the request
• Proxy follows around in the request
• Does nothing until you ask it
• Authenticates Requests for any kind of
  “User”
• Provides a mechanism for Authentication
• Available in all downstream Rack parts
Authenticating
              (Logging In)

env['warden'].authenticate     :password

env['warden'].authenticate!    :password, :basic, :open_id

env['warden'].authenticated?   :password
Accessing The User

   env['warden'].user
Logging Out

env['warden'].logout
Authentication Logic

• Strategy Based
• Packagable
• Sharable between discrete Apps
• Simple
Strategy
Warden::Strategies.add(:password) do

  def valid?
    params[:username] || params[:password]
  end

  def authenticate!
    u = User.authenticate(params[:username], params[:password])
    u.nil? ? fail!(quot;Could not log inquot;) : success!(u)
  end
end
Strategies

    • Multiple Strategies
    • Strategies Cascade

env['warden'].authenticate!   :password, :basic, :open_id
Failure

 throw(:warden)

 throw(:warden, :some => :option)




Drops out to a “Failure Application”
Rack Setup
Rack::Builder.new do
  use Rack::Session::Cookie

  use Warden::Manager do |manager|
    manager.default_strategies :password, :basic
    manager.failure_app = BadAuthenticationEndsUpHere
  end

  run SomeApp
end
Session Integration


Warden::Manager.serialize_into_session{ |user| user.id }



Warden::Manager.serialize_from_session{ |key| User.get(id)}
Other Features

• Callbacks
• User Scopes - Multiple Users / session
• Authenticated Session Data
 • Locks Session per user
Rails Integration
                  config/initializers/warden.rb
Rails.configuration.middleware.use Warden::Manager do |manager|
  manager.default_strategies :password
  manager.failure_app = LoginController
end



# Rails needs the action to be passed in with the params
Warden::Manager.before_failure do |env, opts|
  request = env[quot;action_controller.rescue.requestquot;]
  request.params[quot;actionquot;] = quot;unauthenticatedquot;
end

# Session Serialization & Strategies
More Information

• http://github.com/hassox/warden

• http://wiki.github.com/hassox/warden

Más contenido relacionado

La actualidad más candente

CEO-028-QBQ的五項修煉Ok
CEO-028-QBQ的五項修煉OkCEO-028-QBQ的五項修煉Ok
CEO-028-QBQ的五項修煉Ok
handbook
 
School admission process management system (Documention)
School admission process management system (Documention)School admission process management system (Documention)
School admission process management system (Documention)
Shital Kat
 
Oosd shopping (1)
Oosd shopping (1)Oosd shopping (1)
Oosd shopping (1)
shaj13
 
Important bangla spelling rules by tanbircox
Important bangla spelling rules by tanbircoxImportant bangla spelling rules by tanbircox

La actualidad más candente (17)

MOVIE TICKET BOOKING-COMPUTER SCIENCE C++ PROJECT
MOVIE TICKET BOOKING-COMPUTER SCIENCE C++ PROJECTMOVIE TICKET BOOKING-COMPUTER SCIENCE C++ PROJECT
MOVIE TICKET BOOKING-COMPUTER SCIENCE C++ PROJECT
 
Computer networking step by step
Computer networking step by stepComputer networking step by step
Computer networking step by step
 
CEO-028-QBQ的五項修煉Ok
CEO-028-QBQ的五項修煉OkCEO-028-QBQ的五項修煉Ok
CEO-028-QBQ的五項修煉Ok
 
Mini Project presentation for MCA
Mini Project presentation for MCAMini Project presentation for MCA
Mini Project presentation for MCA
 
Computer science project
Computer science projectComputer science project
Computer science project
 
Hostel management system (5)
Hostel management system (5)Hostel management system (5)
Hostel management system (5)
 
مساٸل نماز۔رفعت قاسمی ؒ۔.pdf
مساٸل نماز۔رفعت قاسمی ؒ۔.pdfمساٸل نماز۔رفعت قاسمی ؒ۔.pdf
مساٸل نماز۔رفعت قاسمی ؒ۔.pdf
 
Baekjoon Online Judge 2873번 풀이
Baekjoon Online Judge 2873번 풀이Baekjoon Online Judge 2873번 풀이
Baekjoon Online Judge 2873번 풀이
 
مساٸل سجدہ سہو۔منصورپوری.pdf
مساٸل سجدہ سہو۔منصورپوری.pdfمساٸل سجدہ سہو۔منصورپوری.pdf
مساٸل سجدہ سہو۔منصورپوری.pdf
 
ApartmentADDA - India's #1 Apartment Management and Accounting Platform
ApartmentADDA - India's #1 Apartment Management and Accounting PlatformApartmentADDA - India's #1 Apartment Management and Accounting Platform
ApartmentADDA - India's #1 Apartment Management and Accounting Platform
 
Final project presentation CSE
Final project presentation CSEFinal project presentation CSE
Final project presentation CSE
 
School admission process management system (Documention)
School admission process management system (Documention)School admission process management system (Documention)
School admission process management system (Documention)
 
Business Plan Student Information Management System
Business Plan Student Information Management SystemBusiness Plan Student Information Management System
Business Plan Student Information Management System
 
Online Hostel Management System Proposal
Online Hostel Management System Proposal Online Hostel Management System Proposal
Online Hostel Management System Proposal
 
Oosd shopping (1)
Oosd shopping (1)Oosd shopping (1)
Oosd shopping (1)
 
Important bangla spelling rules by tanbircox
Important bangla spelling rules by tanbircoxImportant bangla spelling rules by tanbircox
Important bangla spelling rules by tanbircox
 
Hostel management system Software Engineering SRS
Hostel management system Software Engineering SRSHostel management system Software Engineering SRS
Hostel management system Software Engineering SRS
 

Destacado

Wildlife careers powerpoint
Wildlife careers powerpointWildlife careers powerpoint
Wildlife careers powerpoint
jhadachek
 
Tugas warden asrama
Tugas warden asramaTugas warden asrama
Tugas warden asrama
fakurol
 

Destacado (12)

Rack for User Authentication
Rack for User AuthenticationRack for User Authentication
Rack for User Authentication
 
Demystifying Warden
Demystifying WardenDemystifying Warden
Demystifying Warden
 
Devise and Rails
Devise and RailsDevise and Rails
Devise and Rails
 
Wildlife careers powerpoint
Wildlife careers powerpointWildlife careers powerpoint
Wildlife careers powerpoint
 
Meet the U.S. Fish and Wildlife Service
Meet the U.S. Fish and Wildlife ServiceMeet the U.S. Fish and Wildlife Service
Meet the U.S. Fish and Wildlife Service
 
Game Warden
Game WardenGame Warden
Game Warden
 
React Ecosystem
React EcosystemReact Ecosystem
React Ecosystem
 
Tugas warden asrama
Tugas warden asramaTugas warden asrama
Tugas warden asrama
 
Contoh fail meja ppm
Contoh fail meja ppmContoh fail meja ppm
Contoh fail meja ppm
 
Ethnographic research
Ethnographic researchEthnographic research
Ethnographic research
 
Security best practices for kubernetes deployment
Security best practices for kubernetes deploymentSecurity best practices for kubernetes deployment
Security best practices for kubernetes deployment
 
Railsチュートリアルの歩き方 (第4版)
Railsチュートリアルの歩き方 (第4版)Railsチュートリアルの歩き方 (第4版)
Railsチュートリアルの歩き方 (第4版)
 

Similar a Warden Introduction

Zend Framework Study@Tokyo Vol1
Zend Framework Study@Tokyo Vol1Zend Framework Study@Tokyo Vol1
Zend Framework Study@Tokyo Vol1
Shinya Ohyanagi
 
Zend Framework Study@Tokyo vol1
Zend Framework Study@Tokyo vol1Zend Framework Study@Tokyo vol1
Zend Framework Study@Tokyo vol1
Shinya Ohyanagi
 
Android Bootcamp
Android   BootcampAndroid   Bootcamp
Android Bootcamp
ahkjsdcsadc
 
Zembly Programming Language
Zembly Programming LanguageZembly Programming Language
Zembly Programming Language
zembly
 
Hacking Client Side Insecurities
Hacking Client Side InsecuritiesHacking Client Side Insecurities
Hacking Client Side Insecurities
amiable_indian
 

Similar a Warden Introduction (20)

Zend Framework Study@Tokyo Vol1
Zend Framework Study@Tokyo Vol1Zend Framework Study@Tokyo Vol1
Zend Framework Study@Tokyo Vol1
 
Zend Framework Study@Tokyo vol1
Zend Framework Study@Tokyo vol1Zend Framework Study@Tokyo vol1
Zend Framework Study@Tokyo vol1
 
Android Bootcamp
Android   BootcampAndroid   Bootcamp
Android Bootcamp
 
Zembly Programming Language
Zembly Programming LanguageZembly Programming Language
Zembly Programming Language
 
Building Mobile Friendly APIs in Rails
Building Mobile Friendly APIs in RailsBuilding Mobile Friendly APIs in Rails
Building Mobile Friendly APIs in Rails
 
Streamlining Your Applications with Web Frameworks
Streamlining Your Applications with Web FrameworksStreamlining Your Applications with Web Frameworks
Streamlining Your Applications with Web Frameworks
 
GDD Japan 2009 - Designing OpenSocial Apps For Speed and Scale
GDD Japan 2009 - Designing OpenSocial Apps For Speed and ScaleGDD Japan 2009 - Designing OpenSocial Apps For Speed and Scale
GDD Japan 2009 - Designing OpenSocial Apps For Speed and Scale
 
AMS Node Meetup December presentation Phusion Passenger
AMS Node Meetup December presentation Phusion PassengerAMS Node Meetup December presentation Phusion Passenger
AMS Node Meetup December presentation Phusion Passenger
 
FreeBSD: Dev to Prod
FreeBSD: Dev to ProdFreeBSD: Dev to Prod
FreeBSD: Dev to Prod
 
Skype Development Techniques and Tools
Skype Development Techniques and ToolsSkype Development Techniques and Tools
Skype Development Techniques and Tools
 
Dancing with websocket
Dancing with websocketDancing with websocket
Dancing with websocket
 
Static Analysis Techniques For Testing Application Security - Houston Tech Fest
Static Analysis Techniques For Testing Application Security - Houston Tech FestStatic Analysis Techniques For Testing Application Security - Houston Tech Fest
Static Analysis Techniques For Testing Application Security - Houston Tech Fest
 
Service workers - Forza lavoro al servizio della tua Performance
Service workers - Forza lavoro al servizio della tua PerformanceService workers - Forza lavoro al servizio della tua Performance
Service workers - Forza lavoro al servizio della tua Performance
 
Damage Control
Damage ControlDamage Control
Damage Control
 
An Introduction To Android
An Introduction To AndroidAn Introduction To Android
An Introduction To Android
 
Hacking Client Side Insecurities
Hacking Client Side InsecuritiesHacking Client Side Insecurities
Hacking Client Side Insecurities
 
2011 a grape odyssey
2011   a grape odyssey2011   a grape odyssey
2011 a grape odyssey
 
When To Use Ruby On Rails
When To Use Ruby On RailsWhen To Use Ruby On Rails
When To Use Ruby On Rails
 
Hybrid application development
Hybrid application developmentHybrid application development
Hybrid application development
 
How Not To Code Flex Applications
How Not To Code Flex ApplicationsHow Not To Code Flex Applications
How Not To Code Flex Applications
 

Último

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Último (20)

Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 

Warden Introduction

Notas del editor