omniauth-whiplash 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6ddcdbdf5c216dcde0d9cd8e1fccf00de859be9f
4
+ data.tar.gz: 64d0771c33f7dadb3b68d6be36785596f599cb1a
5
+ SHA512:
6
+ metadata.gz: 0fcc782373d6bd909a506e682c7a8c85f52136c78b2d2bff17e81f08c373327afc531000e1e036ba85f0b816718ec9102952eb7be9b916bdd6bd13bfdcdede55
7
+ data.tar.gz: d0559dbccbf836fedcdd4e987aa30378643674e4b5c1612c3fc43a07c9029692ab63f2c019a1e1e9864cf240b4215e718cc25f9481e5fb1454af210e24884af5
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.3
4
+ before_install: gem install bundler -v 1.10.6
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in omniauth-whiplash.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Nikhil Gupta
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,63 @@
1
+ # Omniauth::Whiplash
2
+
3
+ Whiplash OAuth2 Strategy for OmniAuth 1.0.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'omniauth-whiplash'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install omniauth-whiplash
20
+
21
+ ## Usage
22
+
23
+ `OmniAuth::Strategies::Whiplash` is simply a Rack middleware. Read the OmniAuth 1.0 docs for detailed instructions.
24
+
25
+ Here's a quick example, adding the middleware to a Rails app in config/initializers/omniauth.rb:
26
+
27
+ ```ruby
28
+ Rails.application.config.middleware.use OmniAuth::Builder do
29
+ provider :whiplash, ENV['WHILASH_CLIENT_ID'], ENV['WHIPLASH_CLIENT_SECRET']
30
+ end
31
+ ```
32
+
33
+ ## Configuration
34
+
35
+ You can configure the scope, which you pass in to the provider method via a Hash:
36
+
37
+ `scope`: A comma-separated list of permissions you want to request from the user. See the Shopify API docs for a full list of available permissions.
38
+ For example, to request read_products, read_orders and write_content permissions and display the authentication page:
39
+
40
+ ```ruby
41
+ Rails.application.config.middleware.use OmniAuth::Builder do
42
+ provider :whiplash, ENV['WHILASH_CLIENT_ID'], ENV['WHIPLASH_CLIENT_SECRET'], scope: 'read_orders write_orders read_items write_items read_web_hooks write_web_hooks read_customers read_user'
43
+ end
44
+ ```
45
+
46
+ NOTE: The default scope is `read_user` and is required as part of the `scope` argument, if it's passed in.
47
+
48
+ ALSO: The scope arguments should be passed in *separated by spaces, not commas*, as per above.
49
+
50
+ ## Development
51
+
52
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. Run `bundle exec omniauth-whiplash` to use the gem in this directory, ignoring other installed copies of this gem.
53
+
54
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
55
+
56
+ ## Contributing
57
+
58
+ Bug reports and pull requests are welcome on GitHub at https://github.com/whiplashmerch/omniauth-whiplash.
59
+
60
+
61
+ ## License
62
+
63
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "omniauth/whiplash"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "omniauth/whiplash"
@@ -0,0 +1,46 @@
1
+ module OmniAuth
2
+ module Strategies
3
+ class Whiplash < OmniAuth::Strategies::OAuth2
4
+ option :name, :whiplash
5
+
6
+ option :client_options, {
7
+ site: "https://www.whiplashmerch.com",
8
+ authorize_url: "oauth/authorize",
9
+ request_token_url: "oauth/authorize",
10
+ access_token_url: "oauth/token"
11
+ }
12
+
13
+ uid { raw_info["id"] }
14
+
15
+ info do
16
+ { email: raw_info["email"], name: user_full_name }
17
+ end
18
+
19
+ extra do
20
+ { raw_info: raw_info }
21
+ end
22
+
23
+ def callback_url
24
+ options[:callback_url] || super
25
+ end
26
+
27
+ def user_full_name
28
+ "#{raw_info['first_name']} #{raw_info['last_name']}".strip
29
+ end
30
+
31
+ def raw_info
32
+ @raw_info ||= access_token.get('/api/v2/me.json').parsed
33
+ end
34
+
35
+ def authorize_params
36
+ super.tap do |params|
37
+ %w[scope client_options].each do |v|
38
+ if request.params[v]
39
+ params[v.to_sym] = request.params[v]
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,5 @@
1
+ module Omniauth
2
+ module Whiplash
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ require "omniauth-oauth2"
2
+ require "omniauth/whiplash/version"
3
+ require "omniauth/strategies/whiplash"
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'omniauth/whiplash/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "omniauth-whiplash"
8
+ spec.version = Omniauth::Whiplash::VERSION
9
+ spec.authors = ["Mark Dickson", "Nikhil Gupta"]
10
+ spec.email = ["mark@whiplashmerch.com", "me@nikhgupta.com"]
11
+
12
+ spec.summary = %q{Omniauth Strategy for Whiplash Merchandising}
13
+ spec.description = %q{Omniauth Strategy for Whiplash Merchandising}
14
+ spec.homepage = "https://github.com/ideaoforder/omniauth-whiplash"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.10"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency "rspec"
25
+
26
+ spec.add_dependency 'omniauth', '~> 1.0'
27
+ spec.add_dependency 'omniauth-oauth2', '~> 1.3.1'
28
+ end
metadata ADDED
@@ -0,0 +1,132 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-whiplash
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Mark Dickson
8
+ - Nikhil Gupta
9
+ autorequire:
10
+ bindir: exe
11
+ cert_chain: []
12
+ date: 2016-04-25 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '1.10'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '1.10'
28
+ - !ruby/object:Gem::Dependency
29
+ name: rake
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '10.0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '10.0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: rspec
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: omniauth
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: '1.0'
63
+ type: :runtime
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '1.0'
70
+ - !ruby/object:Gem::Dependency
71
+ name: omniauth-oauth2
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - "~>"
75
+ - !ruby/object:Gem::Version
76
+ version: 1.3.1
77
+ type: :runtime
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - "~>"
82
+ - !ruby/object:Gem::Version
83
+ version: 1.3.1
84
+ description: Omniauth Strategy for Whiplash Merchandising
85
+ email:
86
+ - mark@whiplashmerch.com
87
+ - me@nikhgupta.com
88
+ executables:
89
+ - omniauth-whiplash
90
+ extensions: []
91
+ extra_rdoc_files: []
92
+ files:
93
+ - ".gitignore"
94
+ - ".rspec"
95
+ - ".travis.yml"
96
+ - Gemfile
97
+ - LICENSE.txt
98
+ - README.md
99
+ - Rakefile
100
+ - bin/console
101
+ - bin/setup
102
+ - exe/omniauth-whiplash
103
+ - lib/omniauth/strategies/whiplash.rb
104
+ - lib/omniauth/whiplash.rb
105
+ - lib/omniauth/whiplash/version.rb
106
+ - omniauth-whiplash.gemspec
107
+ homepage: https://github.com/ideaoforder/omniauth-whiplash
108
+ licenses:
109
+ - MIT
110
+ metadata: {}
111
+ post_install_message:
112
+ rdoc_options: []
113
+ require_paths:
114
+ - lib
115
+ required_ruby_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ required_rubygems_version: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ requirements: []
126
+ rubyforge_project:
127
+ rubygems_version: 2.4.5.1
128
+ signing_key:
129
+ specification_version: 4
130
+ summary: Omniauth Strategy for Whiplash Merchandising
131
+ test_files: []
132
+ has_rdoc: