No commit activity in last 3 years
No release in over 3 years
Simple integration for Rails to use Google Apps authentication.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.12

Runtime

 Project Readme

warden-googleapps-rails

A simple Rails integration using Google Apps OAuth.

It's built on warden-googleapps, and heavily inspired by warden-github-rails.

Usage

warden-googleapps-rails provides both controller-based and router-based authentication methods for Rails apps.

First of all, you need to configure this gem by creating an initializer like config/initializers/warden_googleapps_rails.rb, and include:

Warden::GoogleApps::Rails.setup do |config|
  # Required
  config.google_apps_domain = "example.org"
  
  # Optional
  # config.google_apps_endpoint = "http://www.google.com/accounts/o8/id" # this is gmail
  # config.google_apps_redirect_url =  "http://example.org/verify_url" # endpoint where google apps redirects to after successful authentication
end

Controller Helpers

There're several authentication methods for controllers.

# Redirect user to Google Apps OAuth if user not log in
googleapps_authenticate!

# Return whether user has logged in
googleapps_authenticate? 

# Get user object
googleapps_user

# Log out
googleapps_logout

Thus you could write something like:

class PostsController < ApplicationController
  # Ask user log in for all actions
  before_filter :googleapps_authenticate! 
  
  def new
  	@user = googleapps_user
  	# …
  end
  # …
end

Router Constraints

In your routes.rb you could simply wrap your resources:

MyApp::Application.routes.draw do
  # …

  namespace :admin do do    
    # Initialize Google Apps authentication flow if user not log in
    googleapps_authenticate do
      resources :posts
    end
    
    # Require user log in but will not redirect to OAuth flow
    googleapps_authenticated do
      resources :users
    end
  # …
  end

end

Contact

Richard Lee

License

warden-googleapps-rails is available under the MIT license. See the LICENSE.txt file for more info.