Class: GoogleSpreadsheetFetcher::Authorizer::Oauth2::RackApplication
- Inherits:
-
Object
- Object
- GoogleSpreadsheetFetcher::Authorizer::Oauth2::RackApplication
- Defined in:
- lib/google_spreadsheet_fetcher/authorizer/oauth2/rack_application.rb
Constant Summary collapse
- AUTHORIZE_PATH =
'/authorize'.freeze
- CALLBACK_PATH =
'/oauth2callback'.freeze
Instance Method Summary collapse
- #call(env) ⇒ Object
- #cookie_settings(secret: nil) ⇒ Object
-
#initialize(config: nil) ⇒ RackApplication
constructor
A new instance of RackApplication.
Constructor Details
#initialize(config: nil) ⇒ RackApplication
Returns a new instance of RackApplication.
10 11 12 13 14 15 |
# File 'lib/google_spreadsheet_fetcher/authorizer/oauth2/rack_application.rb', line 10 def initialize(config: nil) @config = config || ::GoogleSpreadsheetFetcher::Authorizer::Oauth2::Config.new @authorizer = ::GoogleSpreadsheetFetcher::Authorizer::Oauth2::Authorizer.new(config: config) freeze end |
Instance Method Details
#call(env) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/google_spreadsheet_fetcher/authorizer/oauth2/rack_application.rb', line 17 def call(env) path = env['PATH_INFO'] request_method = env['REQUEST_METHOD'] return (env) if path == AUTHORIZE_PATH && request_method == 'GET' return handle_callback(env) if path == CALLBACK_PATH && request_method == 'GET' plain_response(400, 'invalid access') end |
#cookie_settings(secret: nil) ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/google_spreadsheet_fetcher/authorizer/oauth2/rack_application.rb', line 27 def (secret: nil) { domain: 'localhost', path: '/', expire_after: 3600*24, secret: secret || SecureRandom.hex(64) } end |