Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Groups should be zone aware. This means that a group (displayName) has a zone ID. This commit also reverts the zonification of group_membership and external_group_mapping. The zone can be derived from group ID in both cases https://www.pivotaltracker.com/story/show/99737730 [#99737730]
- Loading branch information
Showing
41 changed files
with
796 additions
and
504 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
43 changes: 43 additions & 0 deletions
43
common/src/main/resources/org/cloudfoundry/identity/uaa/db/hsqldb/V2_5_1__Zonify_Groups.sql
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,43 @@ | |||
-- | |||
-- Cloud Foundry | |||
-- Copyright (c) [2015] Pivotal Software, Inc. All Rights Reserved. | |||
-- | |||
-- This product is licensed to you under the Apache License, Version 2.0 (the "License"). | |||
-- You may not use this product except in compliance with the License. | |||
-- | |||
-- This product includes a number of subcomponents with | |||
-- separate copyright notices and license terms. Your use of these | |||
-- subcomponents is subject to the terms and conditions of the | |||
-- subcomponent's license, as noted in the LICENSE file. | |||
-- | |||
|
|||
|
|||
-- add zone id to the groups table | |||
ALTER TABLE groups ADD COLUMN identity_zone_id varchar(36) DEFAULT 'uaa' NOT NULL ; | |||
ALTER TABLE groups DROP CONSTRAINT unique_uk_2; | |||
CREATE UNIQUE INDEX groups_unique_key ON groups (displayname,identity_zone_id); | |||
|
|||
-- remove zone id from the group_membership table - it is derived from group_id | |||
DROP INDEX group_membership_unique_key; | |||
ALTER TABLE group_membership DROP COLUMN identity_zone_id; | |||
CREATE UNIQUE INDEX group_membership_unique_key ON group_membership (member_id,group_id); | |||
|
|||
-- remove zone id from the external_grou_mapping table - it is derived from group_id | |||
DROP INDEX external_group_unique_key; | |||
ALTER TABLE external_group_mapping DROP COLUMN identity_zone_id; | |||
CREATE UNIQUE INDEX external_group_unique_key ON external_group_mapping (origin,external_group,group_id); | |||
|
|||
|
|||
-- ALTER TABLE group_membership DROP PRIMARY KEY; | |||
-- | |||
-- ALTER TABLE external_group_mapping ADD COLUMN identity_zone_id varchar(36); | |||
-- ALTER TABLE external_group_mapping ADD COLUMN origin varchar(36); | |||
-- ALTER TABLE external_group_mapping DROP PRIMARY KEY; | |||
-- | |||
-- UPDATE group_membership SET identity_zone_id = (SELECT identity_zone_id FROM users where users.id = group_membership.member_id); | |||
-- UPDATE group_membership SET identity_zone_id = (SELECT 'uaa' FROM groups where groups.id = group_membership.member_id); | |||
-- | |||
-- UPDATE external_group_mapping SET identity_zone_id = 'uaa', origin='ldap'; | |||
-- | |||
-- CREATE UNIQUE INDEX group_membership_unique_key ON group_membership (identity_zone_id,member_id,group_id); | |||
-- CREATE UNIQUE INDEX external_group_unique_key ON external_group_mapping (identity_zone_id,origin,external_group,group_id); |
42 changes: 42 additions & 0 deletions
42
common/src/main/resources/org/cloudfoundry/identity/uaa/db/mysql/V2_5_1__Zonify_Groups.sql
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,42 @@ | |||
-- | |||
-- Cloud Foundry | |||
-- Copyright (c) [2015] Pivotal Software, Inc. All Rights Reserved. | |||
-- | |||
-- This product is licensed to you under the Apache License, Version 2.0 (the "License"). | |||
-- You may not use this product except in compliance with the License. | |||
-- | |||
-- This product includes a number of subcomponents with | |||
-- separate copyright notices and license terms. Your use of these | |||
-- subcomponents is subject to the terms and conditions of the | |||
-- subcomponent's license, as noted in the LICENSE file. | |||
-- | |||
|
|||
-- add zone id to the groups table | |||
ALTER TABLE groups ADD COLUMN identity_zone_id varchar(36) DEFAULT 'uaa' NOT NULL; | |||
ALTER TABLE groups DROP INDEX unique_uk_2; | |||
ALTER TABLE groups ADD UNIQUE KEY groups_unique_key(displayname, identity_zone_id); | |||
|
|||
-- remove zone id from the group_membership table - it is derived from group_id | |||
ALTER TABLE group_membership DROP INDEX group_membership_unique_key; | |||
ALTER TABLE group_membership DROP COLUMN identity_zone_id; | |||
ALTER TABLE group_membership ADD UNIQUE KEY group_membership_unique_key(member_id,group_id); | |||
|
|||
-- remove zone id from the external_group_mapping table - it is derived from group_id | |||
ALTER TABLE external_group_mapping DROP INDEX external_group_unique_key; | |||
ALTER TABLE external_group_mapping DROP COLUMN identity_zone_id; | |||
ALTER TABLE external_group_mapping ADD UNIQUE KEY external_group_unique_key(origin,external_group,group_id); | |||
|
|||
|
|||
# ALTER TABLE group_membership DROP PRIMARY KEY; | |||
# | |||
# ALTER TABLE external_group_mapping ADD COLUMN identity_zone_id varchar(36); | |||
# ALTER TABLE external_group_mapping ADD COLUMN origin varchar(36); | |||
# ALTER TABLE external_group_mapping DROP PRIMARY KEY; | |||
# | |||
# UPDATE group_membership SET identity_zone_id = (SELECT identity_zone_id FROM users where users.id = group_membership.member_id); | |||
# UPDATE group_membership SET identity_zone_id = (SELECT 'uaa' FROM groups where groups.id = group_membership.member_id); | |||
# | |||
# UPDATE external_group_mapping SET identity_zone_id = 'uaa', origin='ldap'; | |||
# | |||
# ALTER TABLE group_membership ADD UNIQUE KEY group_membership_unique_key(identity_zone_id,member_id,group_id); | |||
# ALTER TABLE external_group_mapping ADD UNIQUE KEY external_group_unique_key(identity_zone_id,origin,external_group,group_id); |
39 changes: 39 additions & 0 deletions
39
.../src/main/resources/org/cloudfoundry/identity/uaa/db/postgresql/V2_5_1__Zonify_Groups.sql
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,39 @@ | |||
-- | |||
-- Cloud Foundry | |||
-- Copyright (c) [2015] Pivotal Software, Inc. All Rights Reserved. | |||
-- | |||
-- This product is licensed to you under the Apache License, Version 2.0 (the "License"). | |||
-- You may not use this product except in compliance with the License. | |||
-- | |||
-- This product includes a number of subcomponents with | |||
-- separate copyright notices and license terms. Your use of these | |||
-- subcomponents is subject to the terms and conditions of the | |||
-- subcomponent's license, as noted in the LICENSE file. | |||
-- | |||
-- add zone id to the groups table | |||
ALTER TABLE groups ADD COLUMN identity_zone_id varchar(36) DEFAULT 'uaa' NOT NULL ; | |||
ALTER TABLE groups DROP CONSTRAINT unique_uk_2; | |||
CREATE UNIQUE INDEX groups_unique_key ON groups (displayname,identity_zone_id); | |||
|
|||
-- remove zone id from the group_membership table - it is derived from group_id | |||
DROP INDEX group_membership_unique_key; | |||
ALTER TABLE group_membership DROP COLUMN identity_zone_id; | |||
CREATE UNIQUE INDEX group_membership_unique_key ON group_membership (member_id,group_id); | |||
|
|||
-- remove zone id from the external_grou_mapping table - it is derived from group_id | |||
DROP INDEX external_group_unique_key; | |||
ALTER TABLE external_group_mapping DROP COLUMN identity_zone_id; | |||
CREATE UNIQUE INDEX external_group_unique_key ON external_group_mapping (origin,external_group,group_id); | |||
|
|||
-- | |||
-- ALTER TABLE external_group_mapping ADD COLUMN identity_zone_id varchar(36); | |||
-- ALTER TABLE external_group_mapping ADD COLUMN origin varchar(36); | |||
-- ALTER TABLE external_group_mapping DROP CONSTRAINT external_group_mapping_pkey; | |||
-- | |||
-- UPDATE group_membership SET identity_zone_id = (SELECT identity_zone_id FROM users where users.id = group_membership.member_id); | |||
-- UPDATE group_membership SET identity_zone_id = (SELECT 'uaa' FROM groups where groups.id = group_membership.member_id); | |||
-- | |||
-- UPDATE external_group_mapping SET identity_zone_id = 'uaa', origin='ldap'; | |||
-- | |||
-- CREATE UNIQUE INDEX group_membership_unique_key ON group_membership (identity_zone_id,member_id,group_id); | |||
-- CREATE UNIQUE INDEX external_group_unique_key ON external_group_mapping (identity_zone_id,origin,external_group,group_id); |
62 changes: 62 additions & 0 deletions
62
common/src/test/java/org/cloudfoundry/identity/uaa/test/CreateDB.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,62 @@ | |||
/* | |||
* ***************************************************************************** | |||
* Cloud Foundry | |||
* Copyright (c) [2009-2015] Pivotal Software, Inc. All Rights Reserved. | |||
* This product is licensed to you under the Apache License, Version 2.0 (the "License"). | |||
* You may not use this product except in compliance with the License. | |||
* | |||
* This product includes a number of subcomponents with | |||
* separate copyright notices and license terms. Your use of these | |||
* subcomponents is subject to the terms and conditions of the | |||
* subcomponent's license, as noted in the LICENSE file. | |||
* ***************************************************************************** | |||
*/ | |||
|
|||
package org.cloudfoundry.identity.uaa.test; | |||
|
|||
|
|||
import org.junit.Ignore; | |||
import org.junit.Test; | |||
import org.junit.runner.RunWith; | |||
import org.junit.runners.Parameterized; | |||
import org.junit.runners.Parameterized.Parameters; | |||
import org.springframework.mock.env.MockEnvironment; | |||
import org.springframework.util.StringUtils; | |||
|
|||
import java.util.Arrays; | |||
import java.util.Collection; | |||
|
|||
@Ignore("This test is here to simply execute the Flyway create DB script for all databases. Used to aid in writing schema scripts") | |||
@RunWith(Parameterized.class) | |||
public class CreateDB extends JdbcTestBase { | |||
|
|||
private final String profile; | |||
|
|||
public CreateDB(String profile) { | |||
this.profile = profile; | |||
} | |||
|
|||
@Parameters | |||
public static Collection<Object[]> profiles() { | |||
return Arrays.asList(new Object[][]{ | |||
{"mysql,default"}, {"postgresql,default"}, {""}, | |||
}); | |||
} | |||
|
|||
@Override | |||
public void setUp() throws Exception { | |||
MockEnvironment environment = new MockEnvironment(); | |||
environment.setActiveProfiles(StringUtils.commaDelimitedListToStringArray(profile)); | |||
setUp(environment); | |||
} | |||
|
|||
@Test | |||
public void test() { | |||
System.out.println("DB Created:"+profile); | |||
} | |||
|
|||
@Override | |||
public void tearDown() throws Exception { | |||
//no op - no clean up | |||
} | |||
} |
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.