Blazer with Google OAuth2 sign in based on ankane/blazer-docker.
- Create a new OAuth 2.0 Client ID:
- Application type: Web application
- Authorized JavaScript origins:
http://localhost
andhttp://localhost:8080
- Authorized redirect URIs:
http://localhost:8080/users/auth/google_oauth2/callback
- Create a
.env
based on the.env.example
and add your Google OAuth2 credentials. - Edit the
docker-compose.yml
and change theDATABASE_URL
andBLAZER_DATABASE_URL
(suggestions are in file) - Run
docker-compose up
and access at http://localhost:8080. - Connect to the
web
service and runrails db:migrate
.
All routes are protected by Devise, so will 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.
To remove Google Sign-in and use server-side sign-in:
- Add
gem "omniauth-rails_csrf_protection"
to theGemfile
. - Delete the
config/initializers/omniauth.rb
file. - 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 %>
- The majority of this project setup is from ankane/blazer-docker.