Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
KEYCLOAK-1187 DB migration support for oauth/application to client
- Loading branch information
Showing
20 changed files
with
131 additions
and
153 deletions.
There are no files selected for viewing
84 changes: 0 additions & 84 deletions
84
...g/keycloak/connections/jpa/updater/liquibase/custom/SetConsentRequiredOnOAuthClients.java
This file was deleted.
Oops, something went wrong.
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
51 changes: 51 additions & 0 deletions
51
...te/src/main/java/org/keycloak/connections/mongo/updater/impl/updates/Update1_2_0_RC1.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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,51 @@ | |||
package org.keycloak.connections.mongo.updater.impl.updates; | |||
|
|||
import com.mongodb.BasicDBObject; | |||
import com.mongodb.DBCollection; | |||
import com.mongodb.DBCursor; | |||
import org.keycloak.models.KeycloakSession; | |||
|
|||
/** | |||
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a> | |||
*/ | |||
public class Update1_2_0_RC1 extends Update { | |||
|
|||
@Override | |||
public String getId() { | |||
return "1.2.0.RC1"; | |||
} | |||
|
|||
@Override | |||
public void update(KeycloakSession session) { | |||
convertApplicationsToClients(); | |||
convertOAuthClientsToClients(); | |||
} | |||
|
|||
private void convertApplicationsToClients() { | |||
DBCollection applications = db.getCollection("applications"); | |||
applications.update(new BasicDBObject(), new BasicDBObject("$set", new BasicDBObject("consentRequired", false)), false, true); | |||
applications.update(new BasicDBObject(), new BasicDBObject("$rename", new BasicDBObject("name", "clientId")), false, true); | |||
renameCollection("applications", "clients"); | |||
log.debugv("Converted applications to clients"); | |||
|
|||
DBCollection roles = db.getCollection("roles"); | |||
roles.update(new BasicDBObject(), new BasicDBObject("$rename", new BasicDBObject("applicationId", "clientId")), false, true); | |||
log.debugv("Renamed roles.applicationId to roles.clientId"); | |||
} | |||
|
|||
private void convertOAuthClientsToClients() { | |||
DBCollection clients = db.getCollection("clients"); | |||
DBCollection oauthClients = db.getCollection("oauthClients"); | |||
oauthClients.update(new BasicDBObject(), new BasicDBObject("$rename", new BasicDBObject("name", "clientId")), false, true); | |||
oauthClients.update(new BasicDBObject(), new BasicDBObject("$set", new BasicDBObject("consentRequired", true)), false, true); | |||
|
|||
DBCursor curs = oauthClients.find(); | |||
while (curs.hasNext()) { | |||
clients.insert(curs.next()); | |||
} | |||
|
|||
oauthClients.drop(); | |||
log.debugv("Converted oauthClients to clients"); | |||
} | |||
|
|||
} |
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.