The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
fix: jwt auth doesn't wipe login_attributes (#61927)
Edward Pageteeb46a43f1e2
diff --git a/enterprise/backend/src/metabase_enterprise/sso/integrations/jwt.clj b/enterprise/backend/src/metabase_enterprise/sso/integrations/jwt.cljindex 40eb08db243..fb37e41ac24 100644--- a/enterprise/backend/src/metabase_enterprise/sso/integrations/jwt.clj+++ b/enterprise/backend/src/metabase_enterprise/sso/integrations/jwt.clj@@ -32,7 +32,6 @@:last_name last-name:email email:sso_source :jwt- :login_attributes {}:jwt_attributes user-attributes}](or (sso-utils/fetch-and-update-login-attributes! user (sso-settings/jwt-user-provisioning-enabled?))(sso-utils/check-user-provisioning :jwt)diff --git a/enterprise/backend/src/metabase_enterprise/sso/integrations/sso_utils.clj b/enterprise/backend/src/metabase_enterprise/sso/integrations/sso_utils.cljindex f3d751f7cb2..3bbbd6e2b5d 100644--- a/enterprise/backend/src/metabase_enterprise/sso/integrations/sso_utils.clj+++ b/enterprise/backend/src/metabase_enterprise/sso/integrations/sso_utils.clj@@ -29,7 +29,7 @@;; TODO - we should avoid hardcoding this to make it easier to add new integrations. Maybe look at something like;; the keys of `(methods sso/sso-get)`[:sso_source [:enum :saml :jwt]]- [:login_attributes [:maybe :map]]+ [:login_attributes {:optional true} [:maybe :map]][:jwt_attributes {:optional true} [:maybe :map]]])(defn- maybe-throw-user-provisioningdiff --git a/enterprise/backend/test/metabase_enterprise/sso/integrations/jwt_test.clj b/enterprise/backend/test/metabase_enterprise/sso/integrations/jwt_test.cljindex a4108be5f00..2e80f71bb7f 100644--- a/enterprise/backend/test/metabase_enterprise/sso/integrations/jwt_test.clj+++ b/enterprise/backend/test/metabase_enterprise/sso/integrations/jwt_test.clj@@ -530,7 +530,45 @@:first_name "New":last_name "User"}default-jwt-secret))]- (is (saml-test/successful-login? response))))))))+ (is (saml-test/successful-login? response))))))++ (testing "Existing user login attributes are not changed on subsequent logins"+ (with-jwt-default-setup!+ (with-users-with-email-deleted "[email protected]"+ ;; Create user with initial login attributes+ (let [response (client/client-real-response :get 302 "/auth/sso"+ {:request-options {:redirect-strategy :none}}+ :return_to default-redirect-uri+ :jwt+ (jwt/sign+ {:email "[email protected]"+ :first_name "Existing"+ :last_name "User"+ :department "Engineering"+ :role "Developer"}+ default-jwt-secret))]+ (is (saml-test/successful-login? response))+ (testing "initial login attributes are stored"+ (is (= nil+ (t2/select-one-fn :login_attributes :model/User :email "[email protected]")))))++ ;; Log in again with different attributes+ (let [response (client/client-real-response :get 302 "/auth/sso"+ {:request-options {:redirect-strategy :none}}+ :return_to default-redirect-uri+ :jwt+ (jwt/sign+ {:email "[email protected]"+ :first_name "Existing"+ :last_name "User"+ :department "Marketing"+ :role "Manager"+ :location "Remote"}+ default-jwt-secret))]+ (is (saml-test/successful-login? response))+ (testing "login attributes remain unchanged from initial login"+ (is (= nil+ (t2/select-one-fn :login_attributes :model/User :email "[email protected]"))))))))))(deftest login-update-account-test(testing "An existing user will be reactivated upon login"diff --git a/enterprise/frontend/src/metabase-enterprise/auth/components/SettingsJWTForm/SettingsJWTForm.tsx b/enterprise/frontend/src/metabase-enterprise/auth/components/SettingsJWTForm/SettingsJWTForm.tsxindex 7a1f6d76a65..b25175557e0 100644--- a/enterprise/frontend/src/metabase-enterprise/auth/components/SettingsJWTForm/SettingsJWTForm.tsx+++ b/enterprise/frontend/src/metabase-enterprise/auth/components/SettingsJWTForm/SettingsJWTForm.tsx@@ -178,6 +178,7 @@ const getFormValues = ("jwt-user-provisioning-enabled?","jwt-identity-provider-uri","jwt-shared-secret",+ "jwt-group-sync","jwt-attribute-email","jwt-attribute-firstname","jwt-attribute-lastname",