omniauth-clever 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.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +68 -0
- data/Rakefile +1 -0
- data/lib/omniauth-clever.rb +1 -0
- data/lib/omniauth/clever.rb +2 -0
- data/lib/omniauth/clever/version.rb +5 -0
- data/lib/omniauth/strategies/clever.rb +51 -0
- data/omniauth-clever.gemspec +22 -0
- metadata +73 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Think Through Math
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
# OmniAuth Clever
|
2
|
+
|
3
|
+
Unofficial OmniAuth strategy for [Clever SSO OAuth2](https://getclever.com/developers/docs/oauth) integration.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add the gem to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'omniauth-clever', '~> 1.0.0'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
## Usage
|
16
|
+
|
17
|
+
OmniAuth Clever is Rack Middleware in the OmniAuth convention. See the
|
18
|
+
[OmniAuth 1.0 docs](https://github.com/intridea/omniauth) for more information.
|
19
|
+
|
20
|
+
Follow the Clever OAuth docs to register your application, set callback URLs,
|
21
|
+
and get a client ID and client secret.
|
22
|
+
|
23
|
+
Example: In `config/initializers/omniauth.rb`, do:
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
27
|
+
provider :clever, ENV['CLEVER_CLIENT_ID'], ENV['CLEVER_CLIENT_SECRET']
|
28
|
+
end
|
29
|
+
```
|
30
|
+
|
31
|
+
## Configuring
|
32
|
+
|
33
|
+
To be able to set the optional `clever_landing` or `dev` parameters on a
|
34
|
+
per-request basis by passing these params to your `/auth/clever` url, use
|
35
|
+
this in the initializer instead:
|
36
|
+
|
37
|
+
```ruby
|
38
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
39
|
+
provider :clever, ENV['CLEVER_CLIENT_ID'], ENV['CLEVER_CLIENT_SECRET'],
|
40
|
+
:setup => lambda { |env|
|
41
|
+
params = Rack::Utils.parse_query(env['QUERY_STRING'])
|
42
|
+
env['omniauth.strategy'].options[:client_options][:clever_landing] = params['clever_landing']
|
43
|
+
env['omniauth.strategy'].options[:client_options][:dev] = params['dev']
|
44
|
+
}
|
45
|
+
end
|
46
|
+
```
|
47
|
+
|
48
|
+
## Contributing
|
49
|
+
|
50
|
+
1. Fork it
|
51
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
52
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
53
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
54
|
+
5. Create new Pull Request
|
55
|
+
|
56
|
+
## License
|
57
|
+
|
58
|
+
MIT. See LICENSE.txt.
|
59
|
+
|
60
|
+
## Thank yous
|
61
|
+
|
62
|
+
Thank you to the [Clever](https://github.com/Clever/) team for their awesome
|
63
|
+
product and always being helpful with any issues. Thank you to [Think Through
|
64
|
+
Math](https://github.com/thinkthroughmath) for dedicating time for the tech
|
65
|
+
team to make open source contributions such as this.
|
66
|
+
|
67
|
+
And, of course. thank you to [Omniauth](https://github.com/intridea/omniauth)
|
68
|
+
for making it so easy create this gem!
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1 @@
|
|
1
|
+
require "omniauth/clever"
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'omniauth-oauth2'
|
2
|
+
require 'base64'
|
3
|
+
|
4
|
+
module OmniAuth
|
5
|
+
module Strategies
|
6
|
+
class Clever < OmniAuth::Strategies::OAuth2
|
7
|
+
option :name, "clever"
|
8
|
+
|
9
|
+
option :client_options, {
|
10
|
+
:site => 'https://api.getclever.com',
|
11
|
+
:authorize_url => 'https://account.getclever.com/oauth/authorize',
|
12
|
+
:token_url => 'https://api.getclever.com/oauth/token'
|
13
|
+
}
|
14
|
+
|
15
|
+
def authorize_params
|
16
|
+
super.tap do |params|
|
17
|
+
params[:scope] = 'read_only'
|
18
|
+
params[:clever_landing] = options.client_options.clever_landing || 'admin'
|
19
|
+
if options.client_options.dev
|
20
|
+
params[:dev] = options.client_options.dev
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def token_params
|
26
|
+
username_password = options.client_secret + ":"
|
27
|
+
super.tap do |params|
|
28
|
+
params[:headers] = {'Authorization' => "Basic #{Base64.encode64(username_password)}"}
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
uid{ raw_info['data']['id'] }
|
35
|
+
|
36
|
+
info do
|
37
|
+
{ :user_type => raw_info['type'] }.merge! raw_info['data']
|
38
|
+
end
|
39
|
+
|
40
|
+
extra do
|
41
|
+
{
|
42
|
+
'raw_info' => raw_info
|
43
|
+
}
|
44
|
+
end
|
45
|
+
|
46
|
+
def raw_info
|
47
|
+
@raw_info ||= access_token.get('/me').parsed
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'omniauth/clever/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "omniauth-clever"
|
8
|
+
gem.version = Omniauth::Clever::VERSION
|
9
|
+
gem.authors = ["Carol Nichols"]
|
10
|
+
gem.email = ["cnichols@thinkthroughmath.com"]
|
11
|
+
gem.description = %q{Unofficial OmniAuth strategy for getclever.com SSO OAuth2 integration}
|
12
|
+
gem.summary = %q{The unofficial strategy for authenticating people using getclever.com to your application using Clever's OAuth2 provider}
|
13
|
+
gem.homepage = "https://github.com/thinkthroughmath/omniauth-clever"
|
14
|
+
gem.license = 'MIT'
|
15
|
+
|
16
|
+
gem.files = `git ls-files`.split($/)
|
17
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
18
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
19
|
+
gem.require_paths = ["lib"]
|
20
|
+
|
21
|
+
gem.add_runtime_dependency 'omniauth-oauth2', '~> 1.1.1'
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-clever
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Carol Nichols
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-07-30 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: omniauth-oauth2
|
16
|
+
prerelease: false
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 1.1.1
|
22
|
+
none: false
|
23
|
+
type: :runtime
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - ~>
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: 1.1.1
|
29
|
+
none: false
|
30
|
+
description: Unofficial OmniAuth strategy for getclever.com SSO OAuth2 integration
|
31
|
+
email:
|
32
|
+
- cnichols@thinkthroughmath.com
|
33
|
+
executables: []
|
34
|
+
extensions: []
|
35
|
+
extra_rdoc_files: []
|
36
|
+
files:
|
37
|
+
- .gitignore
|
38
|
+
- Gemfile
|
39
|
+
- LICENSE.txt
|
40
|
+
- README.md
|
41
|
+
- Rakefile
|
42
|
+
- lib/omniauth-clever.rb
|
43
|
+
- lib/omniauth/clever.rb
|
44
|
+
- lib/omniauth/clever/version.rb
|
45
|
+
- lib/omniauth/strategies/clever.rb
|
46
|
+
- omniauth-clever.gemspec
|
47
|
+
homepage: https://github.com/thinkthroughmath/omniauth-clever
|
48
|
+
licenses:
|
49
|
+
- MIT
|
50
|
+
post_install_message:
|
51
|
+
rdoc_options: []
|
52
|
+
require_paths:
|
53
|
+
- lib
|
54
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - ! '>='
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: '0'
|
59
|
+
none: false
|
60
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - ! '>='
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '0'
|
65
|
+
none: false
|
66
|
+
requirements: []
|
67
|
+
rubyforge_project:
|
68
|
+
rubygems_version: 1.8.24
|
69
|
+
signing_key:
|
70
|
+
specification_version: 3
|
71
|
+
summary: The unofficial strategy for authenticating people using getclever.com to
|
72
|
+
your application using Clever's OAuth2 provider
|
73
|
+
test_files: []
|