omniauth-irma 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 89bcfd3d0b656a570534dafe15fa27122d83aff5a4c46c2c7c593f1d3f96a922
4
+ data.tar.gz: 1d2f787afbf24204703c3a9e8a22128b6ad0bfd17f5c807f34649878407af059
5
+ SHA512:
6
+ metadata.gz: 7f6618898d39532d392cde4dc34efc892e6a8af8f547f73d96c322afcb1575ab82d64e71b6952d541a453ae7f9ff92e19d9462f792057146de2f1a1f7f069a1c
7
+ data.tar.gz: 072ce1f6496e69b7444fc3f61644d7e23d89c46456f3eabf44f3846c396ba3020d2c0f41947b9e27b1f7a8dc9a433b5739e1300119909a62353bb90baaead9a1
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in omniauth-irma.gemspec
4
+ gemspec
5
+
6
+ gem "rake", "~> 12.0"
data/LICENSE.txt ADDED
@@ -0,0 +1,19 @@
1
+ The MIT License (MIT)
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,40 @@
1
+ # Omniauth::Irma
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/omniauth/irma`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'omniauth-irma'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle install
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install omniauth-irma
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/omniauth-irma.
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
@@ -0,0 +1,94 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!-- Generator: Adobe Illustrator 23.0.4, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
+ <svg version="1.1" id="Layer_1" xmlns:serif="http://www.serif.com/"
4
+ xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 600 600"
5
+ style="enable-background:new 0 0 600 600;" xml:space="preserve">
6
+ <style type="text/css">
7
+ .st0{display:none;}
8
+ .st1{display:inline;}
9
+ .st2{fill:#D44454;}
10
+ .st3{fill:#FFBB58;}
11
+ .st4{fill:#2BC194;}
12
+ .st5{fill:#00B1E6;}
13
+ .st6{fill:#004C92;}
14
+ .st7{fill:#FFFFFF;}
15
+ .st8{clip-path:url(#SVGID_2_);}
16
+ </style>
17
+ <g transform="matrix(1,0,0,1,-0.588574,-0.544313)">
18
+ <g id="Rounded_Rectangle_1_1_" transform="matrix(0.945114,-0.32674,0.32674,0.945114,-8.94903,58.0541)" class="st0">
19
+ <g transform="matrix(0.945114,0.32674,-0.32674,0.945114,23.6518,-9.46055)" class="st1">
20
+ <path class="st2" d="M144.3,513.4c-13.8,0-25.9-8.3-30.1-20.5L41.1,276.8c-5.5-16.2,4.2-34.1,21.6-40l347.9-117.9
21
+ c3.7-1.3,7.6-1.9,11.4-1.9c13.8,0,25.9,8.3,30.1,20.5l73.1,216.1c5.5,16.2-4.2,34.1-21.6,40L155.7,511.5
22
+ C152,512.8,148.1,513.4,144.3,513.4L144.3,513.4z"/>
23
+ <path class="st2" d="M422.1,128.4c8.7,0,16.5,4.9,19.2,12.7l73.1,216.1c3.5,10.2-3,21.6-14.5,25.5L152,500.7
24
+ c-2.6,0.9-5.2,1.3-7.8,1.3c-8.7,0-16.5-4.9-19.2-12.7L52,273.1c-3.5-10.2,3-21.6,14.5-25.5l347.9-117.9
25
+ C416.9,128.8,419.5,128.4,422.1,128.4 M422.1,105.5c-5.1,0-10.2,0.8-15.1,2.5L59.1,225.9c-23.4,7.9-36.3,32.4-28.8,54.6
26
+ l73.1,216.1c5.7,17,22.2,28.3,40.9,28.3c5.1,0,10.2-0.8,15.1-2.5l347.9-117.9c23.4-7.9,36.3-32.4,28.8-54.6L463,133.8
27
+ C457.3,116.9,440.8,105.5,422.1,105.5z"/>
28
+ </g>
29
+ <g transform="matrix(0.945114,0.32674,-0.32674,0.945114,38.5375,-37.9081)" class="st1">
30
+ <path class="st3" d="M156.3,433.1c-13.8,0-25.9-8.3-30.1-20.5L53.2,196.4c-5.5-16.2,4.2-34.1,21.6-40L422.7,38.5
31
+ c3.7-1.3,7.6-1.9,11.4-1.9c13.8,0,25.9,8.3,30.1,20.5l73.1,216.1c5.5,16.2-4.2,34.1-21.6,40L167.8,431.2
32
+ C164.1,432.5,160.2,433.1,156.3,433.1L156.3,433.1z"/>
33
+ <path class="st3" d="M434.2,48.1c8.7,0,16.5,4.9,19.2,12.7L526.4,277c3.5,10.2-3,21.6-14.5,25.5L164.1,420.4
34
+ c-2.6,0.9-5.2,1.3-7.8,1.3c-8.7,0-16.5-4.9-19.2-12.7L64.1,192.8c-3.5-10.2,3-21.6,14.5-25.5L426.4,49.4
35
+ C429,48.5,431.6,48.1,434.2,48.1 M434.2,25.2c-5.1,0-10.2,0.8-15.1,2.5L71.2,145.6c-23.4,7.9-36.3,32.4-28.8,54.6l73.1,216.1
36
+ c5.7,17,22.2,28.3,40.9,28.3c5.1,0,10.2-0.8,15.1-2.5l347.9-117.9c23.4-7.9,36.3-32.4,28.8-54.6L475.1,53.5
37
+ C469.3,36.6,452.9,25.2,434.2,25.2z"/>
38
+ </g>
39
+ <g transform="matrix(0.872113,0.489304,-0.489304,0.872113,33.7109,-39.4445)" class="st1">
40
+ <path class="st4" d="M147.3,428.8c-13.8,0-25.9-8.3-30.1-20.5L44.2,192.2c-5.5-16.2,4.2-34.1,21.6-40L413.7,34.3
41
+ c3.7-1.3,7.6-1.9,11.4-1.9c13.8,0,25.9,8.3,30.1,20.5L528.2,269c5.5,16.2-4.2,34.1-21.6,40L158.7,426.9
42
+ C155,428.2,151.2,428.8,147.3,428.8L147.3,428.8z"/>
43
+ <path class="st4" d="M425.1,43.8c8.7,0,16.5,4.9,19.2,12.7l73.1,216.1c3.5,10.2-3,21.6-14.5,25.5L155,416.1
44
+ c-2.6,0.9-5.2,1.3-7.8,1.3c-8.7,0-16.5-4.9-19.2-12.7L55,188.5c-3.5-10.2,3-21.6,14.5-25.5L417.3,45.1
45
+ C419.9,44.2,422.6,43.8,425.1,43.8 M425.1,20.9c-5.1,0-10.2,0.8-15.1,2.5L62.1,141.3c-23.4,7.9-36.3,32.4-28.8,54.6L106.4,412
46
+ c5.7,17,22.2,28.3,40.9,28.3c5.1,0,10.2-0.8,15.1-2.5l347.9-117.9c23.4-7.9,36.3-32.4,28.8-54.6L466,49.2
47
+ C460.3,32.3,443.8,20.9,425.1,20.9z"/>
48
+ </g>
49
+ <g transform="matrix(0.876971,0.480544,-0.480544,0.876971,56.23,-21.0767)" class="st1">
50
+ <path class="st5" d="M219.4,442.5c-13.8,0-25.9-8.3-30.1-20.5l-73.1-216.1c-5.5-16.2,4.2-34.1,21.6-40L485.8,47.9
51
+ c3.7-1.3,7.6-1.9,11.4-1.9c13.8,0,25.9,8.3,30.1,20.5l73.1,216.1c5.5,16.2-4.2,34.1-21.6,40L230.8,440.6
52
+ C227.1,441.8,223.3,442.5,219.4,442.5L219.4,442.5z"/>
53
+ <path class="st5" d="M497.2,57.5c8.7,0,16.5,4.9,19.2,12.7l73.1,216.1c3.5,10.2-3,21.6-14.5,25.5L227.1,429.7
54
+ c-2.6,0.9-5.2,1.3-7.8,1.3c-8.7,0-16.5-4.9-19.2-12.7l-73.1-216.1c-3.5-10.2,3-21.6,14.5-25.5L489.4,58.8
55
+ C492,57.9,494.6,57.5,497.2,57.5 M497.2,34.5c-5.1,0-10.2,0.8-15.1,2.5L134.2,154.9c-23.4,7.9-36.3,32.4-28.8,54.6l73.1,216.1
56
+ c5.7,17,22.2,28.3,40.9,28.3c5.1,0,10.2-0.8,15.1-2.5l347.9-117.9c23.4-7.9,36.3-32.4,28.8-54.6L538.1,62.9
57
+ C532.4,45.9,515.9,34.5,497.2,34.5z"/>
58
+ </g>
59
+ </g>
60
+ <g id="Rounded_Rectangle_1_1_1" transform="matrix(1,0,0,1,12.3739,26.4544)" serif:id="Rounded_Rectangle_1_1_">
61
+ <g>
62
+ <path class="st6" d="M149.5,475.7c-13.8,0-25.9-8.3-30.1-20.5L46.3,239c-5.5-16.2,4.2-34.1,21.6-40L415.8,81.1
63
+ c3.7-1.3,7.6-1.9,11.4-1.9c13.8,0,25.9,8.3,30.1,20.5l73.1,216.1c5.5,16.2-4.2,34.1-21.6,40L160.9,473.8
64
+ C157.2,475,153.3,475.7,149.5,475.7L149.5,475.7z"/>
65
+ <path class="st7" d="M427.3,90.7c8.7,0,16.5,4.9,19.2,12.7l73.1,216.1c3.5,10.2-3,21.6-14.5,25.5L157.2,462.9
66
+ c-2.6,0.9-5.2,1.3-7.8,1.3c-8.7,0-16.5-4.9-19.2-12.7L57.2,235.3c-3.5-10.2,3-21.6,14.5-25.5L419.5,91.9
67
+ C422.1,91.1,424.7,90.7,427.3,90.7 M427.3,67.7c-5.1,0-10.2,0.8-15.1,2.5L64.3,188.1C40.9,196,28,220.5,35.5,242.7l73.1,216.1
68
+ c5.7,17,22.2,28.3,40.9,28.3c5.1,0,10.2-0.8,15.1-2.5l347.9-117.9c23.4-7.9,36.3-32.4,28.8-54.6L468.2,96.1
69
+ C462.5,79.1,446,67.7,427.3,67.7z"/>
70
+ </g>
71
+ </g>
72
+ <g id="IRMA_1_" transform="matrix(1,0,0,1,12.3739,26.4544)">
73
+ <g>
74
+ <defs>
75
+ <polygon id="SVGID_1_" points="521.1,321.7 482.2,205.6 508.1,204.4 547.4,317.3 547.4,65.5 29.8,65.5 29.8,491.6 547.4,491.6
76
+ 547.4,323.4 "/>
77
+ </defs>
78
+ <clipPath id="SVGID_2_">
79
+ <use xlink:href="#SVGID_1_" style="overflow:visible;"/>
80
+ </clipPath>
81
+ <g class="st8">
82
+ <rect x="178.7" y="207.8" class="st7" width="21.5" height="113.5"/>
83
+ <path class="st7" d="M225.1,207.8h39.4c11.6,0,21,3.4,28.3,10.2c7.3,6.8,10.9,15.2,10.9,25.3c0,7.1-2,13.5-6,19.2
84
+ c-4,5.7-9.4,9.9-16.2,12.7l26.4,46h-23.7l-23-42.8h-14.7v42.8h-21.5L225.1,207.8L225.1,207.8z M264.5,226.6h-17.9v33.1h17.9
85
+ c5.1,0,9.2-1.5,12.3-4.5c3.1-3,4.6-7,4.6-12c0-4.9-1.5-8.8-4.6-11.9C273.7,228.1,269.6,226.6,264.5,226.6z"/>
86
+ <path class="st7" d="M386.3,291.1l-17.7-0.1l-22.9-40.3v70.5h-21.5V207.8h19.1l34.1,60.5l34.3-60.5h18.9v113.5h-21.5v-70.3
87
+ L386.3,291.1z"/>
88
+ <path class="st7" d="M523.1,321.2l-7.6-24.2h-40.6l-7.6,24.2h-23.3l40.4-113.5h21.6l40.4,113.5H523.1z M495.2,233.2l-15,47.2
89
+ h30.1L495.2,233.2z"/>
90
+ </g>
91
+ </g>
92
+ </g>
93
+ </g>
94
+ </svg>
@@ -0,0 +1,19 @@
1
+ $(document).on("ready page:load", function() {
2
+ $("#irma-login-button").click(function(e) {
3
+ handle("/users/auth/irma", e);
4
+ });
5
+
6
+ $("#irma-register-button").click(function(e) {
7
+ handle("/users/auth/irma?register=true", e);
8
+ });
9
+
10
+ function handle(url, e) {
11
+ $.post(url, function(data) {
12
+ irma.handleSession(data.sessionPtr).then(function() {
13
+ console.log("done!");
14
+ window.location.replace("/users/auth/irma/callback?sessiontoken=" + data.token);
15
+ });
16
+ });
17
+ e.preventDefault();
18
+ }
19
+ });
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "omniauth/irma"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/lib/irma.rb ADDED
@@ -0,0 +1,2 @@
1
+ require "omniauth/irma/version"
2
+ require "omniauth/strategies/irma"
@@ -0,0 +1,5 @@
1
+ module Omniauth
2
+ module Irma
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,73 @@
1
+ module OmniAuth
2
+ module Strategies
3
+ class Irma
4
+ class Engine < Rails::Engine; end
5
+
6
+ include OmniAuth::Strategy
7
+
8
+ option :fields, %i[email zipcode over18 gender]
9
+ option :uid_field, :email
10
+
11
+ option :irma_server, "http://localhost:8088"
12
+ option :attrs_register, [[["pbdf.pbdf.email.email"]],[["pbdf.gemeente.address.zipcode","pbdf.gemeente.personalData.over18","pbdf.gemeente.personalData.gender"]]]
13
+ option :attrs_login, [[["pbdf.pbdf.email.email"]]]
14
+
15
+ LOOKUP = {
16
+ "pbdf.pbdf.email.email" => {:key => :email},
17
+ "pbdf.gemeente.address.zipcode" => {:key => :zipcode},
18
+ "pbdf.gemeente.personalData.over18" => {:key => :over18, :replace => {"Yes" => true, "No" => false}},
19
+ "pbdf.gemeente.personalData.gender" => {:key => :gender, :replace => {"M" => "male", "F" => "female"}},
20
+ }
21
+ option :attrs_lookup, LOOKUP
22
+
23
+ def request_phase
24
+ registering = !Rack::Utils.parse_nested_query(request.query_string)["register"].nil?
25
+ disclose = registering ? options[:attrs_register].to_json : options[:attrs_login].to_json
26
+ res = Faraday.post("#{options[:irma_server]}/session",
27
+ "{\"@context\":\"https://irma.app/ld/request/disclosure/v2\",\"disclose\":#{disclose}}",
28
+ "Content-Type" => "application/json").body
29
+ Rack::Response.new(res, 200, "content-type" => "application/json").finish
30
+ end
31
+
32
+ uid do
33
+ sessiontoken = token request
34
+ attrs = raw_info sessiontoken
35
+ attrs[:email]
36
+ end
37
+
38
+ info do
39
+ sessiontoken = token request
40
+ attrs = raw_info sessiontoken
41
+ attrs
42
+ end
43
+
44
+ def token(request)
45
+ Rack::Utils.parse_nested_query(request.query_string)["sessiontoken"]
46
+ end
47
+
48
+ def raw_info(sessiontoken)
49
+ if @raw_info.nil?
50
+ sessionresult = JSON.load(Faraday.get("#{options[:irma_server]}/session/#{sessiontoken}/result").body)
51
+
52
+ @raw_info = {}
53
+ lookup = LOOKUP.merge(options[:attrs_lookup])
54
+ puts lookup.to_json
55
+ sessionresult["disclosed"].each do |concon|
56
+ concon.each do |con|
57
+ attribute_id = con["id"]
58
+ opts = lookup[attribute_id]
59
+ raw_info_key = opts[:key]
60
+ raise RuntimeError if raw_info_key.nil?
61
+ val = con["rawvalue"]
62
+ if !opts[:replace].nil? && opts[:replace].key?(val)
63
+ val = opts[:replace][val]
64
+ end
65
+ @raw_info[raw_info_key] = val
66
+ end
67
+ end
68
+ end
69
+ @raw_info
70
+ end
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,24 @@
1
+ require_relative 'lib/omniauth/irma/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "omniauth-irma"
5
+ spec.version = Omniauth::Irma::VERSION
6
+ spec.authors = ["Confiks"]
7
+ spec.email = ["confiks@scriptbase.org"]
8
+
9
+ spec.summary = %q{IRMA strategy for OmniAuth}
10
+ spec.homepage = "https://irma.app/docs"
11
+ spec.license = "MIT"
12
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
13
+
14
+ spec.metadata["homepage_uri"] = spec.homepage
15
+
16
+ # Specify which files should be added to the gem when it is released.
17
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
18
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
19
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
20
+ end
21
+ spec.bindir = "exe"
22
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
+ spec.require_paths = ["lib"]
24
+ end
metadata ADDED
@@ -0,0 +1,57 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-irma
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Confiks
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-03-03 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email:
15
+ - confiks@scriptbase.org
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - ".gitignore"
21
+ - Gemfile
22
+ - LICENSE.txt
23
+ - README.md
24
+ - Rakefile
25
+ - app/assets/images/irmalogo.svg
26
+ - app/assets/javascripts/irma_omniauth.js
27
+ - bin/console
28
+ - bin/setup
29
+ - lib/irma.rb
30
+ - lib/omniauth/irma/version.rb
31
+ - lib/omniauth/strategies/irma.rb
32
+ - omniauth-irma.gemspec
33
+ homepage: https://irma.app/docs
34
+ licenses:
35
+ - MIT
36
+ metadata:
37
+ homepage_uri: https://irma.app/docs
38
+ post_install_message:
39
+ rdoc_options: []
40
+ require_paths:
41
+ - lib
42
+ required_ruby_version: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 2.3.0
47
+ required_rubygems_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
52
+ requirements: []
53
+ rubygems_version: 3.0.2
54
+ signing_key:
55
+ specification_version: 4
56
+ summary: IRMA strategy for OmniAuth
57
+ test_files: []