app_rail-airtable 0.4.6 → 0.4.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3e4126f9d575a705e24ba998e9adb2ecd3dc95c567e13668a733b246fe9401fc
4
- data.tar.gz: 58b0c53b463db9b7689c580b1fc5d7284c0d72ddf10e51f5eeeee1e63a65fc65
3
+ metadata.gz: 3d413292d55b91966eeed50458ef1cd264cc278add196d53fbab2633dfd406d3
4
+ data.tar.gz: e16281efca091bc9d9e2dc2abf2f81c4c16416cd9cf27a6b34127bd191899bb0
5
5
  SHA512:
6
- metadata.gz: f5969fbe95e911778f4b44104137c6ffe13163e55ea0a57aa13d6b03746ea4ef00daec15b6af9eb1a1c5d58fd2da5903e6cc2e90c71d7cd222dbacfa69b9f11f
7
- data.tar.gz: b73be3571e4711e835b2a287a38132e8b38c071d433672de505ccce12c2e1658206fb35fdf4985dcc7ef6b32853cf69996e81589ac50fbfec431b6fed261cfe1
6
+ metadata.gz: a4c6b3fe35603c645186b1d45d67d16f4afa1d556500abb1f5467b9ae78be4b29dc847e85a9c3379ecf75ebf0b94894e5d620557096eec9abad06d8e1248017b
7
+ data.tar.gz: e61beebcf401102669f1707ddc4f2a5b6b9f7d25585b05cbace9198a1d55196739ca22e73297699fc5413c1226d1a050c754cd7f2fdbd49bdc34a436950dd90f
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- app_rail-airtable (0.4.6)
4
+ app_rail-airtable (0.4.8)
5
5
  activesupport
6
6
  airrecord
7
7
  app_rail-steps
@@ -14,7 +14,7 @@ PATH
14
14
  GEM
15
15
  remote: https://rubygems.org/
16
16
  specs:
17
- activesupport (7.0.2.4)
17
+ activesupport (7.0.4)
18
18
  concurrent-ruby (~> 1.0, >= 1.0.2)
19
19
  i18n (>= 1.6, < 2)
20
20
  minitest (>= 5.1)
@@ -23,28 +23,28 @@ GEM
23
23
  faraday (>= 1.0, < 3.0)
24
24
  faraday-net_http_persistent
25
25
  net-http-persistent
26
- app_rail-steps (0.2.9)
27
- bcrypt (3.1.17)
26
+ app_rail-steps (0.2.16)
27
+ bcrypt (3.1.18)
28
28
  byebug (11.1.3)
29
29
  concurrent-ruby (1.1.10)
30
- connection_pool (2.2.5)
30
+ connection_pool (2.3.0)
31
31
  diff-lcs (1.4.4)
32
- faraday (2.2.0)
33
- faraday-net_http (~> 2.0)
32
+ faraday (2.6.0)
33
+ faraday-net_http (>= 2.0, < 3.1)
34
34
  ruby2_keywords (>= 0.0.4)
35
- faraday-net_http (2.0.2)
36
- faraday-net_http_persistent (2.0.1)
37
- faraday-net_http
35
+ faraday-net_http (3.0.1)
36
+ faraday-net_http_persistent (2.1.0)
37
+ faraday (~> 2.5)
38
38
  net-http-persistent (~> 4.0)
39
- i18n (1.10.0)
39
+ i18n (1.12.0)
40
40
  concurrent-ruby (~> 1.0)
41
- minitest (5.15.0)
42
- mustermann (1.1.1)
41
+ minitest (5.16.3)
42
+ mustermann (2.0.2)
43
43
  ruby2_keywords (~> 0.0.1)
44
44
  net-http-persistent (4.0.1)
45
45
  connection_pool (~> 2.2)
46
46
  rack (2.2.3)
47
- rack-protection (2.2.0)
47
+ rack-protection (2.2.2)
48
48
  rack
49
49
  rack-test (1.1.0)
50
50
  rack (>= 1.0, < 3)
@@ -63,14 +63,14 @@ GEM
63
63
  rspec-support (~> 3.10.0)
64
64
  rspec-support (3.10.2)
65
65
  ruby2_keywords (0.0.5)
66
- sinatra (2.2.0)
67
- mustermann (~> 1.0)
66
+ sinatra (2.2.2)
67
+ mustermann (~> 2.0)
68
68
  rack (~> 2.2)
69
- rack-protection (= 2.2.0)
69
+ rack-protection (= 2.2.2)
70
70
  tilt (~> 2.0)
71
71
  thor (1.1.0)
72
- tilt (2.0.10)
73
- tzinfo (2.0.4)
72
+ tilt (2.0.11)
73
+ tzinfo (2.0.5)
74
74
  concurrent-ruby (~> 1.0)
75
75
 
76
76
  PLATFORMS
@@ -12,7 +12,7 @@ module AppRail
12
12
 
13
13
  def self.included(klass)
14
14
  klass.extend(ClassMethods)
15
- klass.prepend(InstanceMethods) # prepends `initialize` instance method in order to take precedence over Airrecord::Table#initialize
15
+ klass.prepend(InstanceMethods)
16
16
  end
17
17
 
18
18
  module ClassMethods
@@ -47,38 +47,30 @@ module AppRail
47
47
  end
48
48
 
49
49
  module InstanceMethods
50
- def initialize(*args)
51
- if (kwargs = args.first) && kwargs.is_a?(Hash) && kwargs.size == 2 && kwargs.key?(:email) && kwargs.key?(:password)
52
- super('Email' => kwargs[:email], 'Password Hash' => self.class.password_hash(kwargs[:password]), 'Access Token' => self.class.next_access_token)
53
- else
54
- super
55
- end
50
+ def valid_password?(password)
51
+ BCrypt::Password.new(password_hash) == password
56
52
  end
57
- end
58
53
 
59
- def valid_password?(password)
60
- BCrypt::Password.new(password_hash) == password
61
- end
62
-
63
- def password_hash
64
- self['Password Hash']
65
- end
54
+ def password_hash
55
+ self['Password Hash']
56
+ end
66
57
 
67
- def oauth_session
68
- ensure_access_token!
58
+ def oauth_session
59
+ ensure_access_token!
69
60
 
70
- {
71
- access_token: self['Access Token'],
72
- scope: :user,
73
- token_type: :bearer,
74
- expires_in: 31_536_000 # 1 year
75
- }
76
- end
61
+ {
62
+ access_token: self['Access Token'],
63
+ scope: :user,
64
+ token_type: :bearer,
65
+ expires_in: 31_536_000 # 1 year
66
+ }
67
+ end
77
68
 
78
- def ensure_access_token!
79
- unless self['Access Token']
80
- self['Access Token'] = User.next_access_token
81
- save
69
+ def ensure_access_token!
70
+ unless self['Access Token']
71
+ self['Access Token'] = User.next_access_token
72
+ save
73
+ end
82
74
  end
83
75
  end
84
76
  end
@@ -22,6 +22,10 @@ module AppRail
22
22
  request.env['HTTP_AUTHORIZATION']
23
23
  end
24
24
 
25
+ def oauth_client_id
26
+ ENV.fetch('OAUTH_CLIENT_ID')
27
+ end
28
+
25
29
  def authenticate!
26
30
  halt 401 unless current_user
27
31
  end
@@ -68,8 +68,10 @@ module AppRail
68
68
 
69
69
  def self.sign_in_route(name)
70
70
  post "/#{name}/session" do
71
+ halt [401, { error: 'Invalid client_id' }.to_json] unless params['client_id'] == oauth_client_id
72
+
71
73
  resource = name.classify_constantize.authenticate_by_params(params)
72
- halt 401 unless resource
74
+ halt [401, { error: 'Invalid credentials' }.to_json] unless resource
73
75
 
74
76
  resource.oauth_session.to_json
75
77
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module AppRail
4
4
  module Airtable
5
- VERSION = '0.4.6'
5
+ VERSION = '0.4.8'
6
6
  end
7
7
  end
@@ -3,10 +3,12 @@
3
3
  source 'https://rubygems.org'
4
4
  git_source(:github) { |repo| "https://github.com/#{repo}.git" }
5
5
 
6
- ruby '2.7.4'
6
+ ruby '3.1.2'
7
7
 
8
- gem 'app_rail-airtable', '~> 0.4.0'
8
+ gem 'app_rail-airtable'
9
9
  gem 'app_rail-steps'
10
+ gem 'sinatra', '~> 3.0', '>= 3.0.2'
11
+ gem 'puma'
10
12
 
11
13
  group :development do
12
14
  gem 'dotenv'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: app_rail-airtable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.6
4
+ version: 0.4.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Brooke-Smith
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-02 00:00:00.000000000 Z
11
+ date: 2022-10-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -213,7 +213,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
213
213
  - !ruby/object:Gem::Version
214
214
  version: '0'
215
215
  requirements: []
216
- rubygems_version: 3.1.6
216
+ rubygems_version: 3.3.7
217
217
  signing_key:
218
218
  specification_version: 4
219
219
  summary: Gem to help building App Rail servers using Airtable as a backend