omniauth-bike-index 1.0.0 → 1.0.5

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
- SHA1:
3
- metadata.gz: f1c9a5e41e30b52036f65770a0890439ad29b4fe
4
- data.tar.gz: 0e557a7f410e21be8f3cabea92ac204acfa3737b
2
+ SHA256:
3
+ metadata.gz: 01d745f15c082b6b8906b5643f130d20f39bbc66b7425b563a2b12b3f85f17d1
4
+ data.tar.gz: 39c97a47c2950793af76588ad1697b49ae653fdd08714198162a7f97b4e8f6a2
5
5
  SHA512:
6
- metadata.gz: e83173b9ff0486ff302aef7069ef7314658e1dd94b2c7ca24954eb25ad5ca01d84d84813abc0c9f042bca123fccc80266b81b8c537a477ed1f53b68dea13400d
7
- data.tar.gz: 0fa877dfc49dee02e22b4fa77b4d55c1c9b6c70d3c7d71125628d6fc8cc97118f5ce6b76e5aeaa5f1f00fad96f4e6aa0522b78ae058789214f5b77f558af4964
6
+ metadata.gz: 6dfcab4f77621d617a78870bd923379fdc2f311b33dab85549f8fc8df08668876d1d9d78671fbc4f2aeb4a42b52774e0826788a54acbca66b08630ea1d165b37
7
+ data.tar.gz: 4b53ab68270c7c2634bafecedc156314cc1023036e44e83a94b578f49a87eda4393ca15464983bd6490b251665a8d6128023fcc0be2324963ebb583a6ffc1608
data/.gitignore CHANGED
@@ -19,4 +19,7 @@ tmp
19
19
  .rspec
20
20
  .ruby-*
21
21
 
22
+ # ASDF ruby versions
23
+ .tool-versions
24
+
22
25
  info.markdown
data/.travis.yml CHANGED
@@ -3,11 +3,11 @@ gemfile:
3
3
  - Gemfile
4
4
  language: ruby
5
5
  before_install:
6
- - gem install bundler
6
+ - gem install bundler
7
7
  - gem update bundler
8
8
  rvm:
9
- - 2.2.4
10
9
  - 2.3.0
10
+ - 2.5.8
11
11
  - jruby-head
12
12
  matrix:
13
13
  allow_failures:
data/Gemfile CHANGED
@@ -1,9 +1,10 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
- gem 'rake'
3
+ gem "rake"
4
4
 
5
5
  group :test do
6
- gem 'rspec'
6
+ gem "standard"
7
+ gem "rspec"
7
8
  end
8
9
 
9
10
  gemspec
data/README.md CHANGED
@@ -1,11 +1,9 @@
1
1
  # OmniAuth::BikeIndex [![Build Status](https://travis-ci.org/bikeindex/omniauth-bike-index.svg?branch=master)](https://travis-ci.org/bikeindex/omniauth-bike-index)
2
- ==============
3
2
 
4
3
  Bike Index OAuth2 Strategy for OmniAuth 1.0.
5
4
 
6
5
  Supports the OAuth 2.0 server-side and client-side flows.
7
6
 
8
-
9
7
  ## Creating an application
10
8
 
11
9
  To be able to use OAuth on the Bike Index, you have to create an application. Go to [BikeIndex.org/oauth/applications](https://bikeindex.org/oauth/applications) to add your application.
@@ -14,7 +12,6 @@ Once you've added your application and your routes, you'll be able to see your A
14
12
 
15
13
  **Note**: Callback url has to be an exact match - if your url is `http://localhost:3001/users/auth/bike_index/callback` you _must_ enter that exactly - `http://localhost:3001/users/auth/` will not work.
16
14
 
17
-
18
15
  Check out the **[Bike Index API Documentation](https://bikeindex.org/documentation)** to see what can be done with authenticated users.
19
16
 
20
17
  ## Usage
@@ -62,7 +59,6 @@ end
62
59
 
63
60
  Available scopes: `read_user`, `write_user`, `read_bikes`, `write_bikes`
64
61
 
65
-
66
62
  ## Credentials
67
63
 
68
64
  If you don't include a scope, the response will include a `uid` from Bike Index for the user and nothing else.
@@ -71,11 +67,9 @@ If you include the `read_bikes` scope, the response will include an array of the
71
67
 
72
68
  You can use these IDs to access information about the bikes - e.g. [api/v3/bikes/3414](https://bikeindex.org/api/v3/bikes/3414) & [api/v3/bikes/29367](https://bikeindex.org/api/v3/bikes/29367)
73
69
 
74
- If you include the `read_user` scope, the response will include the user's nickname, email and name. You will also see their twitter handle and avatar if they have added them. The keys for these items -
70
+ If you include the `read_user` scope, the response will include the user's nickname, email and name. You will also see their twitter handle and avatar if they have added them. The keys for these items -
75
71
  `nickname`, `email`, `name`, `twitter` & `image` - all accessible in the `request.env['omniauth.auth']`, e.g. `request.env['omniauth.auth'].info.email`
76
72
 
77
-
78
73
  ## Auth Hash
79
74
 
80
75
  You can also see the authetication hash (in JSON format) by going to the authentication url on the Bike Index with the user's access token - `https://bikeindex.org/api/v3/me?access_token=<OAUTH_ACCESS_TOKEN>`
81
-
data/Rakefile CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env rake
2
- require 'bundler/gem_tasks'
3
- require 'rspec/core/rake_task'
2
+ require "bundler/gem_tasks"
3
+ require "rspec/core/rake_task"
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
6
6
  task test: :spec
7
- task default: :spec
7
+ task default: :spec
@@ -1,2 +1,2 @@
1
- require 'omniauth/bike_index/version'
2
- require 'omniauth/strategies/bike_index'
1
+ require "omniauth/bike_index/version"
2
+ require "omniauth/strategies/bike_index"
@@ -1,5 +1,5 @@
1
1
  module OmniAuth
2
2
  module BikeIndex
3
- VERSION = '1.0.0'
3
+ VERSION = "1.0.5"
4
4
  end
5
5
  end
@@ -1,41 +1,60 @@
1
- require 'omniauth-oauth2'
1
+ require "omniauth-oauth2"
2
2
 
3
3
  module OmniAuth
4
4
  module Strategies
5
5
  class BikeIndex < OmniAuth::Strategies::OAuth2
6
6
  option :name, :bike_index
7
- DEFAULT_SCOPE = 'public'
8
- option :client_options, site: 'https://bikeindex.org', authorize_url: '/oauth/authorize'
7
+ DEFAULT_SCOPE = "public"
8
+ option :client_options, site: "https://bikeindex.org", authorize_url: "/oauth/authorize"
9
9
 
10
- uid { raw_info['id'] }
10
+ uid { raw_info["id"] }
11
11
 
12
12
  info do
13
13
  prune!(
14
- 'nickname' => raw_info['user']['username'],
15
- 'bike_ids' => raw_info['bike_ids'],
16
- 'email' => raw_info['user']['email'],
17
- 'name' => raw_info['user']['name'],
18
- 'twitter' => raw_info['user']['twitter'],
19
- 'image' => raw_info['user']['image'],
14
+ "nickname" => raw_info["user"]["username"],
15
+ "bike_ids" => raw_info["bike_ids"],
16
+ "email" => raw_info["user"]["email"],
17
+ "secondary_emails" => raw_info["user"]["secondary_emails"],
18
+ "name" => raw_info["user"]["name"],
19
+ "twitter" => raw_info["user"]["twitter"],
20
+ "image" => raw_info["user"]["image"]
20
21
  )
21
22
  end
22
23
 
23
24
  extra do
24
25
  hash = {}
25
- hash['raw_info'] = raw_info unless skip_info?
26
+ hash["raw_info"] = raw_info unless skip_info?
26
27
  prune! hash
27
28
  end
28
29
 
29
30
  def raw_info
30
- @raw_info ||= access_token.get('/api/v3/me').parsed || {}
31
+ @raw_info ||= access_token.get("/api/v3/me").parsed || {}
32
+ end
33
+
34
+ def param_or_option(key)
35
+ # omniauth.params are the parameters passed in to the URL
36
+ # (e.g. company in /users/auth/bike_index?company=Metro)
37
+ # So for partner, company and unauthenticated_redirect it tries those params, then goes from settings
38
+ session["omniauth.params"] && session["omniauth.params"][key] ||
39
+ option[key]
31
40
  end
32
41
 
33
42
  def request_phase
34
- options[:authorize_params] = { scope: (options['scope'] || DEFAULT_SCOPE) }
43
+ options[:authorize_params] = {
44
+ scope: (options["scope"] || DEFAULT_SCOPE),
45
+ partner: param_or_option("partner"),
46
+ company: param_or_option("company"),
47
+ unauthenticated_redirect: param_or_option("unauthenticated_redirect")
48
+ }
35
49
  super
36
50
  end
37
51
 
38
- private
52
+ # https://github.com/omniauth/omniauth-oauth2/issues/81
53
+ def callback_url
54
+ full_host + script_name + callback_path
55
+ end
56
+
57
+ private
39
58
 
40
59
  def prune!(hash)
41
60
  hash.delete_if do |_, value|
@@ -43,7 +62,6 @@ module OmniAuth
43
62
  value.nil? || (value.respond_to?(:empty?) && value.empty?)
44
63
  end
45
64
  end
46
-
47
65
  end
48
66
  end
49
- end
67
+ end
@@ -1,25 +1,24 @@
1
- # -*- encoding: utf-8 -*-
2
- $LOAD_PATH.push File.expand_path('../lib', __FILE__)
3
- require 'omniauth/bike_index/version'
1
+ $LOAD_PATH.push File.expand_path("../lib", __FILE__)
2
+ require "omniauth/bike_index/version"
4
3
 
5
4
  Gem::Specification.new do |s|
6
- s.name = 'omniauth-bike-index'
7
- s.version = OmniAuth::BikeIndex::VERSION
8
- s.authors = ['Seth Herr']
9
- s.email = ['seth@bikeidnex.org']
10
- s.summary = 'Bike Index strategy for OmniAuth'
11
- s.description = 'Bike Index strategy for OmniAuth v1.2'
12
- s.homepage = 'https://github.com/bikeindex/omniauth-bike-index'
13
- s.license = 'MIT'
5
+ s.name = "omniauth-bike-index"
6
+ s.version = OmniAuth::BikeIndex::VERSION
7
+ s.authors = ["Seth Herr"]
8
+ s.email = ["seth@bikeidnex.org"]
9
+ s.summary = "Bike Index strategy for OmniAuth"
10
+ s.description = "Bike Index strategy for OmniAuth v1.2"
11
+ s.homepage = "https://github.com/bikeindex/omniauth-bike-index"
12
+ s.license = "MIT"
14
13
 
15
- s.files = `git ls-files`.split("\n")
16
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
- s.executables = `git ls-files -- bin/*`.split("\n").collect { |f| File.basename(f) }
18
- s.require_paths = ['lib']
14
+ s.files = `git ls-files`.split("\n")
15
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
+ s.executables = `git ls-files -- bin/*`.split("\n").collect { |f| File.basename(f) }
17
+ s.require_paths = ["lib"]
19
18
 
20
- s.add_runtime_dependency 'omniauth', '~> 1.2'
21
- s.add_runtime_dependency 'omniauth-oauth2', '~> 1.1'
19
+ s.add_runtime_dependency "omniauth", "~> 1.2"
20
+ s.add_runtime_dependency "omniauth-oauth2", "~> 1.1"
22
21
 
23
- s.add_development_dependency 'dotenv', '~> 0'
24
- s.add_development_dependency 'sinatra', '~> 0'
22
+ s.add_development_dependency "dotenv", "~> 0"
23
+ s.add_development_dependency "sinatra", "~> 0"
25
24
  end
data/spec/app.rb CHANGED
@@ -1,37 +1,37 @@
1
- $LOAD_PATH.unshift File.expand_path('..', __FILE__)
2
- $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
1
+ $LOAD_PATH.unshift File.expand_path("..", __FILE__)
2
+ $LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
3
3
 
4
- require 'dotenv'
5
- require 'sinatra'
6
- require 'omniauth'
7
- require 'omniauth-bike-index'
4
+ require "dotenv"
5
+ require "sinatra"
6
+ require "omniauth"
7
+ require "omniauth-bike-index"
8
8
 
9
9
  Dotenv.load
10
10
 
11
- use Rack::Session::Cookie, :key => 'key',
12
- :domain => 'localhost',
13
- :path => '/',
14
- :expire_after => 14_400,
15
- :secret => 'secret'
11
+ use Rack::Session::Cookie, key: "key",
12
+ domain: "localhost",
13
+ path: "/",
14
+ expire_after: 14_400,
15
+ secret: "secret"
16
16
 
17
17
  use OmniAuth::Builder do
18
- provider :bike_index, ENV['CLIENT_ID'], ENV['CLIENT_SECRET'], :scope => 'access_profile'
18
+ provider :bike_index, ENV["CLIENT_ID"], ENV["CLIENT_SECRET"], scope: "access_profile"
19
19
  end
20
20
 
21
- get '/' do
21
+ get "/" do
22
22
  <<-HTML
23
23
  <a href='/auth/bikeindex'>Sign in with Bike Index</a>
24
24
  HTML
25
25
  end
26
26
 
27
- get '/auth/failure' do
28
- env['omniauth.error'].to_s
27
+ get "/auth/failure" do
28
+ env["omniauth.error"].to_s
29
29
  end
30
30
 
31
- get '/auth/:name/callback' do
32
- auth = request.env['omniauth.auth']
31
+ get "/auth/:name/callback" do
32
+ auth = request.env["omniauth.auth"]
33
33
 
34
- puts %Q(
34
+ puts %(
35
35
  >> UID
36
36
  #{auth.uid.inspect}
37
37
 
@@ -45,5 +45,5 @@ get '/auth/:name/callback' do
45
45
  #{auth.extra.inspect}
46
46
  )
47
47
 
48
- 'Check logs for user information.'
48
+ "Check logs for user information."
49
49
  end
@@ -1,33 +1,32 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe OmniAuth::Strategies::BikeIndex do
4
4
  subject do
5
5
  @subject ||= begin
6
- args = ['client_id', 'client_secret', @options || {}].compact
6
+ args = ["client_id", "client_secret", @options || {}].compact
7
7
  OmniAuth::Strategies::BikeIndex.new(*args)
8
8
  end
9
9
  end
10
10
 
11
- context 'client options' do
12
- it 'has correct name' do
11
+ context "client options" do
12
+ it "has correct name" do
13
13
  expect(subject.options.name).to eq(:bike_index)
14
14
  end
15
15
 
16
- it 'has correct site' do
17
- expect(subject.options.client_options.site).to eq('https://bikeindex.org')
16
+ it "has correct site" do
17
+ expect(subject.options.client_options.site).to eq("https://bikeindex.org")
18
18
  end
19
19
 
20
- it 'has correct authorize url' do
21
- expect(subject.options.client_options.authorize_url).to eq('/oauth/authorize')
20
+ it "has correct authorize url" do
21
+ expect(subject.options.client_options.authorize_url).to eq("/oauth/authorize")
22
22
  end
23
-
24
23
  end
25
24
 
26
- context 'figuring stuff out' do
27
- it "gets log in" do
28
- app = lambda{|env| [200, {}, ["Hello World."]]}
29
- OmniAuth::Strategies::Developer.new(app).options.uid_field # => :email
30
- OmniAuth::Strategies::Developer.new(app, :uid_field => :name).options.uid_field # => :name
25
+ context "figuring stuff out" do
26
+ it "gets log in" do
27
+ app = lambda { |env| [200, {}, ["Hello World."]] }
28
+ OmniAuth::Strategies::Developer.new(app).options.uid_field # => :email
29
+ OmniAuth::Strategies::Developer.new(app, uid_field: :name).options.uid_field # => :name
31
30
  end
32
31
  end
33
32
  end
data/spec/spec_helper.rb CHANGED
@@ -1,10 +1,10 @@
1
- $LOAD_PATH.unshift File.expand_path('..', __FILE__)
2
- $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
1
+ $LOAD_PATH.unshift File.expand_path("..", __FILE__)
2
+ $LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
3
3
 
4
- require 'rspec'
5
- require 'omniauth'
6
- require 'omniauth-bike-index'
4
+ require "rspec"
5
+ require "omniauth"
6
+ require "omniauth-bike-index"
7
7
 
8
8
  RSpec.configure do |config|
9
- config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
9
+ config.extend OmniAuth::Test::StrategyMacros, type: :strategy
10
10
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-bike-index
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seth Herr
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-13 00:00:00.000000000 Z
11
+ date: 2021-02-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: omniauth
@@ -89,7 +89,7 @@ homepage: https://github.com/bikeindex/omniauth-bike-index
89
89
  licenses:
90
90
  - MIT
91
91
  metadata: {}
92
- post_install_message:
92
+ post_install_message:
93
93
  rdoc_options: []
94
94
  require_paths:
95
95
  - lib
@@ -104,9 +104,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
104
104
  - !ruby/object:Gem::Version
105
105
  version: '0'
106
106
  requirements: []
107
- rubyforge_project:
108
- rubygems_version: 2.4.8
109
- signing_key:
107
+ rubygems_version: 3.0.3
108
+ signing_key:
110
109
  specification_version: 4
111
110
  summary: Bike Index strategy for OmniAuth
112
111
  test_files: