omniauth-icos 1.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 +7 -0
- data/.gitignore +55 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +64 -0
- data/README.md +36 -0
- data/Rakefile +8 -0
- data/lib/omniauth-icos.rb +2 -0
- data/lib/omniauth-icos/version.rb +5 -0
- data/lib/omniauth/strategies/icos.rb +83 -0
- data/omniauth-icos.gemspec +27 -0
- data/spec/omniauth/strategies/icos_spec.rb +31 -0
- data/spec/spec_helper.rb +11 -0
- metadata +154 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 558e0a0bf99f64aad6ce865cf82687368fc43677
|
4
|
+
data.tar.gz: 92ccde964c4332b20bc8f3273fc6a9c0ddcfb12d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b07c9831b7cc6c39cca3941bff0bcfe9a92fa0291393ec5c6ca0be2aef3082fb9bba18e66490f82c28a635eb20a2f8977a227b8696971c016fc3bd0ec4733908
|
7
|
+
data.tar.gz: caab6e3c2dde5d8d84cd5b6a40af87f3b92b6d92b799625b13b7eb18eaae92b515c0257c038497b62990781f08ff08df51de1ef10931cc76cd3f16dc3790aea5
|
data/.gitignore
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
# Created by .ignore support plugin (hsz.mobi)
|
2
|
+
### Ruby template
|
3
|
+
*.gem
|
4
|
+
*.rbc
|
5
|
+
/.config
|
6
|
+
/coverage/
|
7
|
+
/InstalledFiles
|
8
|
+
/pkg/
|
9
|
+
/spec/reports/
|
10
|
+
/spec/examples.txt
|
11
|
+
/test/tmp/
|
12
|
+
/test/version_tmp/
|
13
|
+
/tmp/
|
14
|
+
|
15
|
+
# Used by dotenv library to load environment variables.
|
16
|
+
# .env
|
17
|
+
|
18
|
+
## Specific to RubyMotion:
|
19
|
+
.dat*
|
20
|
+
.repl_history
|
21
|
+
build/
|
22
|
+
*.bridgesupport
|
23
|
+
build-iPhoneOS/
|
24
|
+
build-iPhoneSimulator/
|
25
|
+
|
26
|
+
## Specific to RubyMotion (use of CocoaPods):
|
27
|
+
#
|
28
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
29
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
30
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
31
|
+
#
|
32
|
+
# vendor/Pods/
|
33
|
+
|
34
|
+
## Documentation cache and generated files:
|
35
|
+
/.yardoc/
|
36
|
+
/_yardoc/
|
37
|
+
/doc/
|
38
|
+
/rdoc/
|
39
|
+
|
40
|
+
## Environment normalization:
|
41
|
+
/.bundle/
|
42
|
+
/vendor/bundle
|
43
|
+
/lib/bundler/man/
|
44
|
+
|
45
|
+
# for a library or gem, you might want to ignore these files since the code is
|
46
|
+
# intended to run in multiple environments; otherwise, check them in:
|
47
|
+
# Gemfile.lock
|
48
|
+
# .ruby-version
|
49
|
+
# .ruby-gemset
|
50
|
+
|
51
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
52
|
+
.rvmrc
|
53
|
+
|
54
|
+
/.idea/*
|
55
|
+
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
omniauth-icos (1.0.0)
|
5
|
+
multi_json
|
6
|
+
omniauth-oauth (~> 1.0)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: http://rubygems.org/
|
10
|
+
specs:
|
11
|
+
addressable (2.5.2)
|
12
|
+
public_suffix (>= 2.0.2, < 4.0)
|
13
|
+
crack (0.4.3)
|
14
|
+
safe_yaml (~> 1.0.0)
|
15
|
+
diff-lcs (1.3)
|
16
|
+
docile (1.1.5)
|
17
|
+
hashdiff (0.3.7)
|
18
|
+
hashie (3.5.6)
|
19
|
+
json (2.1.0)
|
20
|
+
multi_json (1.12.2)
|
21
|
+
oauth (0.5.3)
|
22
|
+
omniauth (1.7.1)
|
23
|
+
hashie (>= 3.4.6, < 3.6.0)
|
24
|
+
rack (>= 1.6.2, < 3)
|
25
|
+
omniauth-oauth (1.1.0)
|
26
|
+
oauth
|
27
|
+
omniauth (~> 1.0)
|
28
|
+
public_suffix (3.0.1)
|
29
|
+
rack (2.0.3)
|
30
|
+
rack-test (0.8.2)
|
31
|
+
rack (>= 1.0, < 3)
|
32
|
+
rake (12.3.0)
|
33
|
+
rspec (2.99.0)
|
34
|
+
rspec-core (~> 2.99.0)
|
35
|
+
rspec-expectations (~> 2.99.0)
|
36
|
+
rspec-mocks (~> 2.99.0)
|
37
|
+
rspec-core (2.99.2)
|
38
|
+
rspec-expectations (2.99.2)
|
39
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
40
|
+
rspec-mocks (2.99.4)
|
41
|
+
safe_yaml (1.0.4)
|
42
|
+
simplecov (0.15.1)
|
43
|
+
docile (~> 1.1.0)
|
44
|
+
json (>= 1.8, < 3)
|
45
|
+
simplecov-html (~> 0.10.0)
|
46
|
+
simplecov-html (0.10.2)
|
47
|
+
webmock (3.1.1)
|
48
|
+
addressable (>= 2.3.6)
|
49
|
+
crack (>= 0.3.2)
|
50
|
+
hashdiff
|
51
|
+
|
52
|
+
PLATFORMS
|
53
|
+
ruby
|
54
|
+
|
55
|
+
DEPENDENCIES
|
56
|
+
omniauth-icos!
|
57
|
+
rack-test
|
58
|
+
rake
|
59
|
+
rspec (~> 2.7)
|
60
|
+
simplecov
|
61
|
+
webmock
|
62
|
+
|
63
|
+
BUNDLED WITH
|
64
|
+
1.16.0
|
data/README.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
OmniAuth ICOS ID
|
2
|
+
==============
|
3
|
+
|
4
|
+
This gem contains the ICOS ID strategy for OmniAuth.
|
5
|
+
|
6
|
+
For more information about ICOS ID: http://icosid.com
|
7
|
+
|
8
|
+
## Installing
|
9
|
+
|
10
|
+
Add to your `Gemfile`:
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
gem 'omniauth-icos'
|
14
|
+
```
|
15
|
+
|
16
|
+
Then `bundle install`.
|
17
|
+
|
18
|
+
|
19
|
+
## Basic Usage
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
|
23
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
24
|
+
provider :icos, ENV['ICOS_CLIENT_ID'], ENV['ICOS_CLIENT_SECRET']
|
25
|
+
end
|
26
|
+
|
27
|
+
```
|
28
|
+
|
29
|
+
You should use the provider name which is 'icos'.
|
30
|
+
|
31
|
+
|
32
|
+
After you have the gem running and the configuration is done, you can get to the follow url to log the user in:
|
33
|
+
|
34
|
+
http://localhost:3000/users/auth/icos
|
35
|
+
|
36
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
require 'omniauth-oauth2'
|
2
|
+
require 'multi_json'
|
3
|
+
require 'securerandom'
|
4
|
+
|
5
|
+
module OmniAuth
|
6
|
+
module Strategies
|
7
|
+
class ICOS < OmniAuth::Strategies::OAuth2
|
8
|
+
DEFAULT_SCOPES = 'hydra.consent offline'
|
9
|
+
|
10
|
+
option :name, 'icos'
|
11
|
+
|
12
|
+
option :client_options, {
|
13
|
+
authorize_url: '/oauth2/auth',
|
14
|
+
token_url: '/oauth2/token',
|
15
|
+
site: 'https://icosid.com'
|
16
|
+
}
|
17
|
+
|
18
|
+
option :authorize_params, {
|
19
|
+
state: SecureRandom.hex,
|
20
|
+
scopes: DEFAULT_SCOPES
|
21
|
+
}
|
22
|
+
|
23
|
+
option :token_params, {
|
24
|
+
state: SecureRandom.hex,
|
25
|
+
scopes: DEFAULT_SCOPES
|
26
|
+
}
|
27
|
+
|
28
|
+
uid { user_info['Id'] }
|
29
|
+
|
30
|
+
info do
|
31
|
+
{
|
32
|
+
:email => user_info['Email'],
|
33
|
+
:phone => user_info['Phone'],
|
34
|
+
:name => compact_full_name,
|
35
|
+
:first_name => user_info['FirstName'],
|
36
|
+
:middle_name => user_info['MiddleName'],
|
37
|
+
:last_name => user_info['LastName'],
|
38
|
+
:county => user_info['County'],
|
39
|
+
:citizenship => user_info['Citizenship'],
|
40
|
+
:address => user_info['Address'],
|
41
|
+
:document_number => user_info['DocumentNumber'],
|
42
|
+
:use_g2fa => user_info['UseG2fa'],
|
43
|
+
:globalid_verify => user_info['GlobalidVerify'],
|
44
|
+
:globalid_agent_verify => user_info['GlobalidAgentVerify'],
|
45
|
+
:netki_status => user_info['NetkiStatus'],
|
46
|
+
:eth_wallet => user_info['EthWallet']
|
47
|
+
}
|
48
|
+
end
|
49
|
+
|
50
|
+
extra do
|
51
|
+
{
|
52
|
+
:raw_info => raw_info
|
53
|
+
}
|
54
|
+
end
|
55
|
+
|
56
|
+
def build_access_token
|
57
|
+
options.token_params.merge!(:headers => {'Authorization' => basic_auth_header })
|
58
|
+
super
|
59
|
+
end
|
60
|
+
|
61
|
+
def basic_auth_header
|
62
|
+
'Basic ' + Base64.strict_encode64("#{options[:client_id]}:#{options[:client_secret]}")
|
63
|
+
end
|
64
|
+
|
65
|
+
def compact_full_name
|
66
|
+
[user_info['FirstName'], user_info['MiddleName'], user_info['LastName']].reject { |name| name.empty? }.join(' ')
|
67
|
+
end
|
68
|
+
|
69
|
+
def raw_info
|
70
|
+
puts MultiJson.decode(access_token.get('/v1/services/client/').body)
|
71
|
+
@raw_info ||= MultiJson.decode(access_token.get('/v1/services/client/').body)
|
72
|
+
rescue ::Errno::ETIMEDOUT
|
73
|
+
raise ::Timeout::Error
|
74
|
+
end
|
75
|
+
|
76
|
+
def user_info
|
77
|
+
@user_info ||= raw_info.nil? ? {} : raw_info['Result']
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
OmniAuth.config.add_camelization 'icos', 'ICOS'
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path('../lib', __FILE__)
|
3
|
+
require 'omniauth-icos/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gem.name = 'omniauth-icos'
|
7
|
+
gem.version = OmniAuth::ICOS::VERSION
|
8
|
+
gem.authors = ['Nikita Anistratenko']
|
9
|
+
gem.email = ['steverovsky@gmail.com']
|
10
|
+
gem.homepage = 'https://github.com/steverovsky/omniauth-icos'
|
11
|
+
gem.summary = %q{OmniAuth strategy for ICOS ID}
|
12
|
+
gem.description = %q{OmniAuth strategy for ICOS ID}
|
13
|
+
|
14
|
+
gem.files = `git ls-files`.split("\n")
|
15
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
17
|
+
gem.require_paths = ['lib']
|
18
|
+
|
19
|
+
gem.add_runtime_dependency 'omniauth'
|
20
|
+
gem.add_runtime_dependency 'omniauth-oauth2'
|
21
|
+
gem.add_runtime_dependency 'multi_json'
|
22
|
+
|
23
|
+
gem.add_development_dependency 'rspec', '~> 2.7'
|
24
|
+
gem.add_development_dependency 'rack-test'
|
25
|
+
gem.add_development_dependency 'simplecov'
|
26
|
+
gem.add_development_dependency 'webmock'
|
27
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe OmniAuth::Strategies::Icos do
|
4
|
+
subject do
|
5
|
+
OmniAuth::Strategies::Icos.new({})
|
6
|
+
end
|
7
|
+
|
8
|
+
context 'client options' do
|
9
|
+
it 'should have correct name' do
|
10
|
+
expect(subject.options.name).to eq 'icos'
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'should have correct site' do
|
14
|
+
expect(subject.options.client_options.site).to eq 'https://icosid.com'
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should have correct authorize url' do
|
18
|
+
expect(subject.options.client_options[:authorize_url]).to eq '/oauth2/auth'
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should have correct token url' do
|
22
|
+
expect(subject.options.client_options[:token_url]).to eq '/oauth2/token'
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context 'default scopes' do
|
27
|
+
it 'should have correct default scope' do
|
28
|
+
expect(OmniAuth::Strategies::Icos::DEFAULT_SCOPES).to eq 'hydra.consent offline'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
$:.unshift File.expand_path('..', __FILE__)
|
2
|
+
$:.unshift File.expand_path('../../lib', __FILE__)
|
3
|
+
require 'rspec'
|
4
|
+
require 'rack/test'
|
5
|
+
require 'omniauth'
|
6
|
+
require 'omniauth-icos'
|
7
|
+
|
8
|
+
RSpec.configure do |config|
|
9
|
+
config.include Rack::Test::Methods
|
10
|
+
config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
|
11
|
+
end
|
metadata
ADDED
@@ -0,0 +1,154 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-icos
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nikita Anistratenko
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-11-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: omniauth
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: omniauth-oauth2
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: multi_json
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.7'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '2.7'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rack-test
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: simplecov
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: webmock
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description: OmniAuth strategy for ICOS ID
|
112
|
+
email:
|
113
|
+
- steverovsky@gmail.com
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- ".gitignore"
|
119
|
+
- Gemfile
|
120
|
+
- Gemfile.lock
|
121
|
+
- README.md
|
122
|
+
- Rakefile
|
123
|
+
- lib/omniauth-icos.rb
|
124
|
+
- lib/omniauth-icos/version.rb
|
125
|
+
- lib/omniauth/strategies/icos.rb
|
126
|
+
- omniauth-icos.gemspec
|
127
|
+
- spec/omniauth/strategies/icos_spec.rb
|
128
|
+
- spec/spec_helper.rb
|
129
|
+
homepage: https://github.com/steverovsky/omniauth-icos
|
130
|
+
licenses: []
|
131
|
+
metadata: {}
|
132
|
+
post_install_message:
|
133
|
+
rdoc_options: []
|
134
|
+
require_paths:
|
135
|
+
- lib
|
136
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
137
|
+
requirements:
|
138
|
+
- - ">="
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
version: '0'
|
141
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
requirements: []
|
147
|
+
rubyforge_project:
|
148
|
+
rubygems_version: 2.6.11
|
149
|
+
signing_key:
|
150
|
+
specification_version: 4
|
151
|
+
summary: OmniAuth strategy for ICOS ID
|
152
|
+
test_files:
|
153
|
+
- spec/omniauth/strategies/icos_spec.rb
|
154
|
+
- spec/spec_helper.rb
|