omniauth-universe 0.0.6
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/LICENSE.md +21 -0
- data/README.md +61 -0
- data/lib/omniauth/strategies/universe.rb +80 -0
- data/lib/omniauth/universe/version.rb +5 -0
- data/lib/omniauth/universe.rb +2 -0
- data/lib/omniauth-universe.rb +1 -0
- data/omniauth-universe.gemspec +22 -0
- metadata +80 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 96300583930f09a58b6eed6cbdf85af5f9da36f2
|
4
|
+
data.tar.gz: 882bbc8eb6df65e92d4d3926b657c87352b81080
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ec588472ae18b80008306c6ce8784317b7cc1914f16330c0128b090935cc09ad24d177774e547b2b944b9e7fd33bccd706680f3af7930fa9c5a7cd81deb904b7
|
7
|
+
data.tar.gz: 3161db9e76050335458d9d11671bf1af25031f9d9b681412973a0323a574ae539c3a485903967a49f7babe5d9c1fde8705f4ef2d5db327e4a26022733a956ecd
|
data/LICENSE.md
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 John-Alan Simmons <simmons.johnalan@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
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
# OmniAuth Universe
|
2
|
+
|
3
|
+
This gem contains the Universe strategy for OmniAuth 2.0.
|
4
|
+
|
5
|
+
## Installing
|
6
|
+
|
7
|
+
Add to your `Gemfile`:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'omniauth-universe', '~> 0.0.6'
|
11
|
+
```
|
12
|
+
|
13
|
+
Then `bundle install`.
|
14
|
+
|
15
|
+
## Basic Usage
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
use OmniAuth::Builder do
|
19
|
+
provider :universe, ENV['UNIVERSE_CLIENT_ID'], ENV['UNIVERSE_CLIENT_SECRET']
|
20
|
+
end
|
21
|
+
```
|
22
|
+
|
23
|
+
Currently Universe Oauth2 authorization is in beta and must be activated by contacting support@universe.com.
|
24
|
+
|
25
|
+
## Versioning
|
26
|
+
|
27
|
+
This library aims to adhere to [Semantic Versioning 2.0.0][semver]. Violations
|
28
|
+
of this scheme should be reported as bugs.
|
29
|
+
|
30
|
+
[semver]: http://semver.org/spec/v2.0.0.html
|
31
|
+
|
32
|
+
## Contributors
|
33
|
+
|
34
|
+
- John-Alan Simmons ([jsimnz](https://github.com/jsimnz), [@iamjsimnz](https://twitter.com/iamjsimnz))
|
35
|
+
|
36
|
+
Special thanks to [Kruttik Aggarwal](https://github.com/k504866430) for the original codebase that was forked from [omniauth-eventbrite](https://github.com/k504866430/omniauth-eventbrite)
|
37
|
+
|
38
|
+
## License
|
39
|
+
|
40
|
+
The MIT License (MIT)
|
41
|
+
|
42
|
+
Copyright (c) 2016 John-Alan Simmons <simmons.johnalan@gmail.com>
|
43
|
+
|
44
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
45
|
+
of this software and associated documentation files (the "Software"), to deal
|
46
|
+
in the Software without restriction, including without limitation the rights
|
47
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
48
|
+
copies of the Software, and to permit persons to whom the Software is
|
49
|
+
furnished to do so, subject to the following conditions:
|
50
|
+
|
51
|
+
The above copyright notice and this permission notice shall be included in
|
52
|
+
all copies or substantial portions of the Software.
|
53
|
+
|
54
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
55
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
56
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
57
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
58
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
59
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
60
|
+
THE SOFTWARE.
|
61
|
+
|
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'omniauth/strategies/oauth2'
|
2
|
+
|
3
|
+
module OmniAuth
|
4
|
+
module Strategies
|
5
|
+
class Universe < OmniAuth::Strategies::OAuth2
|
6
|
+
DEFAULT_RESPONSE_TYPE = 'code'
|
7
|
+
DEFAULT_GRANT = 'authorization_code'
|
8
|
+
INFO_URL = 'https://universe.com/api/v2/current_user'.freeze
|
9
|
+
|
10
|
+
option :name, 'universe'
|
11
|
+
|
12
|
+
# The list of optional values that can be sent with authorize
|
13
|
+
#
|
14
|
+
# @note :ref is a referral code for the Referral Program.
|
15
|
+
# option :authorize_options, [:ref]
|
16
|
+
option :client_options, site: 'https://universe.com',
|
17
|
+
authorize_url: '/oauth/authorize',
|
18
|
+
token_url: '/oauth/token'
|
19
|
+
|
20
|
+
uid { raw_info['id'].to_s }
|
21
|
+
|
22
|
+
info do
|
23
|
+
prune!('email' => raw_info['email'],
|
24
|
+
'name' => raw_info['name'],
|
25
|
+
'first_name' => raw_info['first_name'],
|
26
|
+
'last_name' => raw_info['last_name'])
|
27
|
+
end
|
28
|
+
|
29
|
+
extra do
|
30
|
+
prune!('raw_info' => raw_info)
|
31
|
+
end
|
32
|
+
|
33
|
+
# The OAuth2 client authorization parameters.
|
34
|
+
#
|
35
|
+
# @return [OmniAuth::Strategy::Options]
|
36
|
+
def authorize_params
|
37
|
+
super.tap do |params|
|
38
|
+
params[:response_type] ||= DEFAULT_RESPONSE_TYPE
|
39
|
+
params[:client_id] = client.id
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# Unfiltered data about the authenticating user.
|
44
|
+
#
|
45
|
+
# @return [Hash]
|
46
|
+
def raw_info
|
47
|
+
@raw_info ||= access_token.get(INFO_URL).parsed['current_user'] || {}
|
48
|
+
end
|
49
|
+
|
50
|
+
# The OAuth2 client authentication parameters.
|
51
|
+
#
|
52
|
+
# @return [OmniAuth::Strategy::Options]
|
53
|
+
def token_params
|
54
|
+
super.tap do |params|
|
55
|
+
params[:grant_type] ||= DEFAULT_GRANT
|
56
|
+
params[:client_id] = client.id
|
57
|
+
params[:client_secret] = client.secret
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
private
|
62
|
+
|
63
|
+
def full_name
|
64
|
+
first_name = raw_info['first_name'] || ''
|
65
|
+
last_name = raw_info['last_name'] || ''
|
66
|
+
|
67
|
+
"#{first_name} #{last_name}".strip || nil
|
68
|
+
end
|
69
|
+
|
70
|
+
def prune!(hash)
|
71
|
+
hash.delete_if do |_, value|
|
72
|
+
prune!(value) if value.is_a?(Hash)
|
73
|
+
value.nil? || (value.respond_to?(:empty?) && value.empty?)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
OmniAuth.config.add_camelization 'universe', 'Universe'
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'omniauth/universe'
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'omniauth/universe/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'omniauth-universe'
|
8
|
+
spec.version = Omniauth::Universe::VERSION
|
9
|
+
spec.authors = ['John-Alan Simmons']
|
10
|
+
spec.email = ['simmons.johnalan@gmail.com']
|
11
|
+
spec.homepage = 'https://github.com/conferencecloud/omniauth-universe'
|
12
|
+
spec.summary = 'Universe OAuth2 strategy for OmniAuth'
|
13
|
+
spec.description = spec.summary
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = %w(LICENSE.md README.md
|
17
|
+
omniauth-universe.gemspec) + Dir['lib/**/*.rb']
|
18
|
+
spec.require_paths = ['lib']
|
19
|
+
|
20
|
+
spec.add_dependency 'omniauth-oauth2', '~> 1.0'
|
21
|
+
spec.add_development_dependency 'bundler', '~> 1.0'
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-universe
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.6
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- John-Alan Simmons
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-05-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: omniauth-oauth2
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.0'
|
41
|
+
description: Universe OAuth2 strategy for OmniAuth
|
42
|
+
email:
|
43
|
+
- simmons.johnalan@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- LICENSE.md
|
49
|
+
- README.md
|
50
|
+
- lib/omniauth-universe.rb
|
51
|
+
- lib/omniauth/strategies/universe.rb
|
52
|
+
- lib/omniauth/universe.rb
|
53
|
+
- lib/omniauth/universe/version.rb
|
54
|
+
- omniauth-universe.gemspec
|
55
|
+
homepage: https://github.com/conferencecloud/omniauth-universe
|
56
|
+
licenses:
|
57
|
+
- MIT
|
58
|
+
metadata: {}
|
59
|
+
post_install_message:
|
60
|
+
rdoc_options: []
|
61
|
+
require_paths:
|
62
|
+
- lib
|
63
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
requirements: []
|
74
|
+
rubyforge_project:
|
75
|
+
rubygems_version: 2.4.5
|
76
|
+
signing_key:
|
77
|
+
specification_version: 4
|
78
|
+
summary: Universe OAuth2 strategy for OmniAuth
|
79
|
+
test_files: []
|
80
|
+
has_rdoc:
|