gatleon-rails 0.1.0 → 0.1.1
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/Gemfile +1 -0
- data/Gemfile.lock +39 -0
- data/gatleon-rails.gemspec +2 -2
- data/lib/gatleon/rails/authform/concern.rb +50 -0
- data/lib/gatleon/rails/version.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2808f3c5f7c91c27b3814dc48b445a942c47180b83f41eab0523aea5f9960076
|
4
|
+
data.tar.gz: 11bf642b7edadbd200d4a8943d88b38e52e448902b58e6c83a2379be45718b3f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c575051e593a79b694b19bad48d81059229cc4b4c191116c43b209254f6c97ffbbd3fbb97e8f64be63bb766d8d526c7a203c60808964b5adb38e82c0250ed03
|
7
|
+
data.tar.gz: 6bdcbcd283c32a9b344298436ebb2e14613abb33bccde4ddd376d0850abd9298b87b6670410059cb11c66d6c78bf97ff1b55003a6509cf95c02bd8ca88679adf
|
data/Gemfile
CHANGED
data/Gemfile.lock
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
gatleon-rails (0.1.1)
|
5
|
+
faraday
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
diff-lcs (1.3)
|
11
|
+
faraday (1.0.0)
|
12
|
+
multipart-post (>= 1.2, < 3)
|
13
|
+
multipart-post (2.1.1)
|
14
|
+
rake (12.3.3)
|
15
|
+
rspec (3.9.0)
|
16
|
+
rspec-core (~> 3.9.0)
|
17
|
+
rspec-expectations (~> 3.9.0)
|
18
|
+
rspec-mocks (~> 3.9.0)
|
19
|
+
rspec-core (3.9.1)
|
20
|
+
rspec-support (~> 3.9.1)
|
21
|
+
rspec-expectations (3.9.0)
|
22
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
23
|
+
rspec-support (~> 3.9.0)
|
24
|
+
rspec-mocks (3.9.1)
|
25
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
26
|
+
rspec-support (~> 3.9.0)
|
27
|
+
rspec-support (3.9.2)
|
28
|
+
|
29
|
+
PLATFORMS
|
30
|
+
ruby
|
31
|
+
|
32
|
+
DEPENDENCIES
|
33
|
+
faraday
|
34
|
+
gatleon-rails!
|
35
|
+
rake (~> 12.0)
|
36
|
+
rspec (~> 3.0)
|
37
|
+
|
38
|
+
BUNDLED WITH
|
39
|
+
2.1.4
|
data/gatleon-rails.gemspec
CHANGED
@@ -6,8 +6,8 @@ Gem::Specification.new do |spec|
|
|
6
6
|
spec.authors = ["gatleon"]
|
7
7
|
spec.email = [""]
|
8
8
|
|
9
|
-
spec.summary = %q{
|
10
|
-
spec.description = %q{
|
9
|
+
spec.summary = %q{add authentication to your website - in 1 minute or less.}
|
10
|
+
spec.description = %q{add authentication to your website - in 1 minute or less.}
|
11
11
|
spec.homepage = "https://gatleon.com"
|
12
12
|
spec.license = "MIT"
|
13
13
|
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Gatleon
|
2
|
+
module Rails
|
3
|
+
module Authform
|
4
|
+
class Concern < Module
|
5
|
+
def initialize(form_uid:, current_user_method_name: "current_user")
|
6
|
+
super() do
|
7
|
+
extend ActiveSupport::Concern
|
8
|
+
|
9
|
+
included do
|
10
|
+
helper_method "#{current_user_method_name}".to_sym
|
11
|
+
before_action :_exchange_user_voucher_for_user
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
# defaults to current_user
|
17
|
+
define_method current_user_method_name do
|
18
|
+
begin
|
19
|
+
JSON.parse(cookies[_authform_user_cookie_key])["data"]
|
20
|
+
rescue
|
21
|
+
nil
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
define_method :_exchange_user_voucher_for_user do
|
26
|
+
if params[:_authformForm] == form_uid && params[:_authformUserVoucher]
|
27
|
+
# TODO: headers for api verification
|
28
|
+
response = Faraday.get("https://authform.gatleon.com/v1/exchangeUserVoucherForUser/#{params[:_authformUserVoucher]}")
|
29
|
+
|
30
|
+
if response.status == 200
|
31
|
+
cookies[_authform_user_cookie_key] = response.body
|
32
|
+
end
|
33
|
+
|
34
|
+
q = Rack::Utils.parse_query(URI.parse(request.url).query)
|
35
|
+
q.delete("_authformUserVoucher")
|
36
|
+
url = q.empty? ? request.path : "#{request.path}?#{q.to_query}"
|
37
|
+
|
38
|
+
redirect_to url, status: 302 # redirect to finish removal of query param
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
define_method :_authform_user_cookie_key do
|
43
|
+
form_uid # allows for multiple forms per site
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gatleon-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- gatleon
|
@@ -24,7 +24,7 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
-
description:
|
27
|
+
description: add authentication to your website - in 1 minute or less.
|
28
28
|
email:
|
29
29
|
- ''
|
30
30
|
executables: []
|
@@ -35,6 +35,7 @@ files:
|
|
35
35
|
- ".rspec"
|
36
36
|
- ".travis.yml"
|
37
37
|
- Gemfile
|
38
|
+
- Gemfile.lock
|
38
39
|
- LICENSE.md
|
39
40
|
- README.md
|
40
41
|
- Rakefile
|
@@ -42,6 +43,7 @@ files:
|
|
42
43
|
- bin/setup
|
43
44
|
- gatleon-rails.gemspec
|
44
45
|
- lib/gatleon/rails.rb
|
46
|
+
- lib/gatleon/rails/authform/concern.rb
|
45
47
|
- lib/gatleon/rails/version.rb
|
46
48
|
homepage: https://gatleon.com
|
47
49
|
licenses:
|
@@ -68,5 +70,5 @@ requirements: []
|
|
68
70
|
rubygems_version: 3.0.3
|
69
71
|
signing_key:
|
70
72
|
specification_version: 4
|
71
|
-
summary:
|
73
|
+
summary: add authentication to your website - in 1 minute or less.
|
72
74
|
test_files: []
|