Module: Trinidad::Sandbox::Helpers::Auth
- Includes:
- Sinatra::Authorization
- Defined in:
- lib/trinidad_sandbox_extension/app/helpers/auth.rb
Instance Method Summary collapse
- #authorization_realm ⇒ Object
- #authorize(user, pass) ⇒ Object
- #authorized? ⇒ Boolean
- #authorized_by_token?(params) ⇒ Boolean
- #basic_auth_required?(request) ⇒ Boolean
- #token_required(params, realm = authorization_realm) ⇒ Object
- #token_required?(request) ⇒ Boolean
Instance Method Details
#authorization_realm ⇒ Object
16 |
# File 'lib/trinidad_sandbox_extension/app/helpers/auth.rb', line 16 def ; "Trinidad's sandbox"; end |
#authorize(user, pass) ⇒ Object
8 9 10 |
# File 'lib/trinidad_sandbox_extension/app/helpers/auth.rb', line 8 def (user, pass) user == sandbox_username && pass == sandbox_password end |
#authorized? ⇒ Boolean
12 13 14 |
# File 'lib/trinidad_sandbox_extension/app/helpers/auth.rb', line 12 def sandbox_username && sandbox_password ? request.env['REMOTE_USER'] && !request.env['REMOTE_USER'].empty? : true end |
#authorized_by_token?(params) ⇒ Boolean
32 33 34 |
# File 'lib/trinidad_sandbox_extension/app/helpers/auth.rb', line 32 def (params) deploy_token.nil? || params[:deploy_token] == deploy_token end |
#basic_auth_required?(request) ⇒ Boolean
18 19 20 |
# File 'lib/trinidad_sandbox_extension/app/helpers/auth.rb', line 18 def basic_auth_required?(request) !token_required?(request) end |
#token_required(params, realm = authorization_realm) ⇒ Object
26 27 28 29 30 |
# File 'lib/trinidad_sandbox_extension/app/helpers/auth.rb', line 26 def token_required(params, realm = ) return if (params) response["WWW-Authenticate"] = %(Basic realm="#{realm}") throw :halt, [401, "Deploy Token Required"] end |
#token_required?(request) ⇒ Boolean
22 23 24 |
# File 'lib/trinidad_sandbox_extension/app/helpers/auth.rb', line 22 def token_required?(request) request.path == '/deploy' end |