Module: AppRail::Airtable::AuthenticationHelpers
- Defined in:
- lib/app_rail/airtable/authentication_helpers.rb
Instance Method Summary collapse
- #authenticate! ⇒ Object
- #authorization_header ⇒ Object
- #bearer_token ⇒ Object
- #current_user ⇒ Object
- #find_current_user ⇒ Object
- #oauth_client_id ⇒ Object
- #oauth_client_secret ⇒ Object
Instance Method Details
#authenticate! ⇒ Object
33 34 35 |
# File 'lib/app_rail/airtable/authentication_helpers.rb', line 33 def authenticate! halt 401 unless current_user end |
#authorization_header ⇒ Object
21 22 23 |
# File 'lib/app_rail/airtable/authentication_helpers.rb', line 21 def request.env['HTTP_AUTHORIZATION'] end |
#bearer_token ⇒ Object
14 15 16 17 18 19 |
# File 'lib/app_rail/airtable/authentication_helpers.rb', line 14 def bearer_token = .split(' ') return nil unless .count > 1 [1] end |
#current_user ⇒ Object
6 7 8 |
# File 'lib/app_rail/airtable/authentication_helpers.rb', line 6 def current_user @current_user ||= find_current_user end |
#find_current_user ⇒ Object
10 11 12 |
# File 'lib/app_rail/airtable/authentication_helpers.rb', line 10 def find_current_user && bearer_token ? find_authenticatable_resource(access_token: bearer_token) : nil end |
#oauth_client_id ⇒ Object
25 26 27 |
# File 'lib/app_rail/airtable/authentication_helpers.rb', line 25 def oauth_client_id ENV.fetch('OAUTH_CLIENT_ID') end |
#oauth_client_secret ⇒ Object
29 30 31 |
# File 'lib/app_rail/airtable/authentication_helpers.rb', line 29 def oauth_client_secret ENV.fetch('OAUTH_CLIENT_SECRET') end |