cgi_party 0.1.1 → 2.0.0

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
- SHA1:
3
- metadata.gz: 7d5338233ddfcaa4df704951181cbda4a5dd3444
4
- data.tar.gz: afff0f41825840d08dee3d44bced8bd01dbf64d6
2
+ SHA256:
3
+ metadata.gz: 3ccde7f8565b47c59777e7e49248a7c4b1c4d0039c166b929e81f0fe5634a11f
4
+ data.tar.gz: 34147e2d4f52348ea984d03d88b663d69b76d96141149a14e8ceb30b5787cefe
5
5
  SHA512:
6
- metadata.gz: b37874a6e8c6195b32c62086abacd88f24c86fb92b0ad0137c0fe8465bde73f2a8823806a1d16ee48076c3f7766604873fdb64d3033ca4610446869e38aacb0b
7
- data.tar.gz: 7630e970003e11e4f69d2d0447393d7e5c8624d8fb7b82ddfc496bc4219256eba09a41385ba77a52a7367bcd4eb7c5278a857d3bdde613ffe9b25968db530afc
6
+ metadata.gz: cdb8dca7984eda608e251f8e84e6e90d5e37e4ec624feb75c9f6d7c608f5028dedcc56a4d28f962df33546f5bc54febf51f5497c8f058a9f8335e8e22bed4162
7
+ data.tar.gz: 2554848dc0feef524370632a4d0920c6b5d56804438e9b48c8020f664b25e9f09cbc3e0763dd3d334643159185e321a3b06054ba0e92557e5dca90b8c081b255
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.6.0
data/.travis.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  rvm:
4
- - 2.2.5
5
- before_install: gem install bundler -v 1.16.0
4
+ - 2.6.0
5
+ before_install: gem install bundler -v 1.17.3
data/Gemfile.lock CHANGED
@@ -1,33 +1,44 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cgi_party (0.1.1)
5
- savon (~> 2.0)
4
+ cgi_party (2.0.0)
5
+ rqrcode (~> 2.0)
6
+ savon (= 2.12.1)
6
7
 
7
8
  GEM
8
9
  remote: https://rubygems.org/
9
10
  specs:
11
+ addressable (2.8.1)
12
+ public_suffix (>= 2.0.2, < 6.0)
10
13
  akami (1.3.1)
11
14
  gyoku (>= 0.4.0)
12
15
  nokogiri
13
- builder (3.2.3)
16
+ builder (3.2.4)
17
+ chunky_png (1.4.0)
14
18
  coderay (1.1.2)
15
19
  diff-lcs (1.3)
16
- gyoku (1.3.1)
20
+ gyoku (1.4.0)
17
21
  builder (>= 2.1.2)
18
- httpi (2.4.2)
22
+ rexml (~> 3.0)
23
+ httpi (2.5.0)
19
24
  rack
20
25
  socksify
21
26
  method_source (0.9.0)
22
- mini_portile2 (2.3.0)
23
- nokogiri (1.8.2)
24
- mini_portile2 (~> 2.3.0)
27
+ mini_portile2 (2.4.0)
28
+ nokogiri (1.10.10)
29
+ mini_portile2 (~> 2.4.0)
25
30
  nori (2.6.0)
26
31
  pry (0.11.3)
27
32
  coderay (~> 1.1.0)
28
33
  method_source (~> 0.9.0)
29
- rack (2.0.4)
30
- rake (10.4.2)
34
+ public_suffix (4.0.7)
35
+ rack (3.0.2)
36
+ rake (13.0.1)
37
+ rexml (3.2.5)
38
+ rqrcode (2.1.2)
39
+ chunky_png (~> 1.0)
40
+ rqrcode_core (~> 1.0)
41
+ rqrcode_core (1.2.0)
31
42
  rspec (3.7.0)
32
43
  rspec-core (~> 3.7.0)
33
44
  rspec-expectations (~> 3.7.0)
@@ -41,7 +52,7 @@ GEM
41
52
  diff-lcs (>= 1.2.0, < 2.0)
42
53
  rspec-support (~> 3.7.0)
43
54
  rspec-support (3.7.0)
44
- savon (2.12.0)
55
+ savon (2.12.1)
45
56
  akami (~> 1.2)
46
57
  builder (>= 2.1.2)
47
58
  gyoku (~> 1.2)
@@ -51,7 +62,8 @@ GEM
51
62
  wasabi (~> 3.4)
52
63
  socksify (1.7.1)
53
64
  timecop (0.9.1)
54
- wasabi (3.5.0)
65
+ wasabi (3.7.0)
66
+ addressable
55
67
  httpi (~> 2.0)
56
68
  nokogiri (>= 1.4.2)
57
69
 
@@ -59,12 +71,12 @@ PLATFORMS
59
71
  ruby
60
72
 
61
73
  DEPENDENCIES
62
- bundler (~> 1.16)
74
+ bundler (~> 1.17.3)
63
75
  cgi_party!
64
76
  pry
65
- rake (~> 10.0)
77
+ rake (~> 13.0)
66
78
  rspec (~> 3.0)
67
79
  timecop
68
80
 
69
81
  BUNDLED WITH
70
- 1.16.0
82
+ 1.17.3
data/README.md CHANGED
@@ -1,9 +1,11 @@
1
1
  # CGIParty
2
- CGIParty is a gem made for integrating against the CGI Group GRP API.
3
- As of now you can only perform BankID authorisation.
2
+ CGIParty is a gem made for integrating against the CGI Group GRP2 API.
3
+ As of now you can only perform BankID authorization.
4
4
 
5
5
  - *You will need an agreement with CGI group in order to user their API. We do not provide this.*
6
6
 
7
+ **NOTE: If you're still using the old GRP API, you'll need to install the old version ([1.0.0](https://github.com/standout/cgi-party/tree/v1.0.0)) of this gem.**
8
+
7
9
  ## Installation
8
10
 
9
11
  Add this line to your application's Gemfile:
@@ -48,15 +50,24 @@ the authenticate method. The authenticate response will contain information abou
48
50
  the authentication order.
49
51
  ```ruby
50
52
  client = CGIParty::Client.new
51
- authenticate_response = client.authenticate(social_security_number)
53
+ authenticate_response = client.authenticate(ip_address)
52
54
  ```
53
-
55
+ ### Autostart on the same device
54
56
  You can acquire an url for prompting the BankID application on the device.
55
57
  ```ruby
56
58
  authenticate_response.autostart_url(return_url)
57
- #=> "bankid:///?autostarttoken=[token]&redirect=[return_url]"
59
+ #=> "bankid:///?autostart=[token]&return=[return_url]"
60
+ ```
61
+
62
+ ### QR code for BankID on another device
63
+ Generate an animated QR code. You'll need some way to keep track of elapsed seconds as you refresh the QR code.
64
+ ```ruby
65
+ client.generate_qr(start_token: authenticate_response.qr_start_token,
66
+ start_secret: authenticate_response.qr_start_secret,
67
+ seconds: seconds_elapsed)
58
68
  ```
59
69
 
70
+ ### Collect
60
71
  To poll the collect action you can use the poll collect method. The block will be yielded
61
72
  every time the API responds. You can take appropriate action in your application by using the provided
62
73
  progress statuses.
data/cgi_party.gemspec CHANGED
@@ -6,8 +6,8 @@ require "cgi_party/version"
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "cgi_party"
8
8
  spec.version = CGIParty::VERSION
9
- spec.authors = ["Emric"]
10
- spec.email = ["w.e.w@live.se"]
9
+ spec.authors = ["Emric","Stavros","Tobias"]
10
+ spec.email = ["w.e.w@live.se","stavros.gemitzoglou@standout.se","tobias@almstrand.com"]
11
11
 
12
12
  spec.summary = %q{Makes CGI Group GRP integration a party! <3}
13
13
  spec.homepage = "https://github.com/standout/cgi-party"
@@ -29,10 +29,11 @@ Gem::Specification.new do |spec|
29
29
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
30
30
  spec.require_paths = ["lib"]
31
31
 
32
- spec.add_dependency "savon", "~> 2.0"
32
+ spec.add_dependency "savon", "2.12.1"
33
+ spec.add_dependency "rqrcode", "~> 2.0"
33
34
 
34
- spec.add_development_dependency "bundler", "~> 1.16"
35
- spec.add_development_dependency "rake", "~> 10.0"
35
+ spec.add_development_dependency "bundler", "~> 1.17.3"
36
+ spec.add_development_dependency "rake", "~> 13.0"
36
37
  spec.add_development_dependency "rspec", "~> 3.0"
37
38
  spec.add_development_dependency "pry"
38
39
  spec.add_development_dependency "timecop"
@@ -3,11 +3,10 @@ require "cgi_party/request"
3
3
 
4
4
  module CGIParty
5
5
  class AuthenticateRequest < CGIParty::Request
6
- attr_reader :service_id, :display_name, :provider, :ssn
6
+ attr_reader :service_id, :display_name, :provider
7
7
 
8
- def initialize(savon_client, ssn, options: {})
9
- super(savon_client, options)
10
- @ssn = ssn
8
+ def initialize(savon_client, ip_address, options: {})
9
+ super(savon_client, ip_address, options)
11
10
  end
12
11
 
13
12
  private
@@ -22,10 +21,10 @@ module CGIParty
22
21
 
23
22
  def message_hash
24
23
  {
25
- display_name: @options[:display_name],
26
- provider: @options[:provider],
27
24
  policy: @options[:service_id],
28
- personal_number: @ssn
25
+ provider: @options[:provider],
26
+ rp_display_name: @options[:display_name],
27
+ end_user_info: end_user_info
29
28
  }
30
29
  end
31
30
  end
@@ -3,7 +3,7 @@ require "cgi_party/response"
3
3
  module CGIParty
4
4
  class AuthenticateResponse < Response
5
5
  def autostart_url(return_url)
6
- "bankid:///?autostarttoken=#{auto_start_token}&redirect=#{return_url}"
6
+ "bankid:///?autostart=#{auto_start_token}&return=#{return_url}"
7
7
  end
8
8
  end
9
9
  end
@@ -1,5 +1,5 @@
1
1
  require "savon"
2
-
2
+ require "rqrcode"
3
3
 
4
4
  module CGIParty
5
5
  class Client
@@ -11,11 +11,14 @@ module CGIParty
11
11
 
12
12
  def poll_collect(order_ref, transaction_id = nil)
13
13
  @polling_started_at = Time.now
14
+
14
15
  loop do
15
16
  collect_response = collect(order_ref, transaction_id)
16
17
  return collect_response if timeout_polling?
18
+
17
19
  yield(collect_response)
18
20
  return collect_response if collect_response.authentication_finished?
21
+
19
22
  sleep(CGIParty.config.collect_polling_delay)
20
23
  end
21
24
  end
@@ -24,12 +27,23 @@ module CGIParty
24
27
  Time.now - @polling_started_at
25
28
  end
26
29
 
27
- def authenticate(ssn, options: {})
28
- CGIParty::AuthenticateRequest.new(@savon_client, ssn).execute
30
+ def authenticate(ip_address, options: {})
31
+ CGIParty::AuthenticateRequest.new(@savon_client,
32
+ ip_address,
33
+ options: options)
34
+ .execute
35
+ end
36
+
37
+ def generate_qr(start_token:, start_secret:, seconds:)
38
+ RQRCode::QRCode.new(qr_auth_code(start_token, start_secret, seconds))
29
39
  end
30
40
 
31
41
  def collect(order_reference, transaction_id, options: {})
32
- CGIParty::CollectRequest.new(@savon_client, order_reference, transaction_id).execute
42
+ CGIParty::CollectRequest.new(@savon_client,
43
+ order_reference,
44
+ transaction_id,
45
+ options: options)
46
+ .execute
33
47
  end
34
48
 
35
49
  private
@@ -38,10 +52,19 @@ module CGIParty
38
52
  polling_duration >= CGIParty.config.collect_polling_timeout
39
53
  end
40
54
 
55
+ def qr_auth_code(start_token, start_secret, seconds)
56
+ auth_code = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new("SHA256"),
57
+ start_secret,
58
+ seconds.to_s)
59
+
60
+ "bankid.#{start_token}.#{seconds}.#{auth_code}"
61
+ end
62
+
41
63
  def savon_opts
42
64
  {
65
+ soap_version: 2,
43
66
  namespace: CGIParty::WSDL_NAMESPACE,
44
- namespace_identifier: :v1,
67
+ namespace_identifier: :v2,
45
68
  wsdl: CGIParty.config.wsdl_path,
46
69
  env_namespace: :soapenv,
47
70
  ssl_verify_mode: :none
@@ -5,7 +5,8 @@ module CGIParty
5
5
  class CollectRequest < CGIParty::Request
6
6
  attr_reader :order_reference, :transaction_id
7
7
 
8
- def initialize(savon_client, order_reference, transaction_id = nil, options: {})
8
+ def initialize(savon_client, order_reference,
9
+ transaction_id = nil, options: {})
9
10
  super(savon_client, options)
10
11
  @order_reference = order_reference
11
12
  @transaction_id = transaction_id
@@ -18,13 +19,14 @@ module CGIParty
18
19
  end
19
20
 
20
21
  def available_options
21
- %i[display_name service_id]
22
+ %i[display_name service_id provider]
22
23
  end
23
24
 
24
25
  def message_hash
25
26
  {
26
- display_name: @options[:display_name],
27
27
  policy: @options[:service_id],
28
+ provider: @options[:provider],
29
+ rp_display_name: @options[:display_name],
28
30
  transaction_id: @transaction_id,
29
31
  order_ref: @order_reference
30
32
  }
@@ -1,18 +1,14 @@
1
1
  module CGIParty
2
2
  class Request
3
- def initialize(savon_client, options)
3
+ def initialize(savon_client, ip_address = nil, options)
4
4
  @options = fetch_options(options, available_options)
5
5
  @savon_client = savon_client
6
+ @ip_address = ip_address
6
7
  end
7
8
 
8
9
  def execute
9
- serialize_data(
10
- @savon_client.call(
11
- action_name,
12
- message: message_hash,
13
- message_tag: message_tag
14
- ).body
15
- )
10
+ response = @savon_client.call(action_name, message: message_hash, message_tag: message_tag, soap_action: false)
11
+ serialize_data(response.body)
16
12
  end
17
13
 
18
14
  private
@@ -21,6 +17,7 @@ module CGIParty
21
17
  available_options.each do |option_name|
22
18
  options[option_name] ||= CGIParty.config.public_send(option_name)
23
19
  end
20
+
24
21
  options
25
22
  end
26
23
 
@@ -32,5 +29,12 @@ module CGIParty
32
29
  def message_tag
33
30
  self.class.name.gsub(/^.*::/, '')
34
31
  end
32
+
33
+ def end_user_info
34
+ {
35
+ type: 'IP_ADDR',
36
+ value: @ip_address
37
+ }
38
+ end
35
39
  end
36
40
  end
@@ -1,3 +1,3 @@
1
1
  module CGIParty
2
- VERSION = "0.1.1"
2
+ VERSION = "2.0.0"
3
3
  end
@@ -1,5 +1,5 @@
1
1
  module CGIParty
2
- WSDL_PATH = "https://grp.funktionstjanster.se:8890/grp/v1?wsdl"
3
- WSDL_TEST_PATH = "https://grpt.funktionstjanster.se:18898/grp/v1?wsdl"
4
- WSDL_NAMESPACE = "http://funktionstjanster.se/grp/service/v1.0.0/"
2
+ WSDL_PATH = "https://grp.funktionstjanster.se:8890/grp/v2.1?wsdl"
3
+ WSDL_TEST_PATH = "https://grpt.funktionstjanster.se:18898/grp/v2.1?wsdl"
4
+ WSDL_NAMESPACE = "http://mobilityguard.com/grp/service/v2.0/"
5
5
  end
metadata CHANGED
@@ -1,17 +1,33 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cgi_party
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Emric
8
+ - Stavros
9
+ - Tobias
8
10
  autorequire:
9
11
  bindir: exe
10
12
  cert_chain: []
11
- date: 2018-02-07 00:00:00.000000000 Z
13
+ date: 2023-03-23 00:00:00.000000000 Z
12
14
  dependencies:
13
15
  - !ruby/object:Gem::Dependency
14
16
  name: savon
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - '='
20
+ - !ruby/object:Gem::Version
21
+ version: 2.12.1
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - '='
27
+ - !ruby/object:Gem::Version
28
+ version: 2.12.1
29
+ - !ruby/object:Gem::Dependency
30
+ name: rqrcode
15
31
  requirement: !ruby/object:Gem::Requirement
16
32
  requirements:
17
33
  - - "~>"
@@ -30,28 +46,28 @@ dependencies:
30
46
  requirements:
31
47
  - - "~>"
32
48
  - !ruby/object:Gem::Version
33
- version: '1.16'
49
+ version: 1.17.3
34
50
  type: :development
35
51
  prerelease: false
36
52
  version_requirements: !ruby/object:Gem::Requirement
37
53
  requirements:
38
54
  - - "~>"
39
55
  - !ruby/object:Gem::Version
40
- version: '1.16'
56
+ version: 1.17.3
41
57
  - !ruby/object:Gem::Dependency
42
58
  name: rake
43
59
  requirement: !ruby/object:Gem::Requirement
44
60
  requirements:
45
61
  - - "~>"
46
62
  - !ruby/object:Gem::Version
47
- version: '10.0'
63
+ version: '13.0'
48
64
  type: :development
49
65
  prerelease: false
50
66
  version_requirements: !ruby/object:Gem::Requirement
51
67
  requirements:
52
68
  - - "~>"
53
69
  - !ruby/object:Gem::Version
54
- version: '10.0'
70
+ version: '13.0'
55
71
  - !ruby/object:Gem::Dependency
56
72
  name: rspec
57
73
  requirement: !ruby/object:Gem::Requirement
@@ -97,12 +113,15 @@ dependencies:
97
113
  description:
98
114
  email:
99
115
  - w.e.w@live.se
116
+ - stavros.gemitzoglou@standout.se
117
+ - tobias@almstrand.com
100
118
  executables: []
101
119
  extensions: []
102
120
  extra_rdoc_files: []
103
121
  files:
104
122
  - ".gitignore"
105
123
  - ".rspec"
124
+ - ".ruby-version"
106
125
  - ".travis.yml"
107
126
  - Gemfile
108
127
  - Gemfile.lock
@@ -142,8 +161,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
142
161
  - !ruby/object:Gem::Version
143
162
  version: '0'
144
163
  requirements: []
145
- rubyforge_project:
146
- rubygems_version: 2.4.5.1
164
+ rubygems_version: 3.4.9
147
165
  signing_key:
148
166
  specification_version: 4
149
167
  summary: Makes CGI Group GRP integration a party! <3