-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2488 from opencb/TASK-6494
TASK-6494 - Improve our current Password Policy for built-in authentication in OpenCGA
- Loading branch information
Showing
81 changed files
with
1,667 additions
and
1,020 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
..._4/catalog/FixStatusIndexesMigration.java → ..._4/catalog/FixStatusIndexesMigration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
..._5/storage/AddAllelesColumnToPhoenix.java → ..._5/storage/AddAllelesColumnToPhoenix.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...legalConcurrentFileLoadingsMigration.java → ...legalConcurrentFileLoadingsMigration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...rc/main/java/org/opencb/opencga/app/migrations/v3/v3_2_1/AddPasswordHistoryMigration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package org.opencb.opencga.app.migrations.v3.v3_2_1; | ||
|
||
import com.mongodb.client.model.Filters; | ||
import com.mongodb.client.model.Projections; | ||
import com.mongodb.client.model.UpdateOneModel; | ||
import org.bson.Document; | ||
import org.bson.conversions.Bson; | ||
import org.opencb.opencga.catalog.db.mongodb.MongoDBAdaptor; | ||
import org.opencb.opencga.catalog.db.mongodb.OrganizationMongoDBAdaptorFactory; | ||
import org.opencb.opencga.catalog.migration.Migration; | ||
import org.opencb.opencga.catalog.migration.MigrationTool; | ||
|
||
import java.util.Arrays; | ||
import java.util.Collections; | ||
|
||
import static org.opencb.opencga.catalog.db.mongodb.UserMongoDBAdaptor.*; | ||
|
||
@Migration(id = "add_archivePasswords_array", | ||
description = "Add password history #6494", version = "3.2.1", | ||
language = Migration.MigrationLanguage.JAVA, domain = Migration.MigrationDomain.CATALOG, date = 20240723) | ||
public class AddPasswordHistoryMigration extends MigrationTool { | ||
|
||
@Override | ||
protected void run() throws Exception { | ||
Bson query = Filters.exists(PRIVATE_PASSWORD_ARCHIVE, false); | ||
Bson projection = Projections.include(PRIVATE_PASSWORD); | ||
migrateCollection(Arrays.asList(OrganizationMongoDBAdaptorFactory.USER_COLLECTION, OrganizationMongoDBAdaptorFactory.DELETED_USER_COLLECTION), | ||
query, projection, (document, bulk) -> { | ||
String currentPassword = document.getString("_password"); | ||
|
||
Document passwordDoc = new Document() | ||
.append(HASH, currentPassword) | ||
.append(SALT, ""); | ||
Document privatePassword = new Document(); | ||
privatePassword.put(CURRENT, passwordDoc); | ||
privatePassword.put(ARCHIVE, Collections.singletonList(passwordDoc)); | ||
|
||
MongoDBAdaptor.UpdateDocument updateDocument = new MongoDBAdaptor.UpdateDocument(); | ||
updateDocument.getSet().put(PRIVATE_PASSWORD, privatePassword); | ||
|
||
bulk.add(new UpdateOneModel<>(Filters.eq("_id", document.get("_id")), updateDocument.toFinalUpdateDocument())); | ||
}); | ||
} | ||
|
||
} |
50 changes: 50 additions & 0 deletions
50
.../java/org/opencb/opencga/app/migrations/v3/v3_2_1/MoveUserAccountToInternalMigration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package org.opencb.opencga.app.migrations.v3.v3_2_1; | ||
|
||
import com.mongodb.client.model.Filters; | ||
import com.mongodb.client.model.Projections; | ||
import com.mongodb.client.model.UpdateOneModel; | ||
import org.bson.Document; | ||
import org.bson.conversions.Bson; | ||
import org.opencb.opencga.catalog.db.mongodb.MongoDBAdaptor; | ||
import org.opencb.opencga.catalog.db.mongodb.OrganizationMongoDBAdaptorFactory; | ||
import org.opencb.opencga.catalog.migration.Migration; | ||
import org.opencb.opencga.catalog.migration.MigrationTool; | ||
|
||
import java.util.Arrays; | ||
|
||
@Migration(id = "move_user_account_to_internal", | ||
description = "Move account to internal.account #6494", version = "3.2.1", | ||
language = Migration.MigrationLanguage.JAVA, domain = Migration.MigrationDomain.CATALOG, date = 20240723) | ||
public class MoveUserAccountToInternalMigration extends MigrationTool { | ||
|
||
@Override | ||
protected void run() throws Exception { | ||
Bson query = Filters.exists("account", true); | ||
Bson projection = Projections.include("internal", "account"); | ||
migrateCollection(Arrays.asList(OrganizationMongoDBAdaptorFactory.USER_COLLECTION, | ||
OrganizationMongoDBAdaptorFactory.DELETED_USER_COLLECTION), | ||
query, projection, (document, bulk) -> { | ||
MongoDBAdaptor.UpdateDocument updateDocument = new MongoDBAdaptor.UpdateDocument(); | ||
|
||
Document account = document.get("account", Document.class); | ||
Document internal = document.get("internal", Document.class); | ||
internal.put("account", account); | ||
|
||
updateDocument.getSet().put("modificationDate", internal.get("lastModified")); | ||
updateDocument.getSet().put("creationDate", account.get("creationDate")); | ||
account.remove("creationDate"); | ||
|
||
Document password = new Document() | ||
.append("expirationDate", null) | ||
.append("lastModified", internal.get("lastModified")); | ||
account.put("password", password); | ||
account.put("failedAttempts", internal.get("failedAttempts")); | ||
internal.remove("failedAttempts"); | ||
|
||
updateDocument.getSet().put("internal", internal); | ||
updateDocument.getUnset().add("account"); | ||
|
||
bulk.add(new UpdateOneModel<>(Filters.eq("_id", document.get("_id")), updateDocument.toFinalUpdateDocument())); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.