patheard / blazer-docker

Blazer with Devise and Google OAuth2 sign in

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

🔐 Blazer with Devise and Google OAuth2 sign in

An example of how to use ankane/blazer-docker with Devise and Google OAuth2 authentication.

Setup

  1. Create a new OAuth 2.0 Client ID:
    • Application type: Web application
    • Authorized JavaScript origins: http://localhost and http://localhost:8080
    • Authorized redirect URIs: http://localhost:8080/users/auth/google_oauth2/callback
  2. Create a .env based on the .env.example and add your Google OAuth2 credentials.
  3. Run docker-compose up and access at http://localhost:8080.

All routes are protected by Devise, so you'll need to sign in with Google to access Blazer. Users that are already signed into their Google account will be automatically signed in once they've accepted the consent screen.

Notes

To remove Google Sign-in and use server-side sign-in:

  1. Add gem "omniauth-rails_csrf_protection" to the Gemfile.
  2. Delete the config/initializers/omniauth.rb file.
  3. Add a sign-in button to app/views/devise/sessions/new.html.erb:
<%= button_to "Sign in with Google", user_google_oauth2_omniauth_authorize_path, method: :post %>

Credits

About

Blazer with Devise and Google OAuth2 sign in

License:MIT License


Languages

Language:Ruby 84.0%Language:HTML 12.9%Language:Dockerfile 2.2%Language:Shell 0.8%Language:Procfile 0.1%