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: handle invalid email address in auth-identity (#66022)
Edward Paget71f7cbc41b9f
diff --git a/resources/migrations/058_update_migrations.yaml b/resources/migrations/058_update_migrations.yamlindex a2b6107b8dc..6c2fa1d4ee3 100644--- a/resources/migrations/058_update_migrations.yaml+++ b/resources/migrations/058_update_migrations.yaml@@ -361,7 +361,78 @@ databaseChangeLog:constraintName: fk_auth_identity_core_user_id- changeSet:- id: v58.2025-11-12T00:00:03+ id: v58.2025-11-12T00:00:07+ author: edpaget+ comment: Add auth_identity_id columns to core_session table+ changes:+ - addColumn:+ tableName: core_session+ columns:+ - column:+ name: auth_identity_id+ type: int+ remarks: Foreign key to auth_identity - tracks which auth method was used for login+ constraints:+ nullable: true+ rollback:+ - dropColumn:+ tableName: core_session+ columnName: auth_identity_id++ - changeSet:+ id: v58.2025-11-12T00:00:08+ author: edpaget+ comment: Add expires_at columns to core_session table+ changes:+ - addColumn:+ tableName: core_session+ columns:+ - column:+ name: expires_at+ type: ${timestamp_type}+ remarks: Timestamp when this session expires (from auth_identity or calculated)+ constraints:+ nullable: true+ rollback:+ - dropColumn:+ tableName: core_session+ columnName: expires_at++ - changeSet:+ id: v58.2025-11-12T00:00:09+ author: edpaget+ comment: Add index on core_session.auth_identity_id+ changes:+ - createIndex:+ tableName: core_session+ indexName: idx_core_session_auth_identity_id+ columns:+ - column:+ name: auth_identity_id+ rollback:+ - dropIndex:+ tableName: core_session+ indexName: idx_core_session_auth_identity_id++ - changeSet:+ id: v58.2025-11-12T00:00:10+ author: edpaget+ comment: Add foreign key constraint from core_session to auth_identity+ changes:+ - addForeignKeyConstraint:+ baseTableName: core_session+ baseColumnNames: auth_identity_id+ constraintName: fk_session_auth_identity+ referencedTableName: auth_identity+ referencedColumnNames: id+ onDelete: CASCADE+ rollback:+ - dropForeignKeyConstraint:+ baseTableName: core_session+ constraintName: fk_session_auth_identity++ - changeSet:+ id: v58.2025-11-12T00:00:11author: edpagetcomment: Migrate password authentication to auth_identity tablechanges:@@ -372,7 +443,7 @@ databaseChangeLog:SELECTid,'password',- email,+ LEFT(email, 255),json_build_object('password_hash', password, 'password_salt', password_salt)::text,NULL,COALESCE(date_joined, now()),@@ -387,7 +458,7 @@ databaseChangeLog:SELECTid,'password',- email,+ LEFT(email, 255),json_object('password_hash', password, 'password_salt', password_salt),NULL,COALESCE(date_joined, now()),@@ -401,7 +472,7 @@ databaseChangeLog:SELECTid,'password',- email,+ LEFT(email, 255),CONCAT('{"password_hash":"', password, '","password_salt":"', password_salt, '"}'),NULL,COALESCE(date_joined, now()),@@ -416,7 +487,7 @@ databaseChangeLog:- sql: DELETE FROM auth_identity WHERE provider = 'password';- changeSet:- id: v58.2025-11-12T00:00:04+ id: v58.2025-11-12T00:00:12author: edpagetcomment: Migrate LDAP authentication to auth_identity tablechanges:@@ -427,7 +498,7 @@ databaseChangeLog:SELECTid,'ldap',- email,+ LEFT(email, 255),NULL,json_build_object('login_attributes', login_attributes)::text,COALESCE(date_joined, now()),@@ -442,7 +513,7 @@ databaseChangeLog:SELECTid,'ldap',- email,+ LEFT(email, 255),NULL,json_object('login_attributes', login_attributes),COALESCE(date_joined, now()),@@ -456,7 +527,7 @@ databaseChangeLog:SELECTid,'ldap',- email,+ LEFT(email, 255),NULL,CONCAT('{"login_attributes":', COALESCE(login_attributes, 'null'), '}'),COALESCE(date_joined, now()),@@ -471,7 +542,7 @@ databaseChangeLog:- sql: DELETE FROM auth_identity WHERE provider = 'ldap';- changeSet:- id: v58.2025-11-12T00:00:05+ id: v58.2025-11-12T00:00:13author: edpagetcomment: Migrate Google SSO authentication to auth_identity tablechanges:@@ -482,7 +553,7 @@ databaseChangeLog:SELECTid,'google',- email,+ LEFT(email, 255),NULL,json_build_object('sso_source', 'google', 'login_attributes', login_attributes)::text,COALESCE(date_joined, now()),@@ -497,7 +568,7 @@ databaseChangeLog:SELECTid,'google',- email,+ LEFT(email, 255),NULL,json_object('sso_source', 'google', 'login_attributes', login_attributes),COALESCE(date_joined, now()),@@ -511,7 +582,7 @@ databaseChangeLog:SELECTid,'google',- email,+ LEFT(email, 255),NULL,CONCAT('{"sso_source":"google","login_attributes":', COALESCE(login_attributes, 'null'), '}'),COALESCE(date_joined, now()),@@ -526,7 +597,7 @@ databaseChangeLog:- sql: DELETE FROM auth_identity WHERE provider = 'google';- changeSet:- id: v58.2025-11-12T00:00:06+ id: v58.2025-11-12T00:00:14author: edpagetcomment: Migrate SAML and JWT authentication to auth_identity tablechanges:@@ -537,7 +608,7 @@ databaseChangeLog:SELECTid,sso_source,- email,+ LEFT(email, 255),NULL,json_build_object('sso_source', sso_source, 'login_attributes', login_attributes, 'jwt_attributes', jwt_attributes)::text,COALESCE(date_joined, now()),@@ -552,7 +623,7 @@ databaseChangeLog:SELECTid,sso_source,- email,+ LEFT(email, 255),NULL,json_object('sso_source', sso_source, 'login_attributes', login_attributes, 'jwt_attributes', jwt_attributes),COALESCE(date_joined, now()),@@ -566,7 +637,7 @@ databaseChangeLog:SELECTid,sso_source,- email,+ LEFT(email, 255),NULL,CONCAT('{"sso_source":"', sso_source, '","login_attributes":', COALESCE(login_attributes, 'null'), ',"jwt_attributes":', COALESCE(jwt_attributes, 'null'), '}'),COALESCE(date_joined, now()),@@ -580,77 +651,6 @@ databaseChangeLog:rollback:- sql: DELETE FROM auth_identity WHERE provider IN ('saml', 'jwt');- - changeSet:- id: v58.2025-11-12T00:00:07- author: edpaget- comment: Add auth_identity_id columns to core_session table- changes:- - addColumn:- tableName: core_session- columns:- - column:- name: auth_identity_id- type: int- remarks: Foreign key to auth_identity - tracks which auth method was used for login- constraints:- nullable: true- rollback:- - dropColumn:- tableName: core_session- columnName: auth_identity_id-- - changeSet:- id: v58.2025-11-12T00:00:08- author: edpaget- comment: Add expires_at columns to core_session table- changes:- - addColumn:- tableName: core_session- columns:- - column:- name: expires_at- type: ${timestamp_type}- remarks: Timestamp when this session expires (from auth_identity or calculated)- constraints:- nullable: true- rollback:- - dropColumn:- tableName: core_session- columnName: expires_at-- - changeSet:- id: v58.2025-11-12T00:00:09- author: edpaget- comment: Add index on core_session.auth_identity_id- changes:- - createIndex:- tableName: core_session- indexName: idx_core_session_auth_identity_id- columns:- - column:- name: auth_identity_id- rollback:- - dropIndex:- tableName: core_session- indexName: idx_core_session_auth_identity_id-- - changeSet:- id: v58.2025-11-12T00:00:10- author: edpaget- comment: Add foreign key constraint from core_session to auth_identity- changes:- - addForeignKeyConstraint:- baseTableName: core_session- baseColumnNames: auth_identity_id- constraintName: fk_session_auth_identity- referencedTableName: auth_identity- referencedColumnNames: id- onDelete: CASCADE- rollback:- - dropForeignKeyConstraint:- baseTableName: core_session- constraintName: fk_session_auth_identity-# >>>>>>>>>> DO NOT ADD NEW MIGRATIONS BELOW THIS LINE! ADD THEM ABOVE <<<<<<<<<<########################################################################################################################diff --git a/test/metabase/app_db/schema_migrations_test.clj b/test/metabase/app_db/schema_migrations_test.cljindex 7f2e78acb9e..348ccb03f69 100644--- a/test/metabase/app_db/schema_migrations_test.clj+++ b/test/metabase/app_db/schema_migrations_test.clj@@ -2764,7 +2764,7 @@(deftest migrate-password-auth-test(testing "Migration v58.2025-11-04T23:10:03: Migrate password authentication to auth_identity table"- (impl/test-migrations ["v58.2025-11-04T23:09:49" "v58.2025-11-12T00:00:03"] [migrate!]+ (impl/test-migrations ["v58.2025-11-04T23:09:49" "v58.2025-11-12T00:00:11"] [migrate!];; Insert users with password auth before migration(t2/query-one {:insert-into :core_user:values [{:first_name "Password"@@ -2792,7 +2792,7 @@(deftest migrate-ldap-auth-test-2(testing "Migration v58.2025-11-04T23:10:04: Migrate LDAP authentication to auth_identity table"- (impl/test-migrations ["v58.2025-11-04T23:09:49" "v58.2025-11-12T00:00:04"] [migrate!]+ (impl/test-migrations ["v58.2025-11-04T23:09:49" "v58.2025-11-12T00:00:12"] [migrate!];; Insert users with LDAP auth before migration (using sso_source='ldap' from current schema)(t2/query-one {:insert-into :core_user:values [{:first_name "LDAP"@@ -2819,7 +2819,7 @@(deftest migrate-google-sso-auth-test(testing "Migration v58.2025-11-04T23:10:05: Migrate Google SSO authentication to auth_identity table"- (impl/test-migrations ["v58.2025-11-04T23:09:49" "v58.2025-11-12T00:00:05"] [migrate!]+ (impl/test-migrations ["v58.2025-11-04T23:09:49" "v58.2025-11-12T00:00:13"] [migrate!];; Insert users with Google SSO before migration(t2/query-one {:insert-into :core_user:values [{:first_name "Google"@@ -2845,7 +2845,7 @@(deftest migrate-saml-jwt-auth-test(testing "Migration v58.2025-11-04T23:10:06: Migrate SAML and JWT authentication to auth_identity table"- (impl/test-migrations ["v58.2025-11-04T23:09:49" "v58.2025-11-12T00:00:06"] [migrate!]+ (impl/test-migrations ["v58.2025-11-04T23:09:49" "v58.2025-11-12T00:00:14"] [migrate!];; Insert users with SAML and JWT before migration(t2/query-one {:insert-into :core_user:values [{:first_name "SAML"