Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • G gitlabhq1
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 21
    • Issues 21
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 12
    • Merge requests 12
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Infrastructure Registry
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • gpt
  • large_projects
  • gitlabhq1
  • Issues
  • #1620

Closed
Open
Created Oct 03, 2012 by Administrator@rootOwner

OmniAuth against existing users

Created by: Ikstar

Issue: Omniauth will not map to existing users, instead it tries to create new users accounts and fails.

Tested: 2.9.1 Stable , 2.6->2.9.1 Upgrade

Scenario:

  1. Existing Gitlab install enables Omniauth for google.
omniauth:
  # Enable ability for users
  # to login via twitter, google ..
  enabled: true

  # IMPORTANT!
  # It allows user to login without having user account
  allow_single_sign_on: true
  block_auto_created_users: true

  # Auth providers
  providers:
     - { name: 'google_oauth2', app_id: 'NUMERICALID.apps.googleusercontent.com',
         app_secret: 'MY_APP_SECRET',
         args: { access_type: 'online', approval_prompt: '' } }
  1. There are existing users [email protected]
  2. Login Process
    • New User (no email registered in gitlab) logs in via Omniauth. Account is created and blocked. (aka works as intended)
    • Existing user logs in via Omniauth. 422 error page is displayed and the following log results
Started GET "/users/auth/google_oauth2/callback?state=e5fd77f54b8d5fdb347e&code=Ih0uQG5TAeMYuJJVnL49Cc-UzMZNdAI" for xxx.xxx.xxx.xxx at 2012-10-03$
Processing by OmniauthCallbacksController#google_oauth2 as HTML
  Parameters: {"state"=>"e5fd77f54b8d5fdb347", "code"=>"Ih0uQG5TAeMYuJJVnL49Cc-UzMZNdAI"}
Completed 500 Internal Server Error in 171ms

ActiveRecord::RecordInvalid (Validation failed: Email has already been taken):
  lib/gitlab/auth.rb:45:in `create_from_omniauth'
  lib/gitlab/auth.rb:56:in `find_or_new_for_omniauth'
  app/models/user.rb:94:in `find_or_new_for_omniauth'
  app/controllers/omniauth_callbacks_controller.rb:40:in `handle_omniauth'
  app/controllers/omniauth_callbacks_controller.rb:4:in `block (2 levels) in <class:OmniauthCallbacksController>'

Removed IP, and parts of state/code variables as this is a production log.

Assignee
Assign to
Time tracking