Minimalist login for rack app with Google account
Ruby
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
example
lib/rack
spec
.gitignore
.travis.yml
Gemfile
README.markdown
Rakefile
rack-google_login.gemspec

README.markdown

rack-google_login

Minimalist login for rack app with Google account

Installation

Add to gemfile

gem 'rack-google_login'

or install with

gem install rack-google_login

How to use

  • Mount it Mount before the main app and put configuration hash into it. example

  • Create login page Use Rack::GoogleLogin.authorization_uri to get uri of Google OAuth 2.0 authoization endpoint. example

  • Controll access with session['user_info'] Redirect user who is not authorized to login page. If user_info was not found in session, the user is not yet authorized with Google. example

  • Use user_info example

Example

Simple sinatra app can be found here.

Useful links

Using OAuth 2.0 to Access Google APIs - Google Accounts Authentication and Authorization — Google Developers

Google APIs Console

TODO

  • Configurable root
  • Use refresh token
  • Make scopes configurable
  • Add more session store

Contribution

All kind of pull requests are very welcome ;-)

License

MIT Licence