cgi_party 1.0.0 → 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: eafefe96bd17d0fdfe9195b72f116247dc3abb4b
4
- data.tar.gz: 1444190411a637ecd29bdcc0aa0d04f2cd326f33
2
+ SHA256:
3
+ metadata.gz: 3ccde7f8565b47c59777e7e49248a7c4b1c4d0039c166b929e81f0fe5634a11f
4
+ data.tar.gz: 34147e2d4f52348ea984d03d88b663d69b76d96141149a14e8ceb30b5787cefe
5
5
  SHA512:
6
- metadata.gz: 7b0da00dcd45482a479afaaa1d3d2f28b48afeaa9d3694e81a37008c211495fd3227d4977527ffb5b964060d943057dd9ec69e8524797bc46c7cdf2c8f7aaa5d
7
- data.tar.gz: 07315f65d6dcd2e44eac37d853c6b73e1ac57f0ceed58fe178b5eb225ffafedbdf0eff70909f982479ab12490fcc753b1d65cb2df8300f87650b0cca41822942
6
+ metadata.gz: cdb8dca7984eda608e251f8e84e6e90d5e37e4ec624feb75c9f6d7c608f5028dedcc56a4d28f962df33546f5bc54febf51f5497c8f058a9f8335e8e22bed4162
7
+ data.tar.gz: 2554848dc0feef524370632a4d0920c6b5d56804438e9b48c8020f664b25e9f09cbc3e0763dd3d334643159185e321a3b06054ba0e92557e5dca90b8c081b255
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.4.3
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.3.0
4
+ - 2.6.0
5
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 (1.0.0)
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.4)
22
+ rexml (~> 3.0)
23
+ httpi (2.5.0)
19
24
  rack
20
25
  socksify
21
26
  method_source (0.9.0)
22
27
  mini_portile2 (2.4.0)
23
- nokogiri (1.10.3)
28
+ nokogiri (1.10.10)
24
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.7)
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
 
@@ -62,7 +74,7 @@ DEPENDENCIES
62
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
 
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","Stavros"]
10
- spec.email = ["w.e.w@live.se","stavros.gemitzoglou@standout.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
35
  spec.add_development_dependency "bundler", "~> 1.17.3"
35
- spec.add_development_dependency "rake", "~> 10.0"
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 = "1.0.0"
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,18 +1,33 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cgi_party
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Emric
8
8
  - Stavros
9
+ - Tobias
9
10
  autorequire:
10
11
  bindir: exe
11
12
  cert_chain: []
12
- date: 2019-07-17 00:00:00.000000000 Z
13
+ date: 2023-03-23 00:00:00.000000000 Z
13
14
  dependencies:
14
15
  - !ruby/object:Gem::Dependency
15
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
16
31
  requirement: !ruby/object:Gem::Requirement
17
32
  requirements:
18
33
  - - "~>"
@@ -45,14 +60,14 @@ dependencies:
45
60
  requirements:
46
61
  - - "~>"
47
62
  - !ruby/object:Gem::Version
48
- version: '10.0'
63
+ version: '13.0'
49
64
  type: :development
50
65
  prerelease: false
51
66
  version_requirements: !ruby/object:Gem::Requirement
52
67
  requirements:
53
68
  - - "~>"
54
69
  - !ruby/object:Gem::Version
55
- version: '10.0'
70
+ version: '13.0'
56
71
  - !ruby/object:Gem::Dependency
57
72
  name: rspec
58
73
  requirement: !ruby/object:Gem::Requirement
@@ -99,6 +114,7 @@ description:
99
114
  email:
100
115
  - w.e.w@live.se
101
116
  - stavros.gemitzoglou@standout.se
117
+ - tobias@almstrand.com
102
118
  executables: []
103
119
  extensions: []
104
120
  extra_rdoc_files: []
@@ -145,8 +161,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
145
161
  - !ruby/object:Gem::Version
146
162
  version: '0'
147
163
  requirements: []
148
- rubyforge_project:
149
- rubygems_version: 2.6.14
164
+ rubygems_version: 3.4.9
150
165
  signing_key:
151
166
  specification_version: 4
152
167
  summary: Makes CGI Group GRP integration a party! <3