Upload
hieu-nguyen-trung
View
218
Download
1
Embed Size (px)
Citation preview
Introduce to Warden@hieuk09
about(me)
• @hieuk09
• Ruby Developer at TINYpulse
Why warden?
A peek at Devise
• 3178 commits
• 8311 LOC
• ~70 dependencies
• Only compatible with Rails
Warden
• A devise dependencies
• 287 commits
• 733 LOC
• ~ 20 dependencies
• Compatible with all Rack applications
What is warden?
• “Warden provides a mechanism for authentication in Rack based Ruby applications"
Some concepts
• Strategy
• Failure
• Callback
• User & Scope
• Session
Strategy
• How you authenticate
• Password
• OAuth
• Implement 2 methods: valid? & authenticate!
Failure
• A rack endpoint
• Handle failure for authentication
• In short: throw(:warden)
Callback
• Provide various callbacks to hook into in authentication cycle (set user, authenticate success, failure, …)
• Behave similar to Rails callbacks
User & Scope
• Set & get user simply by set_user and user
• Scope of user for some scenarios:
• Multiple roles
• Stimulate another user
Session
• Store user data in separate scope
• Access through session
• Work like a simple hash
Demo & Explain
Reference• https://github.com/hassox/warden/wiki
• https://rossta.net/blog/what-i-learned-about-hanami.html
• http://pothibo.com/2013/07/authentication-with-warden-devise-less/
• Demo code
• https://github.com/hieuk09/code_commenter
• https://github.com/hieuk09/code-commenter-hanami