omniauth-plangrade 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 971880782792ea5433e4db1bfcfcdd68d3f7170a
4
- data.tar.gz: e789c6fb47d311e080408688983b71c52a372e4d
3
+ metadata.gz: 3d523a80b7f14c752d07284bff285f756588fe17
4
+ data.tar.gz: b22c3073713a4410dab81e8b18b5a7f1dfdfc085
5
5
  SHA512:
6
- metadata.gz: 17ca6edfc3661c0e51462484576b02ea187fd4b8c22ecc0c084332abc386dca09180f5f4911e29ff4d6767462361d6a5180810feed4332b6e159d6865dc8ff51
7
- data.tar.gz: ab04a76030ed98e42e4848b27c8402d10d921bad0529f02a265f174daea1bd4b5617c8fce79cee65a09d0d50820e73b98cd5f4f899cbe98ce724ca4c861583c6
6
+ metadata.gz: ab52cc22f976648fedc20d209799ac578c7c8306d7ebbe5488f8a653cf2369469694beb591978eaa832fc233536c1d398ff540968da6817888865428d69f3fac
7
+ data.tar.gz: ea400ef43125b12f0c973ec2af46bf746d372128f207349e770ba964cd5927c7ffe8084c99d7821fec92e8a75ef4bc0b120118ecbcb5f0480651b7f6b5b45354
data/.gitignore CHANGED
@@ -20,3 +20,4 @@ tmp
20
20
  *.o
21
21
  *.a
22
22
  mkmf.log
23
+ pkg/*
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --colour
data/.travis.yml ADDED
@@ -0,0 +1,13 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
5
+ - 2.1.0
6
+ - jruby
7
+
8
+ notifications:
9
+ email:
10
+ recipients:
11
+ - topherreynoso@gmail.com
12
+ on_failure: change
13
+ on_success: never
data/Gemfile CHANGED
@@ -1,7 +1,6 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
- # Specify your gem's dependencies in omniauth-plangrade.gemspec
4
- gemspec
3
+ gem 'rake'
5
4
 
6
- gem 'oauth2'
7
- gem 'omniauth-oauth2'
5
+ # Specify your gem's dependencies in omniauth-twitter.gemspec
6
+ gemspec
data/README.md CHANGED
@@ -1,31 +1,85 @@
1
- # Omniauth::Plangrade
1
+ # OmniAuth plangrade
2
+ [![Gem Version](https://badge.fury.io/rb/omniauth-plangrade.svg)](http://badge.fury.io/rb/omniauth-plangrade)
3
+ [![Code Climate](https://codeclimate.com/github/topherreynoso/omniauth-plangrade/badges/gpa.svg)](https://codeclimate.com/github/topherreynoso/omniauth-plangrade)
2
4
 
3
- Omniauth Strategy for plangrade. Find out more about the plangrade API at docs.plangrade.com
5
+ plangrade OAuth2 strategy for OmniAuth.
6
+ Supports the OAuth 2.0 server-side and client-side flows. Read the plangrade docs for more details: [docs.plangrade.com](https://docs.plangrade.com/#authentication). Additionally, this may be used in conjunction with [plangrade-ruby](https://github.com/topherreynoso/plangrade-ruby) in order to refresh tokens and access plangrade API endpoints.
4
7
 
5
- ## Installation
8
+ ## Installing
6
9
 
7
10
  Add omniauth-oauth2 and this line to your application's Gemfile:
8
11
 
9
- gem 'omniauth-plangrade', git: 'https://github.com/topherreynoso/omniauth-plangrade'
12
+ gem 'omniauth-plangrade'
10
13
 
11
- And then execute:
14
+ Then execute:
12
15
 
13
16
  $ bundle install
14
17
 
15
18
  ## Usage
16
19
 
17
- You need to add the following to your `config/initializers/omniauth.rb`:
20
+ `OmniAuth::Strategies::Plangrade` is simply a Rack middleware. Read the OmniAuth docs for detailed instructions: [https://github.com/intridea/omniauth](https://github.com/intridea/omniauth).
21
+
22
+ Here's a quick example, adding the middleware to a Rails app in `config/initializers/omniauth.rb`:
18
23
 
19
24
  ```ruby
20
25
  Rails.application.config.middleware.use OmniAuth::Builder do
21
- provider :plangrade, "your_key", "your_secret", redirect_uri: "redirect_uri"
26
+ provider :plangrade, ENV['PLANGRADE_CLIENT_ID'], ENV['PLANGRADE_CLIENT_SECRET']
22
27
  end
23
28
  ```
24
29
 
25
- ## Contributing
30
+ [See the example rails app for full examples](https://github.com/topherreynoso/plangrade-ruby-client) of both the server and client-side flows.
31
+
32
+ ## Auth Hash
33
+
34
+ Here's an example *Auth Hash* available in `request.env['omniauth.auth']`:
35
+
36
+ ```ruby
37
+ {
38
+ :provider => 'plangrade',
39
+ :uid => '1234567',
40
+ :info => {
41
+ :name => 'Compliance Man',
42
+ :email => 'compliance@plangrade.com',
43
+ },
44
+ :credentials => {
45
+ :token => 'ABCDEF...', # OAuth 2.0 access_token, which you may wish to store
46
+ :refresh_token => 'ABCDEF...', #OAuth 2.0 refresh_token, which you may wish to store
47
+ :expires_at => 1321747205, # when the access token expires (it always will)
48
+ :expires => true # this will always be true
49
+ },
50
+ :extra => {
51
+ :raw_info => {
52
+ :id => '1234567',
53
+ :name => 'Compliance Man',
54
+ :email => 'compliance@plangrade.com',
55
+ }
56
+ }
57
+ }
58
+ ```
59
+
60
+ ### How it Works
61
+
62
+ The client-side flow is supported by parsing the authorization code from the signed request which plangrade places in a cookie.
63
+
64
+ When you call `/auth/plangrade/callback`, the success callback will pass the cookie back to the server. omniauth-plangrade will see this cookie and:
65
+
66
+ 1. parse it,
67
+ 2. extract the authorization code contained in it,
68
+ 3. and hit plangrade and obtain an access token which will get placed in the `request.env['omniauth.auth']['credentials']` hash.
69
+
70
+ ## Token Expiry
71
+
72
+ The expiration time of the access token you obtain is 2 hours.
73
+ The refresh_token, however, has no expiration and may be used until a user revokes your app's access.
74
+
75
+ ## License
76
+
77
+ Copyright (c) 2014 Christopher Reynoso
78
+
79
+ MIT License
80
+
81
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
82
+
83
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
26
84
 
27
- 1. Fork it
28
- 2. Create your feature branch (`git checkout -b my-new-feature`)
29
- 3. Commit your changes (`git commit -am 'Add some feature'`)
30
- 4. Push to the branch (`git push origin my-new-feature`)
31
- 5. Create new Pull Request
85
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile CHANGED
@@ -1,2 +1,8 @@
1
1
  require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
2
3
 
4
+ desc "Run specs"
5
+ RSpec::Core::RakeTask.new
6
+
7
+ desc 'Default: run specs.'
8
+ task :default => :spec
@@ -1,5 +1,5 @@
1
1
  module Omniauth
2
2
  module Plangrade
3
- VERSION = "0.0.1"
3
+ VERSION = "0.1.0"
4
4
  end
5
5
  end
@@ -18,6 +18,12 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_development_dependency "bundler", "~> 1.6"
22
- spec.add_development_dependency "rake"
21
+ spec.add_dependency 'multi_json', '~> 1.3'
22
+ spec.add_runtime_dependency 'oauth2'
23
+ spec.add_runtime_dependency 'omniauth'
24
+ spec.add_runtime_dependency 'omniauth-oauth2'
25
+ spec.add_development_dependency 'rspec', '~> 2.7'
26
+ spec.add_development_dependency 'rack-test'
27
+ spec.add_development_dependency 'simplecov'
28
+ spec.add_development_dependency 'webmock'
23
29
  end
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+
3
+ describe OmniAuth::Strategies::Plangrade do
4
+ let(:request) { double('Request', :params => {}, :cookies => {}, :env => {}) }
5
+
6
+ subject do
7
+ args = ['appid', 'secret', @options || {}].compact
8
+ OmniAuth::Strategies::Plangrade.new(*args).tap do |strategy|
9
+ allow(strategy).to receive(:request) {
10
+ request
11
+ }
12
+ end
13
+ end
14
+
15
+ describe 'client options' do
16
+ it 'should have correct name' do
17
+ expect(subject.options.name).to eq(:plangrade)
18
+ end
19
+
20
+ it 'should have correct site' do
21
+ expect(subject.options.client_options.site).to eq('https://plangrade.com')
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,20 @@
1
+ $:.unshift File.expand_path('..', __FILE__)
2
+ $:.unshift File.expand_path('../../lib', __FILE__)
3
+ require 'simplecov'
4
+ SimpleCov.start
5
+ require 'rspec'
6
+ require 'rack/test'
7
+ require 'webmock/rspec'
8
+ require 'oauth2'
9
+ require 'omniauth'
10
+ require 'omniauth-oauth2'
11
+ require 'omniauth/plangrade'
12
+
13
+ RSpec.configure do |config|
14
+ config.include WebMock::API
15
+ config.include Rack::Test::Methods
16
+ config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
17
+ config.expect_with :rspec do |c|
18
+ c.syntax = :expect
19
+ end
20
+ end
metadata CHANGED
@@ -1,31 +1,115 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-plangrade
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christopher Reynoso
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-09 00:00:00.000000000 Z
11
+ date: 2014-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: bundler
14
+ name: multi_json
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.6'
19
+ version: '1.3'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: 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: omniauth
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: omniauth-oauth2
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '2.7'
20
76
  type: :development
21
77
  prerelease: false
22
78
  version_requirements: !ruby/object:Gem::Requirement
23
79
  requirements:
24
80
  - - "~>"
25
81
  - !ruby/object:Gem::Version
26
- version: '1.6'
82
+ version: '2.7'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rack-test
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: simplecov
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'
27
111
  - !ruby/object:Gem::Dependency
28
- name: rake
112
+ name: webmock
29
113
  requirement: !ruby/object:Gem::Requirement
30
114
  requirements:
31
115
  - - ">="
@@ -47,6 +131,8 @@ extensions: []
47
131
  extra_rdoc_files: []
48
132
  files:
49
133
  - ".gitignore"
134
+ - ".rspec"
135
+ - ".travis.yml"
50
136
  - Gemfile
51
137
  - LICENSE.txt
52
138
  - README.md
@@ -55,6 +141,8 @@ files:
55
141
  - lib/omniauth/plangrade/version.rb
56
142
  - lib/omniauth/strategies/plangrade.rb
57
143
  - omniauth-plangrade.gemspec
144
+ - spec/omniauth/strategies/plangrade_spec.rb
145
+ - spec/spec_helper.rb
58
146
  homepage: https://github.com/topherreynoso/omniauth-plangrade
59
147
  licenses:
60
148
  - MIT
@@ -79,4 +167,6 @@ rubygems_version: 2.2.2
79
167
  signing_key:
80
168
  specification_version: 4
81
169
  summary: Omniauth Strategy for plangrade
82
- test_files: []
170
+ test_files:
171
+ - spec/omniauth/strategies/plangrade_spec.rb
172
+ - spec/spec_helper.rb