Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug/ch132025/split configs for broker and central login #16150

Merged

Conversation

amiedes
Copy link
Contributor

@amiedes amiedes commented Feb 10, 2021

@shortcut-integration
Copy link

@amiedes amiedes force-pushed the bug/ch132025/split-configs-for-broker-and-central-login branch from 18a0ed0 to 1027160 Compare February 10, 2021 16:28
@amiedes amiedes force-pushed the bug/ch132025/split-configs-for-broker-and-central-login branch from 1027160 to 0f658d5 Compare February 23, 2021 08:19
@amiedes
Copy link
Contributor Author

amiedes commented Feb 23, 2021

Staging acceptance ✅

CartoDB -> Central redirection enabled

ubuntu@ded-dynamic-1qa16uc:~$ grep cartodb_central_api www/production.cartodb.com/current/config/app_config.yml -A 2
-bash: fc: history specification out of range
  cartodb_central_api:
    host: "carto-staging.com"
    port: "443"

Regular user login (amiedes-testlogin-1)

Organization user login (amiedes-testlogin-1-org-admin)

CartoDB -> Central redirection disabled

ubuntu@ded-dynamic-1qa16uc:~$ grep cartodb_central_api www/production.cartodb.com/current/config/app_config.yml -A 2
  #cartodb_central_api:
    #host: "carto-staging.com"
    #port: "443"

sudo systemctl restart unicorn-cartodb

Regular user login (amiedes-testlogin-1)

Organization user login (amiedes-testlogin-1-org-admin)

@amiedes amiedes marked this pull request as ready for review February 23, 2021 13:24
@@ -12,7 +12,7 @@ class OauthApp < ActiveRecord::Base
has_many :oauth_app_users, inverse_of: :oauth_app, dependent: :destroy
has_many :oauth_app_organizations, inverse_of: :oauth_app, dependent: :destroy

validates :user, presence: true, if: -> { sync_with_central? || !central_enabled? }
validates :user, presence: true, if: -> { sync_with_central? || Cartodb::Central.api_sync_disabled? }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The process for migrating this was:

  1. Replace central_enabled? per Cartodb::Central.api_sync_enabled?
  2. Replace !central_enabled? per Cartodb::Central.api_sync_disabled?
  3. The central_enabled? method becomes unused, so it can be removed

@@ -344,9 +344,4 @@ def clean_password
self.crypted_password = ''
self.save
end

# INFO: state_machine needs guard methods to be instance methods
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe in a previous version of the gem, but not anymore. Removing the "alias" to avoid one additional level of indirection.

Copy link
Contributor

@rafatower rafatower left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

About my silly comments, I'd just ignore them and focus on updating with master (to get CI back), test & deploy for the sake of pragmatism. In the mid term there won't be any "old http client" so not worth it.

@@ -49,7 +49,7 @@ def new
elsif saml_authentication? && !user
# Automatically trigger SAML request on login view load -- could easily trigger this elsewhere
redirect_to(saml_service.authentication_request)
elsif central_enabled? && !@organization.try(:auth_enabled?)
elsif Cartodb::Central.login_redirection_enabled? && !@organization.try(:auth_enabled?)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

silly thing: can we take advantage to use the safe operator @organization&.auth_enabled? ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think it should be equivalent. Sometimes I'm more keen to refactorings that others 😆 🤷

@@ -213,7 +213,11 @@ def password_expired

respond_to do |format|
format.html do
url = central_enabled? && !@organization.try(:auth_enabled?) ? Cartodb::Central.new.login_url : login_url
url = if Cartodb::Central.login_redirection_enabled? && !@organization.try(:auth_enabled?)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here about safe operator

app/models/carto/helpers/user_commons.rb Show resolved Hide resolved

class <<self

alias login_redirection_enabled? api_sync_enabled?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@amiedes amiedes merged commit 88e5533 into master Feb 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants