esteid 0.1.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/esteid.gemspec +1 -0
- data/lib/esteid/authentication.rb +61 -0
- data/lib/esteid/version.rb +1 -1
- data/lib/esteid.rb +7 -4
- metadata +16 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e3f623f83af8c6d64d5e4adb5f530c467a576107
|
4
|
+
data.tar.gz: 684fe452006675f095eddadd3aa1af6f78f10251
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 522a2f65d701a9776e15909a9e67b1a796f96ae5e79ff99dbbd379775c8fad865fd08040dca14d5e8c541a8159757d6e2642c8ee21fca0e6dda611020255cbc4
|
7
|
+
data.tar.gz: 76e6d004d1ca6ab3fd0e1d29bee76538102e293aac23410a494de5c0892d52ce823494455dbe5f29ab9231dd02f2b33fda77428b49c469c549ac5875af0faebf
|
data/esteid.gemspec
CHANGED
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module EstEID
|
4
|
+
class Authentication
|
5
|
+
attr_reader :eid_cert
|
6
|
+
|
7
|
+
def initialize(request)
|
8
|
+
@eid_cert = request.headers["HTTP_X_ESTEID_CERT"]
|
9
|
+
end
|
10
|
+
|
11
|
+
def valid?
|
12
|
+
eid_cert_present?
|
13
|
+
end
|
14
|
+
|
15
|
+
def identity_code
|
16
|
+
return unless valid?
|
17
|
+
data_hash["serialNumber"]
|
18
|
+
end
|
19
|
+
|
20
|
+
def first_name
|
21
|
+
return unless valid?
|
22
|
+
data_hash["GN"]
|
23
|
+
end
|
24
|
+
|
25
|
+
def last_name
|
26
|
+
return unless valid?
|
27
|
+
data_hash["SN"]
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def data_hash
|
33
|
+
@data_hash ||= parse_header
|
34
|
+
end
|
35
|
+
|
36
|
+
def eid_cert_present?
|
37
|
+
!@eid_cert.nil? && !@eid_cert.empty?
|
38
|
+
end
|
39
|
+
|
40
|
+
def parse_header
|
41
|
+
return unless valid?
|
42
|
+
|
43
|
+
case
|
44
|
+
when /\//.match(@eid_cert)
|
45
|
+
parse_legacy
|
46
|
+
else
|
47
|
+
parse_rfc2253
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def parse_legacy
|
52
|
+
ary = @eid_cert.split("/").reject(&:empty?)
|
53
|
+
Hash[ary.collect { |k| k.split "=" }]
|
54
|
+
end
|
55
|
+
|
56
|
+
def parse_rfc2253
|
57
|
+
ary = @eid_cert.gsub("\\,", "/").split(",")
|
58
|
+
Hash[ary.collect { |k| k.split "=" }]
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
data/lib/esteid/version.rb
CHANGED
data/lib/esteid.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
# Your code goes here...
|
1
|
+
$:.unshift(File.dirname(__FILE__)) unless begin
|
2
|
+
$:.include?(File.dirname(__FILE__)) ||
|
3
|
+
$:.include?(File.expand_path(File.dirname(__FILE__)))
|
5
4
|
end
|
5
|
+
|
6
|
+
require "rubygems"
|
7
|
+
require "esteid/version"
|
8
|
+
require "esteid/authentication"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: esteid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Artem Pakk
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.2'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.2'
|
41
55
|
description:
|
42
56
|
email:
|
43
57
|
- apakk@me.com
|
@@ -55,6 +69,7 @@ files:
|
|
55
69
|
- bin/setup
|
56
70
|
- esteid.gemspec
|
57
71
|
- lib/esteid.rb
|
72
|
+
- lib/esteid/authentication.rb
|
58
73
|
- lib/esteid/version.rb
|
59
74
|
homepage: https://github.com/deskrock/esteid
|
60
75
|
licenses:
|