sinatra_auth_gmail 0.0.1

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/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,28 @@
1
+ sinatra_gmail_auth
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
11
+
12
+ Gemfile
13
+ -------
14
+ gem "sinatra_auth_gmail"
15
+ # vim:ft=ruby
16
+
17
+ Example
18
+ -------
19
+ module Fooby
20
+ class App < Sinatra::Base
21
+ register Sinatra::Auth::Gmail
22
+ get '/' do
23
+ authorize!
24
+ haml "%h2= 'Hello There, #{gmail_user.full_name}!'"
25
+ end
26
+ end
27
+ end
28
+ end
data/Rakefile ADDED
@@ -0,0 +1,52 @@
1
+ require 'rake/gempackagetask'
2
+ require 'rubygems/specification'
3
+ require 'date'
4
+ require 'bundler'
5
+
6
+ task :default => [:spec]
7
+
8
+ require 'spec/rake/spectask'
9
+ desc "Run specs"
10
+ Spec::Rake::SpecTask.new do |t|
11
+ t.spec_files = FileList['spec/**/*_spec.rb']
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'
19
+ end
20
+
21
+ GEM = "sinatra_auth_gmail"
22
+ GEM_VERSION = "0.0.1"
23
+ AUTHOR = "Corey Donohoe"
24
+ EMAIL = "atmos@atmos.org"
25
+ HOMEPAGE = "http://github.com/atmos/sinatra_auth_gmail"
26
+ SUMMARY = "A sinatra extension that provides authentication for GMail authentication"
27
+
28
+ spec = Gem::Specification.new do |s|
29
+ s.name = GEM
30
+ s.version = GEM_VERSION
31
+ s.platform = Gem::Platform::RUBY
32
+ s.has_rdoc = true
33
+ s.extra_rdoc_files = ["LICENSE"]
34
+ s.summary = SUMMARY
35
+ s.description = s.summary
36
+ s.author = AUTHOR
37
+ s.email = EMAIL
38
+ s.homepage = HOMEPAGE
39
+
40
+ bundle = Bundler::Definition.from_gemfile('Gemfile')
41
+ bundle.dependencies.each do |dep|
42
+ next unless dep.groups.include?(:runtime)
43
+ s.add_dependency(dep.name, dep.version_requirements.to_s)
44
+ end
45
+
46
+ s.require_path = 'lib'
47
+ s.files = %w(LICENSE README.md Rakefile) + Dir.glob("{lib}/**/*")
48
+ end
49
+
50
+ Rake::GemPackageTask.new(spec) do |pkg|
51
+ pkg.gem_spec = spec
52
+ end
@@ -0,0 +1,61 @@
1
+ module Sinatra
2
+ module Auth
3
+ module Gmail
4
+ class BadAuthentication < Sinatra::Default
5
+ get '/unauthenticated' do
6
+ status 403
7
+ haml "%h3= 'Unable to authenticate, sorry bud.'"
8
+ end
9
+ end
10
+
11
+ module Helpers
12
+ def authorized?
13
+ env['warden'].authenticate!
14
+ end
15
+
16
+ def authorize!
17
+ throw(:warden) unless authorized?
18
+ end
19
+
20
+ def logout!
21
+ env['warden'].logout
22
+ end
23
+
24
+ def gmail_user
25
+ env['warden'].user
26
+ end
27
+ end
28
+
29
+ def self.registered(app)
30
+ app.use Warden::Manager do |manager|
31
+ manager.default_strategies :google_apps
32
+ manager.failure_app = BadAuthentication
33
+
34
+ manager[:google_apps_endpoint] = 'http://www.google.com/accounts/o8/id'
35
+ end
36
+ app.helpers Helpers
37
+
38
+ app.get '/logout' do
39
+ logout!
40
+ haml "%h2= 'Peace!'"
41
+ end
42
+ end
43
+
44
+ class ExampleApp < Sinatra::Base
45
+ register Sinatra::Auth::Gmail
46
+
47
+ before do
48
+ authorize!
49
+ end
50
+
51
+ get '/' do
52
+ haml "%h2= 'Hello There, #{gmail_user.full_name}!'"
53
+ end
54
+
55
+ get '/another_route' do
56
+ haml "%h2= 'Hello There, #{gmail_user.full_name}!'"
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,13 @@
1
+ require 'sinatra/base'
2
+ require 'haml/util'
3
+ require 'haml/engine'
4
+ require 'warden-googleapps'
5
+
6
+ module Sinatra
7
+ module Auth
8
+ module Gmail
9
+ end
10
+ end
11
+ end
12
+
13
+ require File.join(File.dirname(__FILE__), 'sinatra', 'auth', 'gmail')
metadata ADDED
@@ -0,0 +1,98 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sinatra_auth_gmail
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Corey Donohoe
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2010-02-09 00:00:00 -08:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: haml
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ~>
22
+ - !ruby/object:Gem::Version
23
+ version: 2.2.0
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: sinatra
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 0.9.4
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: rack
37
+ type: :runtime
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: 1.0.1
44
+ version:
45
+ - !ruby/object:Gem::Dependency
46
+ name: warden-googleapps
47
+ type: :runtime
48
+ version_requirement:
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 0.0.3
54
+ version:
55
+ description: A sinatra extension that provides authentication for GMail authentication
56
+ email: atmos@atmos.org
57
+ executables: []
58
+
59
+ extensions: []
60
+
61
+ extra_rdoc_files:
62
+ - LICENSE
63
+ files:
64
+ - LICENSE
65
+ - README.md
66
+ - Rakefile
67
+ - lib/sinatra/auth/gmail.rb
68
+ - lib/sinatra_auth_gmail.rb
69
+ has_rdoc: true
70
+ homepage: http://github.com/atmos/sinatra_auth_gmail
71
+ licenses: []
72
+
73
+ post_install_message:
74
+ rdoc_options: []
75
+
76
+ require_paths:
77
+ - lib
78
+ required_ruby_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: "0"
83
+ version:
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: "0"
89
+ version:
90
+ requirements: []
91
+
92
+ rubyforge_project:
93
+ rubygems_version: 1.3.5
94
+ signing_key:
95
+ specification_version: 3
96
+ summary: A sinatra extension that provides authentication for GMail authentication
97
+ test_files: []
98
+