omniauth-aid 1.0.0 → 2.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 55868809ab0259b17ba70a6a94891272b23750a8
4
- data.tar.gz: a64ddcd0286bca003198965948cf657f150606ac
3
+ metadata.gz: 1550ab83b145950553e634f284ae678696b9b9eb
4
+ data.tar.gz: 60d2bd9b52a1772c04972ed132ff8c1a27d4b28a
5
5
  SHA512:
6
- metadata.gz: ba48fb11312488195f5b6017131eadd65cea71cdf1e774f8c9b032f390c65229bfd9b5637094b99bd31ad0bf8c64bb35dec859cb311ec03e785e3c6e60e4d95d
7
- data.tar.gz: b42b289d7b4b250d36326e44a26f041b0db10de06ab920b7470600d5ff07d054deab01d71e7071e10e9d75218656965a7c9b80c93cfe5236b573cc85d08b760a
6
+ metadata.gz: 6f59f5443f132eb7cb5e0914be568790fc9bbe570e783177aff7ee5137d088d9aa18ff9b7a4662ac3714bab19ffe6aaec29fe50e50771e8317707390139a8a70
7
+ data.tar.gz: 4eb2a49757bce3c0d2f53422dc5cf7e1bab2c19f99cfecce70e895d4051999594095b6c200130266f2370b5c38b3586d0de603bb265bcf0e6453b98c6241014d
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT LICENSE
2
+
3
+ Copyright (c) Jonas Helgemo <jonas.helgemo@gmail.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md CHANGED
@@ -38,7 +38,7 @@ You can configure several options, which you pass in to the `provider` method vi
38
38
 
39
39
  Hash name | Default | Explanation
40
40
  --- | --- | ---
41
- `scope`, `name` | A space-separated list of permissions you want to request from the user. Optional scopes are: `email`, `phone`, `birth_date`, `tracking_key`, `access`, `external_accounts`, `customer`, `avatar`
41
+ `scope` | `id name` | A space-separated list of permissions you want to request from the user. Optional scopes are: `email`, `phone`, `birth_date`, `tracking_key`, `access`, `external_accounts`, `customer`, `avatar`
42
42
 
43
43
  For example, to request `name`, `birth_date` and `email` permissions and display the authentication page:
44
44
 
@@ -1,5 +1,5 @@
1
1
  module Omniauth
2
2
  module Aid
3
- VERSION = "1.0.0"
3
+ VERSION = "2.0.0"
4
4
  end
5
5
  end
@@ -1,25 +1,42 @@
1
1
  require 'omniauth/strategies/oauth2'
2
+ require 'json'
2
3
 
3
4
  module OmniAuth
4
5
  module Strategies
5
- class Aid < OmniAuth::Strategies::OAuth2
6
+ # Class used to parse and return omniauth responses from aID
7
+ class Aid < OmniAuth::Strategies::OAuth2
6
8
  option :name, :aid
7
9
  option :authorize_options, [:scope]
8
10
 
9
- option :client_options, {
10
- site: "https://www.aid.no",
11
- authorize_url: "/api/portunus/v1/oauth/authorize",
12
- token_url: "/api/portunus/v1/oauth/token"
13
- }
11
+ option :client_options,
12
+ site: 'https://www.aid.no',
13
+ authorize_url: '/api/portunus/v1/oauth/authorize',
14
+ token_url: '/api/portunus/v1/oauth/token'
14
15
 
15
- uid { raw_info.fetch("data"){ {} }["id"] }
16
+ uid { raw_info['uuid'] || raw_info.key['id'] }
16
17
 
17
18
  info do
18
- raw_info.fetch("data"){ {} }.fetch("attributes"){ {} }.to_h
19
+ prune!('id' => raw_info['id'],
20
+ 'uuid' => raw_info['uuid'],
21
+ 'nickname' => raw_info['name'],
22
+ 'email' => raw_info['email'],
23
+ 'name' => raw_info['name'],
24
+ 'image' => raw_info
25
+ .fetch('_links') { {} }
26
+ .fetch('avatar') { {} }['href']
27
+ )
28
+ end
29
+
30
+ def prune!(hash)
31
+ hash.delete_if do |_, value|
32
+ prune!(value) if value.is_a?(Hash)
33
+ value.nil? || (value.respond_to?(:empty?) && value.empty?)
34
+ end
19
35
  end
20
36
 
21
37
  def raw_info
22
- @raw_info ||= access_token.get('/api/mercury/v2/users/me').parsed || {}
38
+ response_body = access_token.get('/api/mercury/v2/users/me').body
39
+ @raw_info ||= JSON.parse(response_body) || {}
23
40
  end
24
41
  end
25
42
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-aid
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonas Helgemo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-10-12 00:00:00.000000000 Z
11
+ date: 2016-01-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -63,6 +63,7 @@ files:
63
63
  - ".travis.yml"
64
64
  - Gemfile
65
65
  - Gemfile.lock
66
+ - LICENSE
66
67
  - README.md
67
68
  - Rakefile
68
69
  - bin/console
@@ -93,7 +94,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
94
  version: '0'
94
95
  requirements: []
95
96
  rubyforge_project:
96
- rubygems_version: 2.4.5
97
+ rubygems_version: 2.4.5.1
97
98
  signing_key:
98
99
  specification_version: 4
99
100
  summary: Omniauth-strategy for using aID as an OAuth2-provider