sinatra_auth_github 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 Corey Donohoe
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,10 @@
1
+ sinatra_auth_github
2
+ ===================
3
+
4
+ A sinatra app the provides a gem that...
5
+
6
+ Developing
7
+ ==========
8
+ % gem install bundler
9
+ % bundle install
10
+ % bundle exec rake
@@ -0,0 +1,53 @@
1
+ module Sinatra
2
+ module Auth
3
+ module Github
4
+ class BadAuthentication < Sinatra::Base
5
+ get '/unauthenticated' do
6
+ status 403
7
+ "Unable to authenticate, sorry bud."
8
+ end
9
+ end
10
+
11
+ module Helpers
12
+ def warden
13
+ env['warden']
14
+ end
15
+
16
+ def authenticate!(*args)
17
+ warden.authenticate!(*args)
18
+ end
19
+
20
+ def authenticated?(*args)
21
+ warden.authenticated?(*args)
22
+ end
23
+
24
+ def logout!
25
+ warden.logout
26
+ end
27
+
28
+ def github_user
29
+ warden.user
30
+ end
31
+ end
32
+
33
+ def self.registered(app)
34
+ app.use Warden::Manager do |manager|
35
+ manager.default_strategies :github
36
+
37
+ manager.failure_app = app.github_options[:failure_app] || BadAuthentication
38
+
39
+ manager[:github_secret] = app.github_options[:secret]
40
+ manager[:github_client_id] = app.github_options[:client_id]
41
+ manager[:github_callback_url] = app.github_options[:callback_url] || '/auth/github/callback'
42
+ end
43
+
44
+ app.helpers Helpers
45
+
46
+ app.get '/auth/github/callback' do
47
+ authenticate!
48
+ redirect "/"
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,2 @@
1
+ require 'warden-github'
2
+ require 'sinatra/auth/github'
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sinatra_auth_github
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Corey Donohoe
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-06-01 00:00:00 -07:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ prerelease: false
23
+ version_requirements: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ~>
27
+ - !ruby/object:Gem::Version
28
+ hash: 15
29
+ segments:
30
+ - 1
31
+ - 0
32
+ version: "1.0"
33
+ requirement: *id001
34
+ type: :runtime
35
+ name: sinatra
36
+ - !ruby/object:Gem::Dependency
37
+ prerelease: false
38
+ version_requirements: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ hash: 25
44
+ segments:
45
+ - 0
46
+ - 0
47
+ - 3
48
+ version: 0.0.3
49
+ requirement: *id002
50
+ type: :runtime
51
+ name: warden-github
52
+ description: A sinatra extension for easy oauth integration with github
53
+ email: atmos@atmos.org
54
+ executables: []
55
+
56
+ extensions: []
57
+
58
+ extra_rdoc_files:
59
+ - LICENSE
60
+ files:
61
+ - LICENSE
62
+ - README.md
63
+ - lib/sinatra/auth/github.rb
64
+ - lib/sinatra_auth_github.rb
65
+ has_rdoc: true
66
+ homepage: http://www.github.com/atmos/sinatra_auth_github
67
+ licenses: []
68
+
69
+ post_install_message:
70
+ rdoc_options: []
71
+
72
+ require_paths:
73
+ - lib
74
+ required_ruby_version: !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ hash: 3
80
+ segments:
81
+ - 0
82
+ version: "0"
83
+ required_rubygems_version: !ruby/object:Gem::Requirement
84
+ none: false
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ hash: 3
89
+ segments:
90
+ - 0
91
+ version: "0"
92
+ requirements: []
93
+
94
+ rubyforge_project:
95
+ rubygems_version: 1.3.7
96
+ signing_key:
97
+ specification_version: 3
98
+ summary: A sinatra extension for easy oauth integration with github
99
+ test_files: []
100
+