Module: Sinatra::Auth::Oauthed
- Defined in:
- lib/sinatra/auth/oauthed.rb,
lib/sinatra/auth/oauthed/version.rb
Defined Under Namespace
Modules: Helpers Classes: BadAuthentication
Constant Summary collapse
- VERSION =
'0.0.1'
Class Method Summary collapse
Class Method Details
.registered(app) ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/sinatra/auth/oauthed.rb', line 76 def self.registered(app) app.use Warden::Manager do |manager| manager.default_strategies :oauthed manager.failure_app = BadAuthentication manager[:oauthed_client_id] = ENV['APPLICATION_CLIENT_ID'] manager[:oauthed_secret] = ENV['APPLICATION_CLIENT_SECRET'] manager[:oauthed_scopes] = ENV['APPLICATION_SCOPES_REQUESTED'] manager[:oauthed_oauth_domain] = ENV['OAUTH_BASE_URL'] manager[:oauthed_callback_url] = '/auth/oauthed/callback' end # Sign cookie sessions in with AS::Verifier ENV['WARDEN_OAUTHED_VERIFIER_SECRET'] ||= ENV['OAUTHED_VERIFIER_SECRET'] unless ENV['WARDEN_OAUTHED_VERIFIER_SECRET'] warn 'No WARDEN_OAUTHED_VERIFIER_SECRET environmental variable found.' warn 'Your sessions are likely being stored insecurely.' end app.helpers Helpers app.get '/auth/oauthed/callback' do if params['error'] redirect '/unauthenticated' else authenticate! redirect '/' return_to = session.delete('return_to') || _relative_url_for('/') redirect return_to end end end |