| Module | Picnic::Authentication::Basic |
| In: |
lib/picnic/authentication.rb
|
Picnic::Authentication::Basic provides Basic HTTP Authentication for your Camping app. The module defines a service method that only continues the request chain when proper credentials are provided by the client (browser).
To activate Basic Authentication for your application:
module Blog
def authenticate(credentials)
credentials[:username] == 'admin' &&
credentials[:password] == 'flapper30'
end
module_function :authenticate
end
or
module Wiki
def authenticate(credentials)
u = credentials[:username]
p = credentials[:password]
Models::User.find_by_username_and_password u, p
end
module_function :authenticate
end
This code is based on Camping::BasicAuth written by Manfred Stienstra (see www.fngtps.com/2006/05/basic-authentication-for-camping).