sinatra_auth_github 0.3.1 → 0.4.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/README.md CHANGED
@@ -56,3 +56,4 @@ Extension Options
56
56
  * `:client_id` - The client id that GitHub provides
57
57
  * `:failure_app` - A Sinatra::Base class that has a route for `/unauthenticated`, Useful for overriding the securocat default page.
58
58
  * `:callback_url` - The path that GitHub posts back to, defaults to `/auth/github/callback`.
59
+ * `:oauth_domain` - The scheme and host that's GitHub's endpoint, defaults to `https://github.com`
@@ -6,7 +6,7 @@ require 'rest_client'
6
6
  module Sinatra
7
7
  module Auth
8
8
  module Github
9
- VERSION = "0.3.0"
9
+ VERSION = "0.4.0"
10
10
 
11
11
  # Simple way to serve an image early in the stack and not get blocked by
12
12
  # application level before filters
@@ -60,6 +60,15 @@ module Sinatra
60
60
  warden.user
61
61
  end
62
62
 
63
+ def github_api_uri
64
+ if ENV['GITHUB_OAUTH_API_DOMAIN']
65
+ ENV['GITHUB_OAUTH_API_DOMAIN']
66
+ else
67
+ uri = URI.parse(env['warden'].config[:github_oauth_domain])
68
+ "#{uri.scheme}://api.#{uri.host}"
69
+ end
70
+ end
71
+
63
72
  # Send a V3 API GET request to path
64
73
  #
65
74
  # path - the path on api.github.com to hit
@@ -70,7 +79,7 @@ module Sinatra
70
79
  # github_raw_request("/user")
71
80
  # # => RestClient::Response
72
81
  def github_raw_request(path)
73
- RestClient.get("https://api.github.com/#{path}", :params => { :access_token => github_user.token }, :accept => :json)
82
+ RestClient.get("#{github_api_uri}/#{path}", :params => { :access_token => github_user.token }, :accept => :json)
74
83
  end
75
84
 
76
85
  # Send a V3 API GET request to path and parse the response body
@@ -167,6 +176,7 @@ module Sinatra
167
176
  manager[:github_secret] = app.github_options[:secret] || ENV['GITHUB_CLIENT_SECRET']
168
177
  manager[:github_scopes] = app.github_options[:scopes] || ''
169
178
  manager[:github_client_id] = app.github_options[:client_id] || ENV['GITHUB_CLIENT_ID']
179
+ manager[:github_oauth_domain] = app.github_options[:oauth_domain] || ENV['GITHUB_OAUTH_DOMAIN'] || 'https://github.com'
170
180
  manager[:github_callback_url] = app.github_options[:callback_url] || '/auth/github/callback'
171
181
  end
172
182
 
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "sinatra_auth_github"
6
- s.version = "0.3.1"
6
+ s.version = "0.4.0"
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.authors = ["Corey Donohoe"]
9
9
  s.email = ["atmos@atmos.org"]
@@ -16,7 +16,7 @@ Gem::Specification.new do |s|
16
16
  s.add_dependency "sinatra", "~>1.0"
17
17
  s.add_dependency "yajl-ruby", "~>1.1"
18
18
  s.add_dependency "rest-client", "~>1.6.1"
19
- s.add_dependency "warden-github", "~>0.3.0"
19
+ s.add_dependency "warden-github", "~>0.4.0"
20
20
 
21
21
  s.add_development_dependency "rake"
22
22
  s.add_development_dependency "rspec", "~>1.3.0"
data/spec/app.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'pp'
2
+ require 'ruby-debug'
2
3
 
3
4
  module Example
4
5
  class App < Sinatra::Base
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra_auth_github
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 15
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 3
9
- - 1
10
- version: 0.3.1
8
+ - 4
9
+ - 0
10
+ version: 0.4.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Corey Donohoe
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-01-19 00:00:00 -08:00
18
+ date: 2012-03-01 00:00:00 -08:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -72,12 +72,12 @@ dependencies:
72
72
  requirements:
73
73
  - - ~>
74
74
  - !ruby/object:Gem::Version
75
- hash: 19
75
+ hash: 15
76
76
  segments:
77
77
  - 0
78
- - 3
78
+ - 4
79
79
  - 0
80
- version: 0.3.0
80
+ version: 0.4.0
81
81
  type: :runtime
82
82
  version_requirements: *id004
83
83
  - !ruby/object:Gem::Dependency