chorn-warden-googleapps 0.2.0

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,81 @@
1
+ warden-googleapps
2
+ =================
3
+
4
+ A Warden middleware for google apps. It needs a little work but definitely authenticates you just fine in Rack apps.
5
+
6
+ Example
7
+ =======
8
+ Gemfile
9
+ -------
10
+ source :gemcutter
11
+
12
+ gem 'haml', '~>2.2.0'
13
+ gem 'warden-googleapps', '=0.0.3'
14
+
15
+ group :development do
16
+ gem 'shotgun'
17
+ end
18
+
19
+ app.rb
20
+ ------
21
+ module DirectoryAdmin
22
+ class App < Sinatra::Default
23
+ disable :show_errors
24
+ disable :show_exceptions
25
+
26
+ use Warden::Manager do |manager|
27
+ manager.default_strategies :google_apps
28
+ manager.failure_app = BadAuthentication
29
+
30
+ manager[:google_apps_domain] = 'example.org'
31
+ # manager[:google_apps_endpoint] = 'http://www.google.com/accounts/o8/id' # this is gmail
32
+ end
33
+
34
+ helpers do
35
+ def ensure_authenticated
36
+ unless env['warden'].authenticate!
37
+ throw(:warden)
38
+ end
39
+ end
40
+
41
+ def user
42
+ env['warden'].user
43
+ end
44
+ end
45
+
46
+ get '/' do
47
+ ensure_authenticated
48
+ haml "%h2= 'Hello There, #{user.full_name}!'"
49
+ end
50
+
51
+ get '/logout' do
52
+ env['warden'].logout
53
+ haml "%h2= 'Peace!'"
54
+ end
55
+ end
56
+
57
+ class BadAuthentication < Sinatra::Default
58
+ get '/unauthenticated' do
59
+ status 403
60
+ haml "%h3= 'Unable to authenticate, sorry bud.'"
61
+ end
62
+ end
63
+ end
64
+
65
+ Enabling on GMail
66
+ ==================
67
+ It should just work, even for localhost.
68
+
69
+ Also checkout [sinatra-auth-gmail](http://github.com/atmos/sinatra-auth-gmail).
70
+
71
+ Enabling on Google Apps for Domains
72
+ ===================================
73
+ Be sure you have Federated Login using OpenID enabled under your Advanced Settings Tab
74
+
75
+ ![Your Google Apps Admin Dashboard](http://img.skitch.com/20100103-cdjtbyyw2xsbwya92r6gcd47hr.jpg "Check the box to enable")
76
+
77
+ Developing
78
+ ==========
79
+ % gem install bundler
80
+ % bundle install
81
+ % bundle exec rake repackage
data/Rakefile ADDED
@@ -0,0 +1,61 @@
1
+ require 'rake/gempackagetask'
2
+ require 'rubygems/specification'
3
+ require 'date'
4
+ require 'bundler'
5
+
6
+ require 'lib/warden-googleapps/version'
7
+
8
+ task :default => [:spec]
9
+
10
+ require 'spec/rake/spectask'
11
+ desc "Run specs"
12
+ Spec::Rake::SpecTask.new do |t|
13
+ t.spec_files = FileList['spec/**/*_spec.rb']
14
+ t.spec_opts = %w(-fs --color)
15
+ t.spec_opts << '--loadby' << 'random'
16
+
17
+ t.rcov_opts << '--exclude' << 'spec,.bundle'
18
+ t.rcov = ENV.has_key?('NO_RCOV') ? ENV['NO_RCOV'] != 'true' : true
19
+ t.rcov_opts << '--text-summary'
20
+ t.rcov_opts << '--sort' << 'coverage' << '--sort-reverse'
21
+ end
22
+
23
+ GEM = "warden-googleapps"
24
+ GEM_VERSION = Warden::GoogleApps::VERSION
25
+ AUTHOR = "Corey Donohoe"
26
+ EMAIL = "atmos@atmos.org"
27
+ HOMEPAGE = "http://github.com/atmos/warden-googleapps"
28
+ SUMMARY = "Warden / Devise strategies to use Google's Federated OpenID with Google Apps"
29
+
30
+ spec = Gem::Specification.new do |s|
31
+ s.name = GEM
32
+ s.version = GEM_VERSION
33
+ s.platform = Gem::Platform::RUBY
34
+ s.has_rdoc = true
35
+ s.extra_rdoc_files = ["LICENSE"]
36
+ s.summary = SUMMARY
37
+ s.description = s.summary
38
+ s.author = AUTHOR
39
+ s.email = EMAIL
40
+ s.homepage = HOMEPAGE
41
+
42
+ bundle = Bundler::Definition.from_gemfile('Gemfile')
43
+ bundle.dependencies.each do |dep|
44
+ next unless dep.groups.include?(:runtime)
45
+ s.add_dependency(dep.name, dep.version_requirements.to_s)
46
+ end
47
+
48
+ s.require_path = 'lib'
49
+ s.files = %w(LICENSE README.md Rakefile) + Dir.glob("{lib}/**/*")
50
+ end
51
+
52
+ Rake::GemPackageTask.new(spec) do |pkg|
53
+ pkg.gem_spec = spec
54
+ end
55
+
56
+ desc "create a gemspec file"
57
+ task :make_spec do
58
+ File.open("#{GEM}.gemspec", "w") do |file|
59
+ file.puts spec.to_ruby
60
+ end
61
+ end