omniauth-latvija 1.1.1 → 6.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: 0239b9b5db1634778428119aa3ccd7babdf2feb5
4
- data.tar.gz: 87a622416084055bb8433baafbea7a4416536cb1
2
+ SHA256:
3
+ metadata.gz: 962c2888b86b4eb1b8b3354a8fc8410afb71fbd36804d2f1d032ac79acc1a496
4
+ data.tar.gz: 51403707278ddc99297a0ae49707960cde28e425f08db41e134edbf601533a4e
5
5
  SHA512:
6
- metadata.gz: 43ea0a0b2aca412cd61c73ec9e0e507dcb64f1db84c8057955cf22a347f5914c5e35c7fe7e586036c8b63d8b5cb8c3e055f0d814c418287f1c8cb373d3f37c7e
7
- data.tar.gz: a87c8ffdd361578b2fc2c7d945ac4e4712a9f1514f83a942c31452dd2c54228750fdb551410f16a670e1a3d38d15af61cfed60503ea084dfbac9b9fbd7d3cfca
6
+ metadata.gz: cbe1a3e2097c8417210cc71effd54098230a7ddc9e7f2f6e315098bcf0dc9d1f9959c125cae74b46c8b4095d7eecfb738b1e7a432407c1a96e146810a87e3c4f
7
+ data.tar.gz: d077eb5f9a46a4654017a12a7a3fc7e1afa904a0c99c989bbeb3719f576a32d4c6faf5ea41c1bf5ee84f77d9c6bab940f47d638901a025135c91f6eba13a54e5
data/README.md CHANGED
@@ -12,12 +12,14 @@ Provides the following authentication types:
12
12
  * Online bank
13
13
  * Citadele
14
14
  * Norvik banka
15
+ * PrivatBank
16
+ * eID
15
17
  * Lattelecom Mobile ID
16
18
 
17
19
  ## Installation
18
20
 
19
21
  ```ruby
20
- gem 'omniauth-latvija', :git => 'http://github.com/ebeigarts/omniauth-latvija.git'
22
+ gem 'omniauth-latvija'
21
23
  ```
22
24
 
23
25
  ## Usage
@@ -29,13 +31,44 @@ Here's a quick example, adding the middleware to a Rails app in `config/initiali
29
31
  ```ruby
30
32
  Rails.application.config.middleware.use OmniAuth::Builder do
31
33
  provider :latvija, {
32
- :endpoint => "https://epaktv.vraa.gov.lv/IVIS.LVP.STS/Default.aspx",
33
- :certificate => File.read("/path/to/cert"),
34
- :realm => "urn:federation:example.com"
34
+ endpoint: "https://epaktv.vraa.gov.lv/IVIS.LVP.STS/Default.aspx",
35
+ certificate: File.read("/path/to/cert.pem"),
36
+ private_key: File.read("/path/to/private_key.pem"), # mandatory, if the response is encrypted
37
+ realm: "urn:federation:example.com"
35
38
  }
36
39
  end
37
40
  ```
38
41
 
42
+
43
+ ## Auth Hash
44
+
45
+ Here's an example hash available in `request.env['omniauth.auth']`
46
+
47
+ ```ruby
48
+ {
49
+ provider: 'latvija',
50
+ uid: 'PK:12345612345',
51
+ info: {
52
+ name: 'JANIS BERZINS',
53
+ first_name: 'JANIS',
54
+ last_name: 'BERZINS',
55
+ private_personal_identifier: '12345612345'
56
+ },
57
+ extra: {
58
+ raw_info: {
59
+ givenname: 'JANIS',
60
+ surname: 'BERZINS',
61
+ privatepersonalidentifier: '12345612345',
62
+ historical_privatepersonalidentifier: [],
63
+ not_valid_before: '2019-05-09T07:29:41Z',
64
+ not_valid_on_or_after: '2019-05-09T08:29:41Z'
65
+ },
66
+ authentication_method: 'SWEDBANK',
67
+ legacy_uids: ['JANIS BERZINS, 12345612345']
68
+ }
69
+ }
70
+ ```
71
+
39
72
  ## References
40
73
 
41
74
  * http://docs.oasis-open.org/wsfed/federation/v1.2/os/ws-federation-1.2-spec-os.html
@@ -1,5 +1,5 @@
1
1
  module OmniAuth
2
2
  module Latvija
3
- VERSION = '1.1.1'
3
+ VERSION = '6.0.0'
4
4
  end
5
5
  end
@@ -1,76 +1,112 @@
1
- require "time"
2
- require "rexml/document"
3
- require "rexml/xpath"
4
- require "openssl"
5
- require "xmlcanonicalizer"
6
- require "digest/sha1"
1
+ require 'time'
2
+ require 'openssl'
3
+ require 'digest/sha1'
4
+ require 'digest/sha2'
5
+ require 'xmlenc'
6
+ require 'nokogiri'
7
+ require 'omniauth/strategies/latvija/response'
8
+ require 'omniauth/strategies/latvija/decryptor'
9
+ require 'omniauth/strategies/latvija/signed_document'
7
10
 
8
- require "omniauth/strategies/latvija/response"
9
- require "omniauth/strategies/latvija/signed_document"
11
+ module OmniAuth::Strategies
12
+ #
13
+ # Authenticate with Latvija.lv.
14
+ #
15
+ # @example Basic Rails Usage
16
+ #
17
+ # Add this to config/initializers/omniauth.rb
18
+ #
19
+ # Rails.application.config.middleware.use OmniAuth::Builder do
20
+ # provider :latvija, {
21
+ # endpoint: "https://epaktv.vraa.gov.lv/IVIS.LVP.STS/Default.aspx",
22
+ # certificate: File.read("/path/to/cert"),
23
+ # private: File.read("/path/to/private_key"),
24
+ # realm: "urn:federation:example.com"
25
+ # }
26
+ # end
27
+ #
28
+ class Latvija
29
+ include OmniAuth::Strategy
30
+ class ValidationError < StandardError; end
10
31
 
11
- module OmniAuth
12
- module Strategies
13
- #
14
- # Authenticate with Latvija.lv.
15
- #
16
- # @example Basic Rails Usage
17
- #
18
- # Add this to config/initializers/omniauth.rb
19
- #
20
- # Rails.application.config.middleware.use OmniAuth::Builder do
21
- # provider :latvija, {
22
- # :endpoint => "https://epaktv.vraa.gov.lv/IVIS.LVP.STS/Default.aspx",
23
- # :certificate => File.read("/path/to/cert"),
24
- # :realm => "urn:federation:example.com"
25
- # }
26
- # end
27
- #
28
- class Latvija
29
- include OmniAuth::Strategy
32
+ option :realm, nil
33
+ option :wfresh, false
34
+ option :endpoint, nil
35
+ option :certificate, nil
36
+ option :private_key, nil
30
37
 
31
- class ValidationError < StandardError; end
38
+ info do
39
+ {
40
+ name: full_name,
41
+ first_name: raw_info['givenname'],
42
+ last_name: raw_info['surname'],
43
+ private_personal_identifier: raw_info['privatepersonalidentifier']
44
+ }
45
+ end
32
46
 
33
- def request_phase
34
- params = {
35
- :wa => 'wsignin1.0',
36
- :wct => Time.now.utc.strftime('%Y-%m-%dT%H:%M:%SZ'),
37
- :wtrealm => @options[:realm],
38
- :wreply => callback_url,
39
- :wctx => callback_url,
40
- :wreq => '<trust:RequestSecurityToken xmlns:trust="http://docs.oasis-open.org/ws-sx/ws-trust/200512"><trust:Claims xmlns:i="http://schemas.xmlsoap.org/ws/2005/05/identity" Dialect="http://schemas.xmlsoap.org/ws/2005/05/identity"><i:ClaimType Uri="http://docs.oasis-open.org/wsfed/authorization/200706/claims/action" Optional="false" /></trust:Claims><trust:RequestType>http://docs.oasis-open.org/ws-sx/ws-trust/200512/Issue</trust:RequestType></trust:RequestSecurityToken>'
41
- }
42
- params[:wfresh] = @options[:wfresh] if @options[:wfresh]
43
- query_string = params.collect{ |key, value| "#{key}=#{Rack::Utils.escape(value)}" }.join('&')
44
- redirect "#{options[:endpoint]}?#{query_string}"
45
- end
47
+ extra do
48
+ {
49
+ raw_info: raw_info,
50
+ authentication_method: @response.authentication_method,
51
+ legacy_uids: legacy_uids
52
+ }
53
+ end
54
+
55
+ def request_phase
56
+ params = {
57
+ wa: 'wsignin1.0',
58
+ wct: Time.now.utc.strftime('%Y-%m-%dT%H:%M:%SZ'),
59
+ wtrealm: options[:realm],
60
+ wreply: callback_url,
61
+ wctx: callback_url,
62
+ wreq: '<trust:RequestSecurityToken xmlns:trust="http://docs.oasis-open.org/ws-sx/ws-trust/200512"><trust:Claims xmlns:i="http://schemas.xmlsoap.org/ws/2005/05/identity" Dialect="http://schemas.xmlsoap.org/ws/2005/05/identity"><i:ClaimType Uri="http://docs.oasis-open.org/wsfed/authorization/200706/claims/action" Optional="false" /></trust:Claims><trust:RequestType>http://docs.oasis-open.org/ws-sx/ws-trust/200512/Issue</trust:RequestType></trust:RequestSecurityToken>'
63
+ }
64
+ params[:wfresh] = options[:wfresh] if options[:wfresh]
65
+ query_string = params.collect { |key, value| "#{key}=#{Rack::Utils.escape(value)}" }.join('&')
66
+ redirect "#{options[:endpoint]}?#{query_string}"
67
+ end
46
68
 
47
- def callback_phase
48
- if request.params['wresult']
49
- @response = OmniAuth::Strategies::Latvija::Response.new(request.params['wresult'], {
50
- :certificate => options[:certificate]
51
- })
52
- @response.validate!
53
- super
54
- else
55
- fail!(:invalid_response)
56
- end
57
- rescue Exception => e
58
- fail!(:invalid_response, e)
69
+ def callback_phase
70
+ if request.params['wresult']
71
+ @response = OmniAuth::Strategies::Latvija::Response.new(
72
+ request.params['wresult'],
73
+ certificate: options[:certificate],
74
+ private_key: options[:private_key]
75
+ )
76
+ @response.validate!
77
+ super
78
+ else
79
+ fail!(:invalid_response)
59
80
  end
81
+ rescue Exception => e
82
+ fail!(:invalid_response, e)
83
+ end
84
+
85
+ def raw_info
86
+ @response.attributes
87
+ end
60
88
 
61
- def auth_hash
62
- OmniAuth::Utils.deep_merge(super, {
63
- 'uid' => "#{@response.attributes['givenname']} #{@response.attributes['surname']}, #{@response.attributes["privatepersonalidentifier"]}",
64
- 'user_info' => {
65
- 'name' => "#{@response.attributes['givenname']} #{@response.attributes['surname']}",
66
- 'first_name' => @response.attributes['givenname'],
67
- 'last_name' => @response.attributes['surname'],
68
- 'private_personal_identifier' => @response.attributes['privatepersonalidentifier']
69
- },
70
- 'authentication_method' => @response.authentication_method,
71
- 'extra' => @response.attributes
72
- })
89
+ def uid
90
+ @response.name_identifier
91
+ end
92
+
93
+ def full_name
94
+ @full_name ||= "#{raw_info['givenname']} #{raw_info['surname']}"
95
+ end
96
+
97
+ def legacy_uids
98
+ # UIDs that could have been assigned to this identity by previous versions of the gem, or due to peronal identifier change
99
+
100
+ legacy_uids = [
101
+ "#{full_name}, #{raw_info["privatepersonalidentifier"]}" # generated by gem version <= 4.0
102
+ ]
103
+
104
+ raw_info.fetch('historical_privatepersonalidentifier', []).each do |historical_identifier|
105
+ legacy_uids << "#{full_name}, #{historical_identifier}" # generated by gem version <= 4.0
106
+ legacy_uids << "PK:#{historical_identifier}" # due to personal identifier change
73
107
  end
108
+
109
+ legacy_uids
74
110
  end
75
111
  end
76
112
  end
@@ -0,0 +1,16 @@
1
+ module OmniAuth::Strategies
2
+ class Latvija
3
+ class Decryptor
4
+ def initialize(response, key)
5
+ @response = response
6
+ @key = key
7
+ end
8
+
9
+ def decrypt
10
+ private_key = OpenSSL::PKey::RSA.new(@key)
11
+ encrypted_document = Xmlenc::EncryptedDocument.new(@response)
12
+ encrypted_document.decrypt(private_key)
13
+ end
14
+ end
15
+ end
16
+ end
@@ -1,52 +1,92 @@
1
- module OmniAuth
2
- module Strategies
3
- class Latvija
4
- class Response
5
- ASSERTION = "urn:oasis:names:tc:SAML:1.0:assertion"
6
-
7
- attr_accessor :options, :response, :document
8
-
9
- def initialize(response, options = {})
10
- raise ArgumentError.new("Response cannot be nil") if response.nil?
11
- self.options = options
12
- self.response = response
13
- self.document = OmniAuth::Strategies::Latvija::SignedDocument.new(response)
14
- end
1
+ module OmniAuth::Strategies
2
+ class Latvija
3
+ class Response
4
+ ASSERTION = 'urn:oasis:names:tc:SAML:1.0:assertion'.freeze
5
+
6
+ attr_accessor :options, :response
7
+
8
+ def initialize(response, **options)
9
+ raise ArgumentError, 'Response cannot be nil' if response.nil?
10
+ @options = options
11
+ @response = response
12
+ @document = OmniAuth::Strategies::Latvija::SignedDocument.new(response, private_key: options[:private_key])
13
+ end
14
+
15
+ def validate!
16
+ @document.validate!(fingerprint) && validate_conditions!
17
+ end
15
18
 
16
- def validate!
17
- document.validate!(fingerprint)
19
+ def xml
20
+ @document.nokogiri_xml
21
+ end
22
+
23
+ def authentication_method
24
+ @authentication_method ||= begin
25
+ xml.xpath('//saml:AuthenticationStatement', saml: ASSERTION).attribute('AuthenticationMethod')
18
26
  end
27
+ end
19
28
 
20
- def authentication_method
21
- @authentication_method ||= begin
22
- REXML::XPath.first(document, "//saml:AuthenticationStatement").attributes['AuthenticationMethod']
23
- end
29
+ def name_identifier
30
+ @name_identifier ||= begin
31
+ xml.xpath('//saml:AuthenticationStatement/saml:Subject/saml:NameIdentifier', saml: ASSERTION).text()
24
32
  end
33
+ end
25
34
 
26
- # A hash of alle the attributes with the response. Assuming there is only one value for each key
27
- def attributes
28
- @attributes ||= begin
29
- result = {}
35
+ # A hash of all the attributes with the response.
36
+ # Assuming there is only one value for each key
37
+ def attributes
38
+ @attributes ||= begin
39
+ attrs = {
40
+ 'not_valid_before' => not_valid_before,
41
+ 'not_valid_on_or_after' => not_valid_on_or_after,
42
+ 'historical_privatepersonalidentifier' => []
43
+ }
30
44
 
31
- stmt_element = REXML::XPath.first(document, "//a:Assertion/a:AttributeStatement", { "a" => ASSERTION })
32
- return {} if stmt_element.nil?
45
+ stmt_elements = xml.xpath('//a:Attribute', a: ASSERTION)
46
+ return attrs if stmt_elements.nil?
33
47
 
34
- stmt_element.elements.each do |attr_element|
35
- name = attr_element.attributes["AttributeName"]
36
- value = attr_element.elements.first.text
48
+ stmt_elements.each_with_object(attrs) do |element, result|
49
+ name = element.attribute('AttributeName').value
50
+ value = element.text
37
51
 
52
+ case name
53
+ when 'privatepersonalidentifier' # person can change their identifier, service will return all the versions
54
+ if element.attribute('OriginalIssuer') # this is the primary identifier, as returned by third party auth service
55
+ result[name] = value
56
+ else
57
+ result['historical_privatepersonalidentifier'] << value
58
+ end
59
+ else
38
60
  result[name] = value
39
61
  end
40
-
41
- result
42
62
  end
43
63
  end
64
+ end
65
+
66
+ private
67
+
68
+ def fingerprint
69
+ cert = OpenSSL::X509::Certificate.new(options[:certificate])
70
+ Digest::SHA256.hexdigest(cert.to_der).upcase.scan(/../).join(':')
71
+ end
44
72
 
45
- private
73
+ def conditions_tag
74
+ @conditions_tag ||= xml.xpath('//saml:Conditions', saml: ASSERTION)
75
+ end
76
+
77
+ def not_valid_before
78
+ @not_valid_before ||= conditions_tag.attribute('NotBefore').value
79
+ end
80
+
81
+ def not_valid_on_or_after
82
+ @not_valid_on_or_after ||= conditions_tag.attribute('NotOnOrAfter').value
83
+ end
46
84
 
47
- def fingerprint
48
- cert = OpenSSL::X509::Certificate.new(options[:certificate])
49
- Digest::SHA1.hexdigest(cert.to_der).upcase.scan(/../).join(":")
85
+ def validate_conditions!
86
+ if not_valid_on_or_after.present? && Time.current < Time.parse(not_valid_on_or_after)
87
+ true
88
+ else
89
+ raise ValidationError, 'Current time is on or after NotOnOrAfter condition'
50
90
  end
51
91
  end
52
92
  end
@@ -15,79 +15,97 @@
15
15
  # If applicable, add the following below the CDDL Header,
16
16
  # with the fields enclosed by brackets [] replaced by
17
17
  # your own identifying information:
18
- # "Portions Copyrighted [year] [name of copyright owner]"
18
+ # 'Portions Copyrighted [year] [name of copyright owner]'
19
19
  #
20
20
  # $Id: xml_sec.rb,v 1.6 2007/10/24 00:28:41 todddd Exp $
21
21
  #
22
22
  # Copyright 2007 Sun Microsystems Inc. All Rights Reserved
23
23
  # Portions Copyrighted 2007 Todd W Saxton.
24
24
 
25
- module OmniAuth
26
- module Strategies
27
- class Latvija
28
- class SignedDocument < REXML::Document
29
- DSIG = "http://www.w3.org/2000/09/xmldsig#"
25
+ module OmniAuth::Strategies
26
+ class Latvija
27
+ class SignedDocument
28
+ DSIG = 'http://www.w3.org/2000/09/xmldsig#'.freeze
29
+ XENC = 'http://www.w3.org/2001/04/xmlenc#'.freeze
30
+ CANON_MODE = Nokogiri::XML::XML_C14N_EXCLUSIVE_1_0
30
31
 
31
- attr_accessor :signed_element_id
32
+ def initialize(response, **opts)
33
+ @response = Nokogiri::XML.parse(response, &:noblanks)
34
+ return unless encrypted?
35
+ decryptor = OmniAuth::Strategies::Latvija::Decryptor.new(response, opts[:private_key])
36
+ decrypted_response = decryptor.decrypt
37
+ @response = Nokogiri::XML.parse(decrypted_response, &:noblanks)
38
+ end
32
39
 
33
- def initialize(response)
34
- super(response)
35
- extract_signed_element_id
36
- end
40
+ def validate!(idp_cert_fingerprint)
41
+ validate_fingerprint!(idp_cert_fingerprint)
42
+ sig_element = @response.xpath('//xmlns:Signature', xmlns: DSIG)
43
+
44
+ validate_digest!(sig_element)
45
+ validate_signature!(sig_element)
46
+ true
47
+ end
48
+
49
+ def nokogiri_xml
50
+ @response
51
+ end
37
52
 
38
- def validate!(idp_cert_fingerprint)
39
- # get cert from response
40
- base64_cert = self.elements["//ds:X509Certificate"].text
53
+ private
54
+
55
+ def encrypted?
56
+ @response.xpath('//xenc:EncryptedData', 'xmlns:xenc' => XENC).any?
57
+ end
58
+
59
+ def certificate
60
+ @certificate ||= begin
61
+ base64_cert = @response.xpath('//xmlns:X509Certificate', xmlns: DSIG).text
41
62
  cert_text = Base64.decode64(base64_cert)
42
- cert = OpenSSL::X509::Certificate.new(cert_text)
43
-
44
- # check cert matches registered idp cert
45
- fingerprint = Digest::SHA1.hexdigest(cert.to_der)
46
-
47
- if fingerprint != idp_cert_fingerprint.gsub(/[^a-zA-Z0-9]/,"").downcase
48
- raise ValidationError.new("Fingerprint mismatch")
49
- end
50
-
51
- # remove signature node
52
- sig_element = REXML::XPath.first(self, "//ds:Signature", { "ds" => DSIG })
53
- sig_element.remove
54
-
55
- # check digests
56
- REXML::XPath.each(sig_element, "//ds:Reference", {"ds"=>"http://www.w3.org/2000/09/xmldsig#"}) do |ref|
57
- uri = ref.attributes.get_attribute("URI").value
58
- hashed_element = REXML::XPath.first(self, "//[@AssertionID='#{uri[1,uri.size]}']")
59
- canoner = XML::Util::XmlCanonicalizer.new(false, true)
60
- canon_hashed_element = canoner.canonicalize(hashed_element)
61
- hash = Base64.encode64(Digest::SHA1.digest(canon_hashed_element)).chomp
62
- digest_value = REXML::XPath.first(ref, "//ds:DigestValue", { "ds" => DSIG }).text
63
-
64
- if hash != digest_value
65
- raise ValidationError.new("Digest mismatch")
66
- end
67
- end
68
-
69
- # verify signature
70
- canoner = XML::Util::XmlCanonicalizer.new(false, true)
71
- signed_info_element = REXML::XPath.first(sig_element, "//ds:SignedInfo", { "ds" => DSIG })
72
- canon_string = canoner.canonicalize(signed_info_element)
73
-
74
- base64_signature = REXML::XPath.first(sig_element, "//ds:SignatureValue", { "ds" => DSIG }).text
75
- signature = Base64.decode64(base64_signature)
76
-
77
- # get certificate object
78
- cert_text = Base64.decode64(base64_cert)
79
- cert = OpenSSL::X509::Certificate.new(cert_text)
80
-
81
- if !cert.public_key.verify(OpenSSL::Digest::SHA1.new, signature, canon_string)
82
- raise ValidationError.new("Key validation error")
83
- end
84
-
85
- true
63
+ OpenSSL::X509::Certificate.new(cert_text)
86
64
  end
65
+ end
66
+
67
+ def digest_method_class(reference)
68
+ value = reference.xpath('.//xmlns:DigestMethod', xmlns: DSIG).attribute('Algorithm').value
69
+ value == "#{DSIG}sha1" ? Digest::SHA1 : Digest::SHA256
70
+ end
71
+
72
+ def signature_method_class(sig_element)
73
+ value = sig_element.xpath('.//xmlns:SignatureMethod', xmlns: DSIG).attribute('Algorithm').value
74
+ value == "#{DSIG}rsa-sha1" ? OpenSSL::Digest::SHA1 : OpenSSL::Digest::SHA256
75
+ end
76
+
77
+ def validate_fingerprint!(idp_cert_fingerprint)
78
+ fingerprint = Digest::SHA256.hexdigest(certificate.to_der)
79
+ if fingerprint != idp_cert_fingerprint.gsub(/[^a-zA-Z0-9]/, '').downcase
80
+ raise ValidationError, 'Fingerprint mismatch'
81
+ end
82
+ end
83
+
84
+ def validate_digest!(sig_element)
85
+ response_without_signature = @response.dup
86
+ response_without_signature.xpath('//xmlns:Signature', xmlns: DSIG).remove
87
+
88
+ sig_element.xpath('.//xmlns:Reference', xmlns: DSIG).each do |ref|
89
+ uri = ref.attribute('URI').value
90
+ hashed_element = response_without_signature.
91
+ at_xpath("//*[@AssertionID='#{uri[1, uri.size]}']").
92
+ canonicalize(CANON_MODE)
93
+ hash = Base64.encode64(digest_method_class(ref).digest(hashed_element)).chomp
94
+ digest_value = ref.xpath('.//xmlns:DigestValue', xmlns: DSIG).text
95
+
96
+ raise ValidationError, 'Digest mismatch' if hash != digest_value
97
+ end
98
+ end
99
+
100
+ def validate_signature!(sig_element)
101
+ signed_info_element = sig_element.
102
+ at_xpath('.//xmlns:SignedInfo', xmlns: DSIG).
103
+ canonicalize(CANON_MODE)
104
+ base64_signature = sig_element.xpath('.//xmlns:SignatureValue', xmlns: DSIG).text
105
+ signature = Base64.decode64(base64_signature)
87
106
 
88
- def extract_signed_element_id
89
- reference_element = REXML::XPath.first(self, "//ds:Signature/ds:SignedInfo/ds:Reference", { "ds" => DSIG })
90
- self.signed_element_id = reference_element.attribute("URI").value unless reference_element.nil?
107
+ unless certificate.public_key.verify(signature_method_class(sig_element).new, signature, signed_info_element)
108
+ raise ValidationError, 'Key validation error'
91
109
  end
92
110
  end
93
111
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-latvija
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 6.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Edgars Beigarts
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-11 00:00:00.000000000 Z
11
+ date: 2020-06-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: omniauth
@@ -25,7 +25,7 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: canonix
28
+ name: xmlenc
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -39,33 +39,61 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: rake
42
+ name: nokogiri
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :development
47
+ version: 1.5.1
48
+ type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: 1.5.1
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '12.1'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '12.1'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: rspec
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
73
  - - "~>"
60
74
  - !ruby/object:Gem::Version
61
- version: '2.10'
75
+ version: '3.7'
62
76
  type: :development
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
80
  - - "~>"
67
81
  - !ruby/object:Gem::Version
68
- version: '2.10'
82
+ version: '3.7'
83
+ - !ruby/object:Gem::Dependency
84
+ name: byebug
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
69
97
  - !ruby/object:Gem::Dependency
70
98
  name: simplecov
71
99
  requirement: !ruby/object:Gem::Requirement
@@ -94,6 +122,20 @@ dependencies:
94
122
  - - ">="
95
123
  - !ruby/object:Gem::Version
96
124
  version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: timecop
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
97
139
  description: Latvija.lv authentication strategy for OmniAuth
98
140
  email:
99
141
  - edgars.beigarts@makit.lv
@@ -106,6 +148,7 @@ files:
106
148
  - lib/omniauth-latvija.rb
107
149
  - lib/omniauth-latvija/version.rb
108
150
  - lib/omniauth/strategies/latvija.rb
151
+ - lib/omniauth/strategies/latvija/decryptor.rb
109
152
  - lib/omniauth/strategies/latvija/response.rb
110
153
  - lib/omniauth/strategies/latvija/signed_document.rb
111
154
  homepage:
@@ -117,17 +160,16 @@ require_paths:
117
160
  - lib
118
161
  required_ruby_version: !ruby/object:Gem::Requirement
119
162
  requirements:
120
- - - ">="
163
+ - - ">"
121
164
  - !ruby/object:Gem::Version
122
- version: '0'
165
+ version: 2.1.0
123
166
  required_rubygems_version: !ruby/object:Gem::Requirement
124
167
  requirements:
125
168
  - - ">="
126
169
  - !ruby/object:Gem::Version
127
170
  version: '0'
128
171
  requirements: []
129
- rubyforge_project:
130
- rubygems_version: 2.4.6
172
+ rubygems_version: 3.0.6
131
173
  signing_key:
132
174
  specification_version: 4
133
175
  summary: Latvija.lv authentication strategy for OmniAuth