app_rail-airtable 0.4.5 → 0.4.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +19 -19
- data/lib/app_rail/airtable/authenticatable.rb +22 -25
- data/lib/app_rail/airtable/authentication_helpers.rb +4 -0
- data/lib/app_rail/airtable/sinatra.rb +24 -0
- data/lib/app_rail/airtable/version.rb +1 -1
- data/templates/project/Gemfile +4 -2
- data/templates/project/boot.rb +8 -0
- data/templates/project/config.ru +1 -8
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d413292d55b91966eeed50458ef1cd264cc278add196d53fbab2633dfd406d3
|
4
|
+
data.tar.gz: e16281efca091bc9d9e2dc2abf2f81c4c16416cd9cf27a6b34127bd191899bb0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a4c6b3fe35603c645186b1d45d67d16f4afa1d556500abb1f5467b9ae78be4b29dc847e85a9c3379ecf75ebf0b94894e5d620557096eec9abad06d8e1248017b
|
7
|
+
data.tar.gz: e61beebcf401102669f1707ddc4f2a5b6b9f7d25585b05cbace9198a1d55196739ca22e73297699fc5413c1226d1a050c754cd7f2fdbd49bdc34a436950dd90f
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
app_rail-airtable (0.4.
|
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.
|
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.
|
27
|
-
bcrypt (3.1.
|
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.
|
30
|
+
connection_pool (2.3.0)
|
31
31
|
diff-lcs (1.4.4)
|
32
|
-
faraday (2.
|
33
|
-
faraday-net_http (
|
32
|
+
faraday (2.6.0)
|
33
|
+
faraday-net_http (>= 2.0, < 3.1)
|
34
34
|
ruby2_keywords (>= 0.0.4)
|
35
|
-
faraday-net_http (
|
36
|
-
faraday-net_http_persistent (2.0
|
37
|
-
faraday
|
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.
|
39
|
+
i18n (1.12.0)
|
40
40
|
concurrent-ruby (~> 1.0)
|
41
|
-
minitest (5.
|
42
|
-
mustermann (
|
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.
|
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.
|
67
|
-
mustermann (~>
|
66
|
+
sinatra (2.2.2)
|
67
|
+
mustermann (~> 2.0)
|
68
68
|
rack (~> 2.2)
|
69
|
-
rack-protection (= 2.2.
|
69
|
+
rack-protection (= 2.2.2)
|
70
70
|
tilt (~> 2.0)
|
71
71
|
thor (1.1.0)
|
72
|
-
tilt (2.0.
|
73
|
-
tzinfo (2.0.
|
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)
|
15
|
+
klass.prepend(InstanceMethods)
|
16
16
|
end
|
17
17
|
|
18
18
|
module ClassMethods
|
@@ -24,15 +24,6 @@ module AppRail
|
|
24
24
|
user
|
25
25
|
end
|
26
26
|
|
27
|
-
def create_session_as_json(email:, password:)
|
28
|
-
user = find_by_email_and_password(email, password)
|
29
|
-
return nil unless user
|
30
|
-
|
31
|
-
user['Access Token'] = next_access_token
|
32
|
-
user.save
|
33
|
-
user&.oauth_session
|
34
|
-
end
|
35
|
-
|
36
27
|
def find_by_email_and_password(email, password)
|
37
28
|
user = find_by_email(email)
|
38
29
|
user&.valid_password?(password) ? user : nil
|
@@ -56,25 +47,31 @@ module AppRail
|
|
56
47
|
end
|
57
48
|
|
58
49
|
module InstanceMethods
|
59
|
-
def
|
60
|
-
|
61
|
-
super('Email' => kwargs[:email], 'Password Hash' => self.class.password_hash(kwargs[:password]), 'Access Token' => self.class.next_access_token)
|
62
|
-
else
|
63
|
-
super
|
64
|
-
end
|
50
|
+
def valid_password?(password)
|
51
|
+
BCrypt::Password.new(password_hash) == password
|
65
52
|
end
|
66
|
-
end
|
67
53
|
|
68
|
-
|
69
|
-
|
70
|
-
|
54
|
+
def password_hash
|
55
|
+
self['Password Hash']
|
56
|
+
end
|
71
57
|
|
72
|
-
|
73
|
-
|
74
|
-
|
58
|
+
def oauth_session
|
59
|
+
ensure_access_token!
|
60
|
+
|
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
|
75
68
|
|
76
|
-
|
77
|
-
|
69
|
+
def ensure_access_token!
|
70
|
+
unless self['Access Token']
|
71
|
+
self['Access Token'] = User.next_access_token
|
72
|
+
save
|
73
|
+
end
|
74
|
+
end
|
78
75
|
end
|
79
76
|
end
|
80
77
|
end
|
@@ -46,6 +46,8 @@ module AppRail
|
|
46
46
|
# Allowing the routes to use `authenticate!` and `current_user`
|
47
47
|
helpers AppRail::Airtable::AuthenticationHelpers
|
48
48
|
|
49
|
+
sign_in_route(name)
|
50
|
+
sign_out_route(name)
|
49
51
|
resources(name, only: only)
|
50
52
|
|
51
53
|
return unless block_given?
|
@@ -64,6 +66,28 @@ module AppRail
|
|
64
66
|
update_route(name, authenticated_route?) if only.include?(:update)
|
65
67
|
end
|
66
68
|
|
69
|
+
def self.sign_in_route(name)
|
70
|
+
post "/#{name}/session" do
|
71
|
+
halt [401, { error: 'Invalid client_id' }.to_json] unless params['client_id'] == oauth_client_id
|
72
|
+
|
73
|
+
resource = name.classify_constantize.authenticate_by_params(params)
|
74
|
+
halt [401, { error: 'Invalid credentials' }.to_json] unless resource
|
75
|
+
|
76
|
+
resource.oauth_session.to_json
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def self.sign_out_route(name)
|
81
|
+
delete "/#{name}/session" do
|
82
|
+
authenticate!
|
83
|
+
current_user.access_token = nil
|
84
|
+
current_user.save
|
85
|
+
|
86
|
+
# Assume that the client will reload and trigger a 401
|
87
|
+
[].to_json
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
67
91
|
def self.index_route(name, authenticated_route)
|
68
92
|
get "/#{name}" do
|
69
93
|
authenticate! if authenticated_route
|
data/templates/project/Gemfile
CHANGED
@@ -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 '
|
6
|
+
ruby '3.1.2'
|
7
7
|
|
8
|
-
gem 'app_rail-airtable'
|
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'
|
data/templates/project/config.ru
CHANGED
@@ -1,13 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
$stdout.sync = true
|
4
|
-
|
5
|
-
ENV['RACK_ENV'] ||= 'development'
|
6
|
-
require 'dotenv/load' if ENV['RACK_ENV'] == 'development'
|
7
|
-
require 'bundler'
|
8
|
-
Bundler.require(:default, ENV['RACK_ENV'].to_sym)
|
9
|
-
|
10
|
-
require 'dotenv/load' if ENV['RACK_ENV'] == 'development'
|
11
|
-
|
4
|
+
require './boot'
|
12
5
|
require './lib/server'
|
13
6
|
run Server
|
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.
|
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-
|
11
|
+
date: 2022-10-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -187,6 +187,7 @@ files:
|
|
187
187
|
- templates/project/.gitignore
|
188
188
|
- templates/project/Gemfile
|
189
189
|
- templates/project/app.json
|
190
|
+
- templates/project/boot.rb
|
190
191
|
- templates/project/config.ru
|
191
192
|
- templates/project/lib/server.rb.tt
|
192
193
|
- templates/project/spec/server_spec.rb.tt
|
@@ -212,7 +213,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
212
213
|
- !ruby/object:Gem::Version
|
213
214
|
version: '0'
|
214
215
|
requirements: []
|
215
|
-
rubygems_version: 3.
|
216
|
+
rubygems_version: 3.3.7
|
216
217
|
signing_key:
|
217
218
|
specification_version: 4
|
218
219
|
summary: Gem to help building App Rail servers using Airtable as a backend
|