Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you are using <a href="https://github.com/zquestz/omniauth-google-oauth2" rel="nofollow">omniauth-google-oauth2</a>, you can accomplish domain restrictions using by providing a value for <code>hd</code> option during initialization.</p> <pre><code>Rails.application.config.middleware.use OmniAuth::Builder do provider :google_oauth2, ENV['GOOGLE_CLIENT_ID'], ENV['GOOGLE_CLIENT_SECRET'], { scope: 'email, profile', hd: 'mycompany.com' } end </code></pre> <p>It's also possible to handle this in your controller which is handling the callback. You can deny users depending on values provided in <a href="https://github.com/zquestz/omniauth-google-oauth2#auth-hash" rel="nofollow"><code>request.env["omniauth.auth"]</code></a>.</p> <pre><code>class OmniauthCallbacksController &lt; Devise::OmniauthCallbacksController def google_oauth2 auth_details = request.env["omniauth.auth"] if auth_details.info['email'].split("@")[1] == "yourdomain.com" # do all the bits that come naturally in the callback controller user = User.from_omniauth(request.env["omniauth.auth"]) if user.persisted? flash.notice = "Signed in Through Google!" sign_in_and_redirect user else session["devise.user_attributes"] = user.attributes flash.notice = "You are almost Done! Please provide a password to finish setting up your account" redirect_to new_user_registration_url end else # This is where you turn away the poor souls who do not match your domain render :text =&gt; "We're sorry, at this time we do not allow access to our app." end end end </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload