Skip to content

Define LDAP omniauth_callbacks route only from GitLab config

Thong Kuah requested to merge fix_ldap_routing_calling_db into master

What does this MR do and why?

I found that the route definition for LDAP omniauth_callbacks involves a database call which is not ideal. So rather then using the database, we always define the routes, and use the controller instead of enforce the multiple_ldap_servers licensed feature.

Related issue: #359913 (closed), !92075 (merged)

Screenshots or screen recordings

These are strongly recommended to assist reviewers and reduce the time to merge your change.

LDAP still works:

Screen_Shot_2022-07-14_at_4.48.48_PM

Started POST "/users/auth/ldapmain/callback" for 127.0.0.1 at 2022-07-14 16:48:51 +1200
Processing by Ldap::OmniauthCallbacksController#ldapmain as HTML
  Parameters: {"authenticity_token"=>"[FILTERED]", "username"=>"john", "password"=>"[FILTERED]"}

Redirected to http://127.0.0.1:3000/
Completed 302 Found in 118ms (ActiveRecord: 5.1ms | Elasticsearch: 0.0ms | Allocations: 117111)
Processing by Ldap::OmniauthCallbacksController#ldapalt as HTML
  Parameters: {"authenticity_token"=>"[FILTERED]", "username"=>"bob", "password"=>"[FILTERED]"}

Redirected to http://127.0.0.1:3000/
Completed 302 Found in 388ms (ActiveRecord: 10.4ms | Elasticsearch: 0.0ms | Allocations: 220491)

How to set up and validate locally

  1. Follow https://gitlab.com/gitlab-org/gitlab-development-kit/-/blob/main/doc/howto/ldap.md to validate LDAP login still works
    1. You may encounter an error because the .cache/ directory does not exist in GDK root while creating GDK creates .cache/gitlab-openldap_ldap-users-created. In this case, the workaround is to manually create that directory

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Thong Kuah

Merge request reports

Loading