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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dfad3a23d4577daf71a3f3492cfa164e0d94cb21433e6186628c4df20ac68f60
4
- data.tar.gz: cffb7a313a1328224caeb3806540572c017502349b84dc671e3c71aad6096eae
3
+ metadata.gz: 2808f3c5f7c91c27b3814dc48b445a942c47180b83f41eab0523aea5f9960076
4
+ data.tar.gz: 11bf642b7edadbd200d4a8943d88b38e52e448902b58e6c83a2379be45718b3f
5
5
  SHA512:
6
- metadata.gz: b1bc9e2a9ab5e8bcd2049a94faca63916d5fdf040191f0b925f3494f211afa31fabe67ca5ff0f84216af0f39b3835d6fa354a9342f2aaa1de5f7bcf096e20821
7
- data.tar.gz: 5525a46fd4276d24a804df45ba02e74af96023c60d24c748d9aba836653da6d9ed1496a9da7f4065a1705b4f5763a07f03a4a229aadc34fb0e777ca37685bdc4
6
+ metadata.gz: 1c575051e593a79b694b19bad48d81059229cc4b4c191116c43b209254f6c97ffbbd3fbb97e8f64be63bb766d8d526c7a203c60808964b5adb38e82c0250ed03
7
+ data.tar.gz: 6bdcbcd283c32a9b344298436ebb2e14613abb33bccde4ddd376d0850abd9298b87b6670410059cb11c66d6c78bf97ff1b55003a6509cf95c02bd8ca88679adf
data/Gemfile CHANGED
@@ -3,5 +3,6 @@ source "https://rubygems.org"
3
3
  # Specify your gem's dependencies in gatleon-rails.gemspec
4
4
  gemspec
5
5
 
6
+ gem "faraday"
6
7
  gem "rake", "~> 12.0"
7
8
  gem "rspec", "~> 3.0"
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
@@ -6,8 +6,8 @@ Gem::Specification.new do |spec|
6
6
  spec.authors = ["gatleon"]
7
7
  spec.email = [""]
8
8
 
9
- spec.summary = %q{gatleon rails}
10
- spec.description = %q{gatleon rails}
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
@@ -1,5 +1,5 @@
1
1
  module Gatleon
2
2
  module Rails
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  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.0
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: gatleon rails
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: gatleon rails
73
+ summary: add authentication to your website - in 1 minute or less.
72
74
  test_files: []