Sha256: bab79ee93047946b70ec2d65a8e18878b7c68b99ee7c020234fcaf199f9b0e16

Contents?: true

Size: 1.96 KB

Versions: 6

Compression:

Stored size: 1.96 KB

Contents

warden-googleapps
=================

A Warden middleware for google apps.  It needs a little work but definitely authenticates you just fine in Rack apps.

Example
=======
Gemfile
-------
    source :gemcutter

    gem 'haml',                '~>2.2.0'
    gem 'warden-googleapps',    '=0.0.3'

    group :development do
      gem 'shotgun'
    end

app.rb
------
    module DirectoryAdmin
      class App < Sinatra::Default
        disable :show_errors
        disable :show_exceptions

        use Warden::Manager do |manager|
          manager.default_strategies :google_apps
          manager.failure_app = BadAuthentication

          manager[:google_apps_domain]   = 'example.org'
          # manager[:google_apps_endpoint] = 'http://www.google.com/accounts/o8/id' # this is gmail
        end

        helpers do
          def ensure_authenticated
            unless env['warden'].authenticate!
              throw(:warden)
            end
          end

          def user
            env['warden'].user
          end
        end

        get '/' do
          ensure_authenticated
          haml "%h2= 'Hello There, #{user.full_name}!'"
        end

        get '/logout' do
          env['warden'].logout
          haml "%h2= 'Peace!'"
        end
      end

      class BadAuthentication < Sinatra::Default
        get '/unauthenticated' do
          status 403
          haml "%h3= 'Unable to authenticate, sorry bud.'"
        end
      end
    end

Enabling on GMail
==================
It should just work, even for localhost.

Also checkout [sinatra-auth-gmail](http://github.com/atmos/sinatra-auth-gmail).

Enabling on Google Apps for Domains
===================================
Be sure you have Federated Login using OpenID enabled under your Advanced Settings Tab

![Your Google Apps Admin Dashboard](http://img.skitch.com/20100103-cdjtbyyw2xsbwya92r6gcd47hr.jpg "Check the box to enable")

Developing
==========
    % gem install bundler
    % bundle install
    % bundle exec rake repackage

Version data entries

6 entries across 6 versions & 3 rubygems

Version Path
chorn-warden-googleapps-0.2.1 README.md
chorn-warden-googleapps-0.2.0 README.md
warden-googleapps-0.1.0 README.md
warden-googleapps-0.0.5 README.md
warden-googleapps-0.0.4 README.md
lachlanhardy-warden-googleapps-0.0.4 README.md