Module: Noxy::Auth
- Defined in:
- lib/noxy/sinatra.rb
Defined Under Namespace
Modules: Helpers
Class Method Summary collapse
-
.registered(app) ⇒ Void
After register callback when Noxy is embedded in a Sinatra app.
Class Method Details
.registered(app) ⇒ Void
After register callback when Noxy is embedded in a Sinatra app.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/noxy/sinatra.rb', line 24 def self.registered(app) # Noxy app.set :noxy, Proc.new { Noxy } # Create a session cookie: store # auth data securely accross multiple domains. app.use Rack::Session::Cookie, key: "#{app.noxy.app}.noxy.session", secret: "#{app.noxy.session}", path: '/' # plug and play OmniAuth - Google OAuth2 app.use OmniAuth::Builder do provider :google_oauth2, app.noxy.client, app.noxy.secret end # define proxy lambda, so the proxy lambda, # from Noxy is configurable and # is executed on app instance. proxy = -> { self.instance_exec &app.noxy.proxy } # setup, make sure it's handled on GET and POST app.get '/auth/:name/callback', &proxy app.post '/auth/:name/callback', &proxy # set module as helper app.helpers Helpers end |