viisp-auth 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.ruby-version +1 -0
- data/.travis.yml +6 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +58 -0
- data/LICENSE.txt +21 -0
- data/README.md +106 -0
- data/Rakefile +6 -0
- data/certs/epaslaugos_ident.crt +19 -0
- data/certs/testKey.pem +27 -0
- data/lib/viisp/auth.rb +50 -0
- data/lib/viisp/auth/client.rb +44 -0
- data/lib/viisp/auth/configuration.rb +131 -0
- data/lib/viisp/auth/errors.rb +10 -0
- data/lib/viisp/auth/identity.rb +67 -0
- data/lib/viisp/auth/requests/identity.rb +45 -0
- data/lib/viisp/auth/requests/signature.rb +26 -0
- data/lib/viisp/auth/requests/soap.rb +21 -0
- data/lib/viisp/auth/requests/ticket.rb +62 -0
- data/lib/viisp/auth/signing.rb +27 -0
- data/lib/viisp/auth/version.rb +7 -0
- data/schemas/authentication.xsd +154 -0
- data/schemas/exc-c14n.xsd +39 -0
- data/schemas/xmldsig-core-schema.xsd +318 -0
- data/viisp-auth.gemspec +30 -0
- metadata +170 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6331d0c1295838706bc587d2382c2cd2d0f2b5d4
|
4
|
+
data.tar.gz: 8e703d61b9ce1a2be0985acf939915ab05403626
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 33e015a4a3ccdf70b4b235148b34c8ae084a325cf7b74cd4db86fe8938155193f279dfd7e2416e051fec166379efc6029d8a8e06006d095860b21c3f1923095d
|
7
|
+
data.tar.gz: d374e996f9fd6bf5b68e9bef62f59b941f9250aee54cb9954af20e278402b283f907b38059016bda692e6db2a6d1bd806beaa0bf1c315bb72a834c1517cf01c8
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.4.1
|
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at laurynas.butkus@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
viisp-auth (0.1.0)
|
5
|
+
faraday
|
6
|
+
nokogiri
|
7
|
+
xmldsig (~> 0.6)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
addressable (2.5.2)
|
13
|
+
public_suffix (>= 2.0.2, < 4.0)
|
14
|
+
crack (0.4.3)
|
15
|
+
safe_yaml (~> 1.0.0)
|
16
|
+
diff-lcs (1.3)
|
17
|
+
faraday (0.13.1)
|
18
|
+
multipart-post (>= 1.2, < 3)
|
19
|
+
hashdiff (0.3.7)
|
20
|
+
mini_portile2 (2.3.0)
|
21
|
+
multipart-post (2.0.0)
|
22
|
+
nokogiri (1.8.1)
|
23
|
+
mini_portile2 (~> 2.3.0)
|
24
|
+
public_suffix (3.0.1)
|
25
|
+
rake (10.5.0)
|
26
|
+
rspec (3.7.0)
|
27
|
+
rspec-core (~> 3.7.0)
|
28
|
+
rspec-expectations (~> 3.7.0)
|
29
|
+
rspec-mocks (~> 3.7.0)
|
30
|
+
rspec-core (3.7.0)
|
31
|
+
rspec-support (~> 3.7.0)
|
32
|
+
rspec-expectations (3.7.0)
|
33
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
34
|
+
rspec-support (~> 3.7.0)
|
35
|
+
rspec-mocks (3.7.0)
|
36
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
37
|
+
rspec-support (~> 3.7.0)
|
38
|
+
rspec-support (3.7.0)
|
39
|
+
safe_yaml (1.0.4)
|
40
|
+
webmock (3.1.1)
|
41
|
+
addressable (>= 2.3.6)
|
42
|
+
crack (>= 0.3.2)
|
43
|
+
hashdiff
|
44
|
+
xmldsig (0.6.5)
|
45
|
+
nokogiri (>= 1.6.8, < 2.0.0)
|
46
|
+
|
47
|
+
PLATFORMS
|
48
|
+
ruby
|
49
|
+
|
50
|
+
DEPENDENCIES
|
51
|
+
bundler (~> 1.16)
|
52
|
+
rake (~> 10.0)
|
53
|
+
rspec (~> 3.0)
|
54
|
+
viisp-auth!
|
55
|
+
webmock (~> 3.1)
|
56
|
+
|
57
|
+
BUNDLED WITH
|
58
|
+
1.16.0
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Laurynas Butkus
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
# VIISP::Auth
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/laurynas/viisp-auth.svg?branch=master)](https://travis-ci.org/laurynas/viisp-auth)
|
4
|
+
|
5
|
+
Lithuanian E-Government Gateway "Elektroniniai valdžios vartai" identity service client.
|
6
|
+
|
7
|
+
VIISP identity service documentation: https://www.epaslaugos.lt/portal/content/1257
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem 'viisp-auth'
|
15
|
+
```
|
16
|
+
|
17
|
+
## Configuration
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
VIISP::Auth.configure do |c|
|
21
|
+
c.pid = '1234'
|
22
|
+
c.private_key = OpenSSL::PKey::RSA.new(File.read('your-private-key.pem'))
|
23
|
+
c.postback_url = 'https://localhost'
|
24
|
+
|
25
|
+
# optional
|
26
|
+
c.providers = %w[auth.lt.identity.card auth.lt.bank]
|
27
|
+
c.attributes = %w[lt-personal-code lt-company-code]
|
28
|
+
c.user_information = %w[firstName lastName companyName email]
|
29
|
+
|
30
|
+
# enable test mode
|
31
|
+
# (in test mode there is no need to set pid and private_key)
|
32
|
+
c.test = true
|
33
|
+
end
|
34
|
+
```
|
35
|
+
|
36
|
+
## Usage
|
37
|
+
|
38
|
+
Get an authentication ticket:
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
ticket = VIISP::Auth.ticket
|
42
|
+
```
|
43
|
+
|
44
|
+
Redirected user to authentication portal with ticket using http POST.
|
45
|
+
`VIISP::Auth.portal_endpoint` is a convenience method to get portal URL.
|
46
|
+
|
47
|
+
Redirect form for testing: https://jsfiddle.net/kmrzpqwk/
|
48
|
+
|
49
|
+
After successful authentication identity data can be fetched once.
|
50
|
+
|
51
|
+
```ruby
|
52
|
+
identity = VIISP::Auth.identity(
|
53
|
+
ticket: ticket,
|
54
|
+
include_source_data: true,
|
55
|
+
)
|
56
|
+
```
|
57
|
+
|
58
|
+
Identity example:
|
59
|
+
|
60
|
+
```ruby
|
61
|
+
{
|
62
|
+
"authentication_provider" => "auth.lt.bank",
|
63
|
+
"attributes" => {
|
64
|
+
"lt-personal-code" => "XXXXXXXXXXX"
|
65
|
+
},
|
66
|
+
"user_information" => {
|
67
|
+
"firstName" => "VARDENIS",
|
68
|
+
"lastName" => "PAVARDENIS",
|
69
|
+
"companyName" => nil
|
70
|
+
},
|
71
|
+
"custom_data" => "correlation-123",
|
72
|
+
"source_data" => {
|
73
|
+
"type" => "BANKLINK",
|
74
|
+
"parameters" => {
|
75
|
+
"VK_USER" => "12345678900",
|
76
|
+
"VK_TIME" => "08:57:29"
|
77
|
+
}
|
78
|
+
}
|
79
|
+
}
|
80
|
+
```
|
81
|
+
|
82
|
+
### Ticket arguments
|
83
|
+
|
84
|
+
You can pass `custom_data` and override some configuration attributes when requesting ticket.
|
85
|
+
|
86
|
+
```ruby
|
87
|
+
ticket = VIISP::Auth.ticket(
|
88
|
+
custom_data: 'custom data',
|
89
|
+
postback_url: 'https://localhost',
|
90
|
+
providers: %w[auth.lt.identity.card auth.lt.bank],
|
91
|
+
attributes: %w[lt-personal-code lt-company-code],
|
92
|
+
user_information: %w[firstName lastName companyName email],
|
93
|
+
)
|
94
|
+
```
|
95
|
+
|
96
|
+
## Contributing
|
97
|
+
|
98
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/laurynas/viisp-auth. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
99
|
+
|
100
|
+
## License
|
101
|
+
|
102
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
103
|
+
|
104
|
+
## Code of Conduct
|
105
|
+
|
106
|
+
Everyone interacting in the VIISP::Auth project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/laurynas/viisp-auth/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
-----BEGIN CERTIFICATE-----
|
2
|
+
MIIDATCCAmoCCQDttqj6tPOteDANBgkqhkiG9w0BAQQFADCBxDELMAkGA1UEBhMC
|
3
|
+
TFQxGTAXBgNVBAgTEFZpbG5pYXVzIG0uIHNhdi4xEDAOBgNVBAcTB1ZpbG5pdXMx
|
4
|
+
FjAUBgNVBAoTDUlWUEsgcHJpZSBMUlYxLjAsBgNVBAsTJVRhcnB6aW55YmluaXUg
|
5
|
+
ZHVvbWVudSB2YWxkeW1vIHNreXJpdXMxGjAYBgNVBAMTEXd3dy5lcGFzbGF1Z29z
|
6
|
+
Lmx0MSQwIgYJKoZIhvcNAQkBFhV0LnNha2FsYXVza2FzQGl2cGsubHQwHhcNMDgw
|
7
|
+
OTA4MDgxMjM5WhcNMTMwOTA3MDgxMjM5WjCBxDELMAkGA1UEBhMCTFQxGTAXBgNV
|
8
|
+
BAgTEFZpbG5pYXVzIG0uI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t2cNO5cS
|
20
|
+
LiftYv0oIWMuwFAFLu7lM1AtaP/5dN/TefZNaCZob7rxDmR260mDrEBrTKf6wsI9
|
21
|
+
MKoHmmVvgCOgaDDXjum9wQKBgHnSUAD8p/aIMY7fZOtjaDL7spH0iWeHEOpBGpH6
|
22
|
+
SQk2T1nwKi9OC+HvhP8hn+qKiVH/Gpv2LC8rZAcXruDinrr+0HzNQnh5Qpm1crGW
|
23
|
+
243x/bUw1KVWhJo8FG58TSWlhi4UhPr33bBqHBmSIW2ZQB747oniEm1LRRsAWRQ3
|
24
|
+
HV2pAoGAR1ik8TmDQ4eD5CUlGKwQfL4LMCFl2XdCJNqwAjQ1maEKPj0u/zBBuKJ2
|
25
|
+
9Et3e3xoqo6Fz2m4u7+l3czoYquittKGS0s0iSC2F4wXhT0PaE8WrocPO2oK+9bc
|
26
|
+
jZU8N3XM9rPmJruEw8sEsE4t/Cvi+rxTYp8zVgg0H9nkPyw4L7Y=
|
27
|
+
-----END RSA PRIVATE KEY-----
|
data/lib/viisp/auth.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
require 'viisp/auth/version'
|
3
|
+
require 'viisp/auth/configuration'
|
4
|
+
require 'viisp/auth/errors'
|
5
|
+
require 'viisp/auth/client'
|
6
|
+
require 'viisp/auth/signing'
|
7
|
+
require 'viisp/auth/identity'
|
8
|
+
require 'viisp/auth/requests/soap'
|
9
|
+
require 'viisp/auth/requests/signature'
|
10
|
+
require 'viisp/auth/requests/ticket'
|
11
|
+
require 'viisp/auth/requests/identity'
|
12
|
+
|
13
|
+
module VIISP
|
14
|
+
module Auth
|
15
|
+
module_function
|
16
|
+
|
17
|
+
def configure
|
18
|
+
yield(configuration)
|
19
|
+
end
|
20
|
+
|
21
|
+
def configuration
|
22
|
+
@configuration ||= Configuration.new
|
23
|
+
end
|
24
|
+
|
25
|
+
def client
|
26
|
+
@client ||= Client.new
|
27
|
+
end
|
28
|
+
|
29
|
+
def portal_endpoint
|
30
|
+
configuration.portal_endpoint
|
31
|
+
end
|
32
|
+
|
33
|
+
def ticket(options = {})
|
34
|
+
request = Requests::Ticket.new(options).build
|
35
|
+
|
36
|
+
doc = client.post(request)
|
37
|
+
doc.remove_namespaces!
|
38
|
+
doc.at('ticket')&.text
|
39
|
+
end
|
40
|
+
|
41
|
+
def identity(options = {})
|
42
|
+
request = Requests::Identity.new(options).build
|
43
|
+
|
44
|
+
doc = client.post(request)
|
45
|
+
doc.remove_namespaces!
|
46
|
+
|
47
|
+
Identity.new(doc).to_hash
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'faraday'
|
4
|
+
|
5
|
+
module VIISP
|
6
|
+
module Auth
|
7
|
+
class Client
|
8
|
+
def post(document)
|
9
|
+
with_error_handling do
|
10
|
+
request = Signing.sign(document)
|
11
|
+
response = connection.post('', request)
|
12
|
+
xml = Nokogiri::XML(response.body)
|
13
|
+
Signing.validate!(xml)
|
14
|
+
xml
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def with_error_handling
|
21
|
+
yield
|
22
|
+
rescue Faraday::ClientError => e
|
23
|
+
raise(RequestError, "#{e.message}. #{e.response}")
|
24
|
+
end
|
25
|
+
|
26
|
+
def connection
|
27
|
+
@connection ||= Faraday.new(url: configuration.endpoint) do |builder|
|
28
|
+
builder.options[:timeout] = configuration.read_timeout
|
29
|
+
builder.options[:open_timeout] = configuration.open_timeout
|
30
|
+
|
31
|
+
builder.headers['Accept'] = 'application/xml'
|
32
|
+
|
33
|
+
builder.response :raise_error
|
34
|
+
|
35
|
+
builder.adapter Faraday.default_adapter
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def configuration
|
40
|
+
VIISP::Auth.configuration
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|