sinatra_auth_github 0.13.3 → 0.14.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/README.md +11 -4
- data/Rakefile +5 -12
- data/lib/sinatra/auth/github/test/test_helper.rb +2 -1
- data/lib/sinatra/auth/github/version.rb +1 -1
- data/lib/sinatra/auth/github.rb +7 -6
- data/sinatra_auth_github.gemspec +2 -3
- data/spec/app.rb +0 -1
- data/spec/login_spec.rb +6 -0
- data/spec/quality_spec.rb +2 -2
- data/spec/spec_helper.rb +0 -3
- metadata +6 -22
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -28,11 +28,11 @@ There's an example app in [spec/app.rb](/spec/app.rb).
|
|
28
28
|
Example App Functionality
|
29
29
|
=========================
|
30
30
|
|
31
|
-
You can simply authenticate via GitHub by hitting http://localhost:
|
31
|
+
You can simply authenticate via GitHub by hitting http://localhost:9393
|
32
32
|
|
33
|
-
You can check organization membership by hitting http://localhost:
|
33
|
+
You can check organization membership by hitting http://localhost:9393/orgs/github
|
34
34
|
|
35
|
-
You can check team membership by hitting http://localhost:
|
35
|
+
You can check team membership by hitting http://localhost:9393/teams/42
|
36
36
|
|
37
37
|
All unsuccessful authentication requests get sent to the securocat denied page.
|
38
38
|
|
@@ -56,4 +56,11 @@ 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
|
-
|
59
|
+
|
60
|
+
Enterprise Authentication
|
61
|
+
=========================
|
62
|
+
|
63
|
+
Under the hood, the `warden-github` portion is powered by octokit. If you find yourself wanting to connect to a GitHub Enterprise installation you'll need to export two environmental variables.
|
64
|
+
|
65
|
+
* OCTOKIT_WEB_ENDPOINT - The web endpoint for OAuth, defaults to https://github.com
|
66
|
+
* OCTOKIT_API_ENDPOINT - The API endpoint for authenticated requests, defaults to https://api.github.com
|
data/Rakefile
CHANGED
@@ -1,19 +1,12 @@
|
|
1
|
-
require '
|
1
|
+
require 'rubygems/package_task'
|
2
2
|
require 'rubygems/specification'
|
3
3
|
require 'date'
|
4
|
-
require 'bundler
|
4
|
+
require 'bundler'
|
5
5
|
|
6
6
|
task :default => [:spec]
|
7
7
|
|
8
|
-
require '
|
8
|
+
require 'rspec/core/rake_task'
|
9
9
|
desc "Run specs"
|
10
|
-
|
11
|
-
t.
|
12
|
-
t.spec_opts = %w(-fs --color)
|
13
|
-
t.spec_opts << '--loadby' << 'random'
|
14
|
-
|
15
|
-
t.rcov_opts << '--exclude' << 'spec,.bundle'
|
16
|
-
t.rcov = ENV.has_key?('NO_RCOV') ? ENV['NO_RCOV'] != 'true' : true
|
17
|
-
t.rcov_opts << '--text-summary'
|
18
|
-
t.rcov_opts << '--sort' << 'coverage' << '--sort-reverse'
|
10
|
+
RSpec::Core::RakeTask.new do |t|
|
11
|
+
t.pattern = 'spec/**/*_spec.rb'
|
19
12
|
end
|
@@ -18,7 +18,8 @@ module Sinatra
|
|
18
18
|
'name' => "Test User",
|
19
19
|
'email' => "test@example.com",
|
20
20
|
'company' => "GitHub",
|
21
|
-
'gravatar_id' => '
|
21
|
+
'gravatar_id' => 'a'*32,
|
22
|
+
'avatar_url' => 'https://a249.e.akamai.net/assets.github.com/images/gravatars/gravatar-140.png?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png'
|
22
23
|
}
|
23
24
|
default_attrs.merge! attrs
|
24
25
|
User.new(default_attrs)
|
data/lib/sinatra/auth/github.rb
CHANGED
@@ -146,16 +146,17 @@ module Sinatra
|
|
146
146
|
|
147
147
|
def self.registered(app)
|
148
148
|
app.use AccessDenied
|
149
|
+
app.use BadAuthentication
|
150
|
+
|
149
151
|
app.use Warden::Manager do |manager|
|
150
152
|
manager.default_strategies :github
|
151
153
|
|
152
|
-
manager.failure_app
|
154
|
+
manager.failure_app = app.github_options[:failure_app] || BadAuthentication
|
153
155
|
|
154
|
-
manager[:
|
155
|
-
manager[:
|
156
|
-
manager[:
|
157
|
-
manager[:
|
158
|
-
manager[:github_callback_url] = app.github_options[:callback_url] || '/auth/github/callback'
|
156
|
+
manager[:client_secret] = app.github_options[:secret] || ENV['GITHUB_CLIENT_SECRET']
|
157
|
+
manager[:scopes] = app.github_options[:scopes] || ''
|
158
|
+
manager[:client_id] = app.github_options[:client_id] || ENV['GITHUB_CLIENT_ID']
|
159
|
+
manager[:redirect_uri] = app.github_options[:callback_url] || '/auth/github/callback'
|
159
160
|
end
|
160
161
|
|
161
162
|
app.helpers Helpers
|
data/sinatra_auth_github.gemspec
CHANGED
@@ -15,14 +15,13 @@ Gem::Specification.new do |s|
|
|
15
15
|
s.rubyforge_project = "sinatra_auth_github"
|
16
16
|
|
17
17
|
s.add_dependency "sinatra", "~>1.0"
|
18
|
-
s.add_dependency "warden-github", "~>0.
|
18
|
+
s.add_dependency "warden-github", "~>0.14.0"
|
19
19
|
|
20
20
|
s.add_development_dependency "rake"
|
21
|
-
s.add_development_dependency "rspec", "~>2.
|
21
|
+
s.add_development_dependency "rspec", "~>2.4.0"
|
22
22
|
s.add_development_dependency "shotgun"
|
23
23
|
s.add_development_dependency "randexp", "~>0.1.5"
|
24
24
|
s.add_development_dependency "rack-test", "~>0.5.3"
|
25
|
-
s.add_development_dependency "debugger"
|
26
25
|
|
27
26
|
s.files = `git ls-files`.split("\n")
|
28
27
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
data/spec/app.rb
CHANGED
data/spec/login_spec.rb
CHANGED
@@ -22,4 +22,10 @@ describe "Logged in users" do
|
|
22
22
|
last_response.status.should eql(302)
|
23
23
|
last_response.headers['Location'].should =~ %r{^https://github\.com/login/oauth/authorize}
|
24
24
|
end
|
25
|
+
|
26
|
+
it "shows the securocat when github returns an oauth error" do
|
27
|
+
get "/auth/github/callback?error=redirect_uri_mismatch"
|
28
|
+
follow_redirect!
|
29
|
+
last_response.body.should =~ %r{securocat\.png}
|
30
|
+
end
|
25
31
|
end
|
data/spec/quality_spec.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/spec_helper'
|
2
2
|
|
3
3
|
describe "The library itself" do
|
4
|
-
|
4
|
+
RSpec::Matchers.define :have_no_tab_characters do
|
5
5
|
match do |filename|
|
6
6
|
@failing_lines = []
|
7
7
|
File.readlines(filename).each_with_index do |line,number|
|
@@ -15,7 +15,7 @@ describe "The library itself" do
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
|
18
|
+
RSpec::Matchers.define :have_no_extraneous_spaces do
|
19
19
|
match do |filename|
|
20
20
|
@failing_lines = []
|
21
21
|
File.readlines(filename).each_with_index do |line,number|
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sinatra_auth_github
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.14.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-08-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sinatra
|
@@ -34,7 +34,7 @@ dependencies:
|
|
34
34
|
requirements:
|
35
35
|
- - ~>
|
36
36
|
- !ruby/object:Gem::Version
|
37
|
-
version: 0.
|
37
|
+
version: 0.14.0
|
38
38
|
type: :runtime
|
39
39
|
prerelease: false
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -42,7 +42,7 @@ dependencies:
|
|
42
42
|
requirements:
|
43
43
|
- - ~>
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version: 0.
|
45
|
+
version: 0.14.0
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
47
|
name: rake
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,7 +66,7 @@ dependencies:
|
|
66
66
|
requirements:
|
67
67
|
- - ~>
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version: 2.
|
69
|
+
version: 2.4.0
|
70
70
|
type: :development
|
71
71
|
prerelease: false
|
72
72
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -74,7 +74,7 @@ dependencies:
|
|
74
74
|
requirements:
|
75
75
|
- - ~>
|
76
76
|
- !ruby/object:Gem::Version
|
77
|
-
version: 2.
|
77
|
+
version: 2.4.0
|
78
78
|
- !ruby/object:Gem::Dependency
|
79
79
|
name: shotgun
|
80
80
|
requirement: !ruby/object:Gem::Requirement
|
@@ -123,22 +123,6 @@ dependencies:
|
|
123
123
|
- - ~>
|
124
124
|
- !ruby/object:Gem::Version
|
125
125
|
version: 0.5.3
|
126
|
-
- !ruby/object:Gem::Dependency
|
127
|
-
name: debugger
|
128
|
-
requirement: !ruby/object:Gem::Requirement
|
129
|
-
none: false
|
130
|
-
requirements:
|
131
|
-
- - ! '>='
|
132
|
-
- !ruby/object:Gem::Version
|
133
|
-
version: '0'
|
134
|
-
type: :development
|
135
|
-
prerelease: false
|
136
|
-
version_requirements: !ruby/object:Gem::Requirement
|
137
|
-
none: false
|
138
|
-
requirements:
|
139
|
-
- - ! '>='
|
140
|
-
- !ruby/object:Gem::Version
|
141
|
-
version: '0'
|
142
126
|
description: A sinatra extension for easy oauth integration with github
|
143
127
|
email:
|
144
128
|
- atmos@atmos.org
|