Module: CloudCrowd::Helpers::Authorization
- Included in:
- CloudCrowd::Helpers
- Defined in:
- lib/cloud_crowd/helpers/authorization.rb
Overview
Authorization takes after sinatra-authorization… See github.com/integrity/sinatra-authorization for the original.
Instance Method Summary collapse
-
#authorize(login, password) ⇒ Object
A request is authorized if its login and password match those stored in config.yml, or if authentication is disabled.
-
#authorized? ⇒ Boolean
Has the request been authenticated?.
-
#login_required ⇒ Object
Ensure that the request includes the correct credentials.
Instance Method Details
#authorize(login, password) ⇒ Object
A request is authorized if its login and password match those stored in config.yml, or if authentication is disabled. If authentication is turned on, then every request is authenticated, including between the nodes and the central server.
27 28 29 30 31 |
# File 'lib/cloud_crowd/helpers/authorization.rb', line 27 def (login, password) return true unless CloudCrowd.config[:http_authentication] return CloudCrowd.config[:login] == login && CloudCrowd.config[:password] == password end |
#authorized? ⇒ Boolean
Has the request been authenticated?
19 20 21 |
# File 'lib/cloud_crowd/helpers/authorization.rb', line 19 def !!request.env['REMOTE_USER'] end |
#login_required ⇒ Object
Ensure that the request includes the correct credentials.
10 11 12 13 14 15 16 |
# File 'lib/cloud_crowd/helpers/authorization.rb', line 10 def login_required return if unless auth.provided? bad_request! unless auth.basic? unless (*auth.credentials) request.env['REMOTE_USER'] = auth.username end |