lib/balrog/middleware/controller.rb
# This method is called if a user attempts to sign in with Single Sign-on
# and will authenticate the user if email domain has been whitelisted.
This method is called if a user attempts to sign in with Single Sign-on
and will authenticate the user if email domain has been whitelisted.
This method is called if a user attempts to sign in with Single Sign - on and will authenticate the user if email domain has been whitelisted .
def omniauthentication(env)
      if env['omniauth.auth']['info']['email']
        user_email = env['omniauth.auth']['info']['email']
        email_domain = user_email.split("@").last
      end
      unless email_domain
        return [302, {"Location" => referer}, [""]]
      end
      unless domain_whitelist
        warn <<~EOF
          !! Balrog has not been configured with a domain_whitelist. You shall not
          !! pass! When setting up Balrog::Middleware, pass in a block and
          !! call `set_domain_whitelist` passing in an omniauth provider and
          !! required keys.
          !!
          !! Check out https://github.com/pixielabs/balrog for more information.
        EOF
        return [302, {"Location" => referer}, [""]]
      end
      if domain_whitelist.include?(email_domain)
        authenticate_user(env)
      end
      referer = env["omniauth.origin"] || '/'
      [302, {"Location" => referer}, [""]]
    end
def omniauthentication ( env ) if env [ 'omniauth.auth' ] [ 'info' ] [ 'email' ] user_email = env [ 'omniauth.auth' ] [ 'info' ] [ 'email' ] email_domain = user_email . split ( "@" ) . last end unless email_domain return [ 302 , { "Location" => referer } , [ "" ] ] end unless domain_whitelist warn <<~EOF 

          !! Balrog has not been configured with a domain_whitelist. You shall not
          !! pass! When setting up Balrog::Middleware, pass in a block and
          !! call `set_domain_whitelist` passing in an omniauth provider and
          !! required keys.
          !!
          !! Check out https://github.com/pixielabs/balrog for more information.

         EOF return [ 302 , { "Location" => referer } , [ "" ] ] end if domain_whitelist . include? ( email_domain ) authenticate_user ( env ) end referer = env [ "omniauth.origin" ] || '/' [ 302 , { "Location" => referer } , [ "" ] ] end
This method is called if a user attempts to sign in with Single Sign-on
and will authenticate the user if email domain has been whitelisted.
This method is called if a user attempts to sign in with Single Sign - on and will authenticate the user if email domain has been whitelisted .
# Extract the email domain from the omniauth hash. # If there is no email domain, redirect the user before authentication. # If there is no domain_whitelist, alert the developer. # Authenticate the user if the user's email domain is whitelisted.
env