esteid 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/esteid/authentication.rb +16 -3
- data/lib/esteid/configuration.rb +19 -0
- data/lib/esteid/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 672562dea02e6e9b88e7033f37859c7b2baf2473
|
4
|
+
data.tar.gz: 857f4eb96f0006232b95004f13f4ba31f4c41049
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 241aebde16323d30d412426fde0c75edd99c54183c2120dd6eb9eef8b0e1737e341d54f0c7861554fc2eb6df4f39a25c1d439cf181b85cee1553772ab87e815f
|
7
|
+
data.tar.gz: ac572eaa3b41dcfef513af065a2a986a3fa7a27d33bc69d7c81b8d7fe00955fd914757595ebfa1709643b89704f7b7594037d7d590efee8b115769f4f5fd5ef2
|
@@ -3,7 +3,7 @@ module EstEID
|
|
3
3
|
attr_reader :eid_cert
|
4
4
|
|
5
5
|
def initialize(request)
|
6
|
-
@eid_cert = request.headers[
|
6
|
+
@eid_cert = request.headers[EstEID.config.certificate_header]
|
7
7
|
end
|
8
8
|
|
9
9
|
def valid?
|
@@ -17,16 +17,29 @@ module EstEID
|
|
17
17
|
|
18
18
|
def first_name
|
19
19
|
return unless valid?
|
20
|
-
data_hash["GN"]
|
20
|
+
normalize(data_hash["GN"])
|
21
21
|
end
|
22
22
|
|
23
23
|
def last_name
|
24
24
|
return unless valid?
|
25
|
-
data_hash["SN"]
|
25
|
+
normalize(data_hash["SN"])
|
26
26
|
end
|
27
27
|
|
28
28
|
private
|
29
29
|
|
30
|
+
def normalize(str)
|
31
|
+
result = str.gsub(/\\x([\da-fA-F]{2})/) { |m| [m].pack('H*') }
|
32
|
+
|
33
|
+
if str =~ /\\x00/
|
34
|
+
# UCS-2 encoding
|
35
|
+
result.force_encoding('utf-16be').encode!('utf-8')
|
36
|
+
else
|
37
|
+
result.force_encoding('UTF-8')
|
38
|
+
end
|
39
|
+
|
40
|
+
result
|
41
|
+
end
|
42
|
+
|
30
43
|
def data_hash
|
31
44
|
@data_hash ||= parse_header
|
32
45
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module EstEID
|
2
|
+
class << self
|
3
|
+
attr_reader :config
|
4
|
+
end
|
5
|
+
|
6
|
+
def self.configure
|
7
|
+
@config = Configuration.new
|
8
|
+
yield(@config) if block_given?
|
9
|
+
@config
|
10
|
+
end
|
11
|
+
|
12
|
+
class Configuration
|
13
|
+
attr_accessor :certificate_header
|
14
|
+
|
15
|
+
def initialize
|
16
|
+
@certificate_header = nil
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/esteid/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: esteid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Artem Pakk
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -71,6 +71,7 @@ files:
|
|
71
71
|
- esteid.gemspec
|
72
72
|
- lib/esteid.rb
|
73
73
|
- lib/esteid/authentication.rb
|
74
|
+
- lib/esteid/configuration.rb
|
74
75
|
- lib/esteid/version.rb
|
75
76
|
homepage: https://github.com/deskrock/esteid
|
76
77
|
licenses:
|