Created
November 30, 2011 17:41
-
-
Save cadwallion/1409963 to your computer and use it in GitHub Desktop.
Writing custom warden strategies
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# For more information on Warden strategies, read this: https://github.com/hassox/warden/wiki/Strategies | |
class SuperCoolWardenStrategy | |
def valid? | |
# you have access to env and request | |
# return true/false if this is strategy should run or not | |
# if it returns false, it will move onto the next strategy in the list | |
# defaults to true if you don't write this method | |
end | |
def authenticate! | |
# again, this has access to env and request | |
# write your authentication logic | |
# call `success!(user)` to set the user object | |
# call `fail!` to fail login explicitly | |
# to move on to the next strategy, you can explicitly call `pass` or just do nothing | |
end | |
end | |
Warden::Strategies.add(:super_cool_strat, SuperCoolWardenStrategy) | |
warden.authenticate! :super_cool_strat, :sso_auth |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment