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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cc49ec4534989fd76f869896d52258b866b879e4
4
- data.tar.gz: 4ff90046347bc39b6da5d2c8952c189a02dccf2d
3
+ metadata.gz: e3f623f83af8c6d64d5e4adb5f530c467a576107
4
+ data.tar.gz: 684fe452006675f095eddadd3aa1af6f78f10251
5
5
  SHA512:
6
- metadata.gz: bd1276c580d7a593c73ce0b496250e4b1e131aa97da3205498927afe94ae7efc45595a5c9d62eb3782c2bcaf57b4811810343741b0572038fc78761e0eab249c
7
- data.tar.gz: 14e4399e573bbcaf51f70d68f1a9886b0864a2c2677c05af34e344ed3ff2ed800bc4427a1a8dd0dfae338298d1b6bda10a5dc5cb76fdd80dd6f42950fc703fed
6
+ metadata.gz: 522a2f65d701a9776e15909a9e67b1a796f96ae5e79ff99dbbd379775c8fad865fd08040dca14d5e8c541a8159757d6e2642c8ee21fca0e6dda611020255cbc4
7
+ data.tar.gz: 76e6d004d1ca6ab3fd0e1d29bee76538102e293aac23410a494de5c0892d52ce823494455dbe5f29ab9231dd02f2b33fda77428b49c469c549ac5875af0faebf
data/esteid.gemspec CHANGED
@@ -22,4 +22,5 @@ Gem::Specification.new do |spec|
22
22
 
23
23
  spec.add_development_dependency "bundler", "~> 1.15"
24
24
  spec.add_development_dependency "rake", "~> 10.0"
25
+ spec.add_development_dependency "rspec", "~> 3.2"
25
26
  end
@@ -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
@@ -1,3 +1,3 @@
1
1
  module EstEID
2
- VERSION = "0.1.0"
2
+ VERSION = "1.0.0"
3
3
  end
data/lib/esteid.rb CHANGED
@@ -1,5 +1,8 @@
1
- require "esteid/version"
2
-
3
- module EstEID
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: 0.1.0
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: