cgi_party 1.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.ruby-version +1 -1
- data/.travis.yml +1 -1
- data/Gemfile.lock +23 -11
- data/README.md +15 -4
- data/cgi_party.gemspec +5 -4
- data/lib/cgi_party/authenticate_request.rb +6 -7
- data/lib/cgi_party/client.rb +28 -5
- data/lib/cgi_party/collect_request.rb +5 -3
- data/lib/cgi_party/request.rb +12 -8
- data/lib/cgi_party/version.rb +1 -1
- data/lib/cgi_party/wsdl_paths.rb +3 -3
- metadata +21 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 5ebaaa0e33433a65a30c20367f8af4451a97b32508582f71099a6623167f2171
|
4
|
+
data.tar.gz: 96f438623aaff828771298e1eb7c299994e799351039758c519ef7975c0a7097
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dec8c2f63b57bdff39f8fce7eee7d66377d8cff0bafd2bc8f5f9c292f6b211af33cfaff70a1680c6ececf2aa68f15d81563fe6cac72ffdd77b956338387c2015
|
7
|
+
data.tar.gz: 66f2903aa5e1eef6fb828bae2ddf84dac12811d0ffd1253ada8d7a94e4e450a500310890e7393bc583d97b06b5b37b512d2243cee024baebe4e89b42b890b5c0
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.6.0
|
data/.travis.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,33 +1,44 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
cgi_party (
|
5
|
-
|
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.
|
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.
|
20
|
+
gyoku (1.4.0)
|
17
21
|
builder (>= 2.1.2)
|
18
|
-
|
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.
|
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
|
-
|
30
|
-
|
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.
|
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.
|
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 (~>
|
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
|
3
|
-
As of now you can only perform BankID
|
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(
|
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
59
|
#=> "bankid:///?autostarttoken=[token]&redirect=[return_url]"
|
58
60
|
```
|
59
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)
|
68
|
+
```
|
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", "
|
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", "~>
|
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
|
6
|
+
attr_reader :service_id, :display_name, :provider
|
7
7
|
|
8
|
-
def initialize(savon_client,
|
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
|
-
|
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
|
data/lib/cgi_party/client.rb
CHANGED
@@ -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(
|
28
|
-
CGIParty::AuthenticateRequest.new(@savon_client,
|
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,
|
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: :
|
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,
|
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
|
}
|
data/lib/cgi_party/request.rb
CHANGED
@@ -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
|
-
|
10
|
-
|
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
|
data/lib/cgi_party/version.rb
CHANGED
data/lib/cgi_party/wsdl_paths.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
module CGIParty
|
2
|
-
WSDL_PATH = "https://grp.funktionstjanster.se:8890/grp/
|
3
|
-
WSDL_TEST_PATH = "https://grpt.funktionstjanster.se:18898/grp/
|
4
|
-
WSDL_NAMESPACE = "http://
|
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:
|
4
|
+
version: 2.0.1
|
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:
|
13
|
+
date: 2023-03-31 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: '
|
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: '
|
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
|
-
|
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
|