omniauth-centralid 1.1.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +9 -0
- data/CHANGELOG.md +22 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +52 -0
- data/MIT-LICENSE +1 -1
- data/README.md +54 -12
- data/Rakefile +6 -24
- data/lib/omniauth/strategies/centralid.rb +14 -9
- data/lib/omniauth-centralid/version.rb +1 -1
- data/omniauth-centralid.gemspec +35 -0
- metadata +80 -18
- data/test/omniauth_centralid_test.rb +0 -28
- data/test/test_helper.rb +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: '08637c544cff96c710495dfe33f1a8b1dc8518c06a8182de104f4dc091c0662a'
|
4
|
+
data.tar.gz: 004c208ca78837a67a400a7383120ec272e41dc52d73d35cdde81282bc82755e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a8fc89ad1a51cb4175146f23e028943cb0a99bc892c5d30f081e64979462ef52fc11ba919c3f9f3e9da161faf44e95bcd0c84b1b7450326aa5ee177ee71912d4
|
7
|
+
data.tar.gz: bde115d788db34b4f28485fe7711741a2f7fc3e20e7523d02d26449286cb409098cb12666250586f4e17c48b2cec638dd4f5da1852aedcdfacbb3cddcf28bf16
|
data/.gitignore
ADDED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
## 1.3.0 / 2022-11-14
|
4
|
+
|
5
|
+
- Update root URL
|
6
|
+
|
7
|
+
## 1.2.0 / 2018-07-03
|
8
|
+
|
9
|
+
- Upgrade `omniauth-oauth2` to 1.5
|
10
|
+
|
11
|
+
## 1.1.0 / 2017-06-25
|
12
|
+
|
13
|
+
- Pin `omniauth-oauth2` to 1.3. to make sure custom OAuth strategy works
|
14
|
+
- Removed `multi_json` dependency
|
15
|
+
|
16
|
+
## 1.0.0 / 2017-06-22
|
17
|
+
|
18
|
+
- Bump dependencies `multi_json` & `omniauth-oauth2`
|
19
|
+
|
20
|
+
## 0.1.0 / 2014-12-14
|
21
|
+
|
22
|
+
- Initial release
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
omniauth-centralid (1.1.0)
|
5
|
+
omniauth-oauth2 (~> 1.5.0)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
ansi (1.5.0)
|
11
|
+
builder (3.2.3)
|
12
|
+
faraday (0.12.2)
|
13
|
+
multipart-post (>= 1.2, < 3)
|
14
|
+
hashie (3.5.7)
|
15
|
+
jwt (1.5.6)
|
16
|
+
minitest (5.4.3)
|
17
|
+
minitest-reporters (1.3.0)
|
18
|
+
ansi
|
19
|
+
builder
|
20
|
+
minitest (>= 5.0)
|
21
|
+
ruby-progressbar
|
22
|
+
multi_json (1.13.1)
|
23
|
+
multi_xml (0.6.0)
|
24
|
+
multipart-post (2.0.0)
|
25
|
+
oauth2 (1.4.0)
|
26
|
+
faraday (>= 0.8, < 0.13)
|
27
|
+
jwt (~> 1.0)
|
28
|
+
multi_json (~> 1.3)
|
29
|
+
multi_xml (~> 0.5)
|
30
|
+
rack (>= 1.2, < 3)
|
31
|
+
omniauth (1.8.1)
|
32
|
+
hashie (>= 3.4.6, < 3.6.0)
|
33
|
+
rack (>= 1.6.2, < 3)
|
34
|
+
omniauth-oauth2 (1.5.0)
|
35
|
+
oauth2 (~> 1.1)
|
36
|
+
omniauth (~> 1.2)
|
37
|
+
rack (2.0.5)
|
38
|
+
rake (10.4.2)
|
39
|
+
ruby-progressbar (1.9.0)
|
40
|
+
|
41
|
+
PLATFORMS
|
42
|
+
ruby
|
43
|
+
|
44
|
+
DEPENDENCIES
|
45
|
+
bundler (~> 1.16)
|
46
|
+
minitest (~> 5.0)
|
47
|
+
minitest-reporters (~> 1.3)
|
48
|
+
omniauth-centralid!
|
49
|
+
rake
|
50
|
+
|
51
|
+
BUNDLED WITH
|
52
|
+
1.16.1
|
data/MIT-LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# OmniAuth Central ID
|
2
|
-
[![Build Status](https://
|
2
|
+
[![Build Status](https://semaphoreci.com/api/v1/olimart/omniauth-centralid-2/branches/master/badge.svg)](https://semaphoreci.com/olimart/omniauth-centralid-2)
|
3
3
|
|
4
4
|
This gem offers OmniAuth strategy for Central ID service.
|
5
5
|
|
@@ -8,29 +8,71 @@ This gem offers OmniAuth strategy for Central ID service.
|
|
8
8
|
First start by adding this gem to your Gemfile:
|
9
9
|
|
10
10
|
```ruby
|
11
|
-
gem
|
11
|
+
gem "omniauth-centralid"
|
12
12
|
```
|
13
13
|
|
14
|
-
Next,
|
14
|
+
Next, let OmniAuth know about provider. In a Rails app, create an initializer for instance `config/initializers/omniauth.rb` with:
|
15
15
|
|
16
16
|
```ruby
|
17
17
|
Rails.application.config.middleware.use OmniAuth::Builder do
|
18
|
-
provider :centralid, "
|
18
|
+
provider :centralid, "CENTRALID_KEY", "CENTRALID_SECRET"
|
19
19
|
end
|
20
20
|
```
|
21
|
+
You can override config, like
|
22
|
+
```ruby
|
23
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
24
|
+
provider :centralid, "CENTRALID_KEY", "CENTRALID_SECRET",
|
25
|
+
client_options: {
|
26
|
+
site: "http://localhost:3000"
|
27
|
+
}
|
28
|
+
end
|
29
|
+
```
|
30
|
+
In your routes file:
|
21
31
|
|
22
|
-
|
32
|
+
```ruby
|
33
|
+
get "auth/:provider/callback", to: "oauths#create"
|
34
|
+
get "auth/failure", to: "oauths#failure" # optional (to override default redirect behaviour)
|
35
|
+
```
|
23
36
|
|
24
|
-
|
37
|
+
Add a controller (oauths_controller.rb as defined in your routes)
|
25
38
|
|
26
|
-
|
39
|
+
```ruby
|
40
|
+
# sends the user on a trip to the provider,
|
41
|
+
# and after authorizing there back to the callback url.
|
42
|
+
def create
|
43
|
+
auth = request.env["omniauth.auth"]
|
44
|
+
user = User.find_by(provider: auth["provider"], uid: auth["uid"]).try(:user) || User.create_with_omniauth(auth)
|
45
|
+
# Sign in the user
|
46
|
+
session[:user_id] = user.id
|
47
|
+
redirect_to dashboard_path
|
48
|
+
end
|
27
49
|
|
28
|
-
|
50
|
+
# By default, it is supposed to raise an exception in development mode
|
51
|
+
# and redirect otherwise. Override if needed.
|
52
|
+
def failure
|
53
|
+
redirect_to login_path
|
54
|
+
end
|
55
|
+
```
|
29
56
|
|
30
|
-
|
57
|
+
And finally add a `create_with_omniauth` method in your user model.
|
31
58
|
|
32
|
-
|
59
|
+
```ruby
|
60
|
+
private
|
33
61
|
|
34
|
-
|
62
|
+
def self.create_with_omniauth(auth)
|
63
|
+
user = create! do |user|
|
64
|
+
user.full_name = auth["info"]["name"]
|
65
|
+
user.email = auth["info"]["email"]
|
66
|
+
user.password = SecureRandom.hex
|
67
|
+
user.authentications.new(
|
68
|
+
provider: auth["provider"],
|
69
|
+
uid: auth["uid"]
|
70
|
+
)
|
71
|
+
end
|
72
|
+
user
|
73
|
+
end
|
74
|
+
```
|
35
75
|
|
36
|
-
|
76
|
+
## Contributing
|
77
|
+
|
78
|
+
Run tests with `rake test`
|
data/Rakefile
CHANGED
@@ -1,28 +1,10 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
rescue LoadError
|
4
|
-
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
-
end
|
6
|
-
|
7
|
-
require 'rdoc/task'
|
8
|
-
|
9
|
-
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
-
rdoc.rdoc_dir = 'rdoc'
|
11
|
-
rdoc.title = 'OmniauthCentralid'
|
12
|
-
rdoc.options << '--line-numbers'
|
13
|
-
rdoc.rdoc_files.include('README.rdoc')
|
14
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
-
end
|
16
|
-
|
17
|
-
Bundler::GemHelper.install_tasks
|
18
|
-
|
19
|
-
require 'rake/testtask'
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rake/testtask"
|
20
3
|
|
21
4
|
Rake::TestTask.new(:test) do |t|
|
22
|
-
t.libs <<
|
23
|
-
t.libs <<
|
24
|
-
t.
|
25
|
-
t.verbose = false
|
5
|
+
t.libs << "test"
|
6
|
+
t.libs << "lib"
|
7
|
+
t.test_files = FileList["test/**/*_test.rb"]
|
26
8
|
end
|
27
9
|
|
28
|
-
task default
|
10
|
+
task :default => :test
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "omniauth-oauth2"
|
2
|
+
require "multi_json"
|
3
3
|
|
4
4
|
module OmniAuth
|
5
5
|
module Strategies
|
@@ -7,26 +7,31 @@ module OmniAuth
|
|
7
7
|
option :name, :centralid
|
8
8
|
|
9
9
|
option :client_options, {
|
10
|
-
site:
|
11
|
-
authorize_path:
|
10
|
+
site: "https://centralid.yafoy.com",
|
11
|
+
authorize_path: "/oauth/authorize"
|
12
12
|
}
|
13
13
|
|
14
14
|
option :fields, [:name, :email]
|
15
15
|
|
16
16
|
uid do
|
17
|
-
raw_info[
|
17
|
+
raw_info["id"]
|
18
18
|
end
|
19
19
|
|
20
20
|
info do
|
21
21
|
{
|
22
|
-
name: raw_info[
|
23
|
-
email: raw_info[
|
24
|
-
username: raw_info[
|
22
|
+
name: raw_info["full_name"],
|
23
|
+
email: raw_info["email"],
|
24
|
+
username: raw_info["username"]
|
25
25
|
}
|
26
26
|
end
|
27
27
|
|
28
28
|
def raw_info
|
29
|
-
@raw_info ||= access_token.get(
|
29
|
+
@raw_info ||= access_token.get("/api/v1/me").parsed
|
30
|
+
end
|
31
|
+
|
32
|
+
# https://github.com/intridea/omniauth-oauth2/issues/81
|
33
|
+
def callback_url
|
34
|
+
full_host + script_name + callback_path
|
30
35
|
end
|
31
36
|
end
|
32
37
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require "omniauth-centralid/version"
|
4
|
+
|
5
|
+
# Describe your gem and declare its dependencies:
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "omniauth-centralid"
|
8
|
+
s.version = OmniauthCentralid::VERSION
|
9
|
+
s.authors = ["yafoy"]
|
10
|
+
s.email = ["contact@yafoy.com"]
|
11
|
+
s.homepage = "http://github.com/yafoy/omniauth-centralid"
|
12
|
+
s.summary = "Central ID stategy for OmniAuth"
|
13
|
+
s.description = "This gem contains Central ID strategy for OmniAuth"
|
14
|
+
s.license = "MIT"
|
15
|
+
|
16
|
+
s.files = `git ls-files -z`.split("\x0").reject do |f|
|
17
|
+
f.match(%r{^(test|spec|features)/})
|
18
|
+
end
|
19
|
+
s.bindir = "exe"
|
20
|
+
s.executables = s.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
|
+
s.require_paths = ["lib"]
|
22
|
+
|
23
|
+
#s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.md"]
|
24
|
+
#s.test_files = Dir["test/**/*"]
|
25
|
+
|
26
|
+
# Pin omniauth-oauth2 since v1.4.0 removed the callback_url method
|
27
|
+
# https://github.com/intridea/omniauth-oauth2/issues/93#issuecomment-227247801
|
28
|
+
# https://github.com/WebTheoryLLC/omniauth-twitch/issues/3
|
29
|
+
s.add_runtime_dependency 'omniauth-oauth2', '~> 1.5', '>= 1.5.0'
|
30
|
+
|
31
|
+
s.add_development_dependency "bundler", "~> 1.16"
|
32
|
+
s.add_development_dependency "rake"
|
33
|
+
s.add_development_dependency "minitest", "~> 5.0"
|
34
|
+
s.add_development_dependency "minitest-reporters", "~> 1.3"
|
35
|
+
end
|
metadata
CHANGED
@@ -1,49 +1,114 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniauth-centralid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- yafoy
|
8
|
-
autorequire:
|
9
|
-
bindir:
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-11-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: omniauth-oauth2
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.
|
19
|
+
version: '1.5'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 1.5.0
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- -
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.5'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.5.0
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: bundler
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '1.16'
|
40
|
+
type: :development
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '1.16'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rake
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: minitest
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '5.0'
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - "~>"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '5.0'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: minitest-reporters
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - "~>"
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '1.3'
|
82
|
+
type: :development
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - "~>"
|
25
87
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.3
|
27
|
-
description: This gem contains
|
88
|
+
version: '1.3'
|
89
|
+
description: This gem contains Central ID strategy for OmniAuth
|
28
90
|
email:
|
29
91
|
- contact@yafoy.com
|
30
92
|
executables: []
|
31
93
|
extensions: []
|
32
94
|
extra_rdoc_files: []
|
33
95
|
files:
|
96
|
+
- ".gitignore"
|
97
|
+
- CHANGELOG.md
|
98
|
+
- Gemfile
|
99
|
+
- Gemfile.lock
|
34
100
|
- MIT-LICENSE
|
35
101
|
- README.md
|
36
102
|
- Rakefile
|
37
103
|
- lib/omniauth-centralid.rb
|
38
104
|
- lib/omniauth-centralid/version.rb
|
39
105
|
- lib/omniauth/strategies/centralid.rb
|
40
|
-
-
|
41
|
-
- test/test_helper.rb
|
106
|
+
- omniauth-centralid.gemspec
|
42
107
|
homepage: http://github.com/yafoy/omniauth-centralid
|
43
108
|
licenses:
|
44
109
|
- MIT
|
45
110
|
metadata: {}
|
46
|
-
post_install_message:
|
111
|
+
post_install_message:
|
47
112
|
rdoc_options: []
|
48
113
|
require_paths:
|
49
114
|
- lib
|
@@ -58,11 +123,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
58
123
|
- !ruby/object:Gem::Version
|
59
124
|
version: '0'
|
60
125
|
requirements: []
|
61
|
-
|
62
|
-
|
63
|
-
signing_key:
|
126
|
+
rubygems_version: 3.3.7
|
127
|
+
signing_key:
|
64
128
|
specification_version: 4
|
65
129
|
summary: Central ID stategy for OmniAuth
|
66
|
-
test_files:
|
67
|
-
- test/omniauth_centralid_test.rb
|
68
|
-
- test/test_helper.rb
|
130
|
+
test_files: []
|
@@ -1,28 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class OmniauthCentralidTest < Minitest::Test
|
4
|
-
def test_module_is_declared
|
5
|
-
assert_kind_of Module, OmniauthCentralid
|
6
|
-
end
|
7
|
-
|
8
|
-
def test_version_is_defined
|
9
|
-
refute_nil OmniauthCentralid::VERSION
|
10
|
-
end
|
11
|
-
|
12
|
-
def test_name_is_centralid
|
13
|
-
assert name, 'centralid'
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_site_url_is_defined
|
17
|
-
assert :site, 'https://centralid.herokuapp.com'
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_fields_are_defined
|
21
|
-
assert :fields, [:name, :email]
|
22
|
-
end
|
23
|
-
|
24
|
-
def test_authorization_initialization
|
25
|
-
# get "/auth/centralid"
|
26
|
-
# assert_equal 302, last_response.status
|
27
|
-
end
|
28
|
-
end
|
data/test/test_helper.rb
DELETED