Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alias ID and Alias ZID for Identity Providers #2637

Merged
Merged
Show file tree
Hide file tree
Changes from 86 commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
01380bd
Add flyway migration script for adding "alias_id" and "alias_zid" col…
adrianhoelzl-sap Dec 6, 2023
b67d39c
Add aliasId and aliasZid properties to IdentityProvider class
adrianhoelzl-sap Dec 7, 2023
a0cfe80
Fix IdentityProviderEndpointDocs
adrianhoelzl-sap Dec 11, 2023
c9f4a21
Add migration scripts for MySQL and HSQL
adrianhoelzl-sap Dec 12, 2023
7d7aef5
Fix queries creating or modifying identity providers
adrianhoelzl-sap Dec 12, 2023
e150510
Fix optional constraints in IdP endpoint docs
adrianhoelzl-sap Dec 12, 2023
06a3081
Fix row mapper for update in JdbcIdentityProviderProvisioning
adrianhoelzl-sap Dec 12, 2023
b6dca9d
Fix field definitions for alias_id and alias_zid in IdentityProviderE…
adrianhoelzl-sap Dec 12, 2023
6a8ef06
Improve comments in JdbcIdentityProviderProvisioning
adrianhoelzl-sap Dec 13, 2023
6522e82
Add tests for IdP creation and update affecting alias properties
adrianhoelzl-sap Dec 18, 2023
9f19be9
Add logic for mirroring IdPs from/to custom zones
adrianhoelzl-sap Dec 18, 2023
d6da7c5
Use static import of StringUtils.hasText
adrianhoelzl-sap Dec 18, 2023
0c64c03
Add token format parameter to MockMvcUtils.getUserOAuthAccessTokenAut…
adrianhoelzl-sap Dec 18, 2023
edf2caa
Move tests regarding alias properties of IdP endpoints to separate class
adrianhoelzl-sap Dec 18, 2023
4081553
Revert changes to IdentityProviderEndpointsMockMvcTests
adrianhoelzl-sap Dec 18, 2023
cb3788d
Remove comment
adrianhoelzl-sap Dec 18, 2023
8aba009
Add tests for deletion operation
adrianhoelzl-sap Dec 20, 2023
4dd7c95
Consider mirrored IdPs in IdP status update endpoint
adrianhoelzl-sap Dec 20, 2023
12bd9a7
Fix unit tests
adrianhoelzl-sap Dec 20, 2023
86c2431
Add creation of new mirrored IdP if aliasId is set, but the reference…
adrianhoelzl-sap Dec 20, 2023
9ce3ebe
Fix IdentityProviderEndpointsAliasMockMvcTests
adrianhoelzl-sap Dec 20, 2023
94cd995
Simplify validation of alias properties
adrianhoelzl-sap Dec 20, 2023
1d2e9ae
Add tests for update status calls involving mirrored IdPs
adrianhoelzl-sap Dec 20, 2023
63472c4
Add tests for mirrored IdP being created if referenced, but not present
adrianhoelzl-sap Dec 20, 2023
bf5c42c
Add deletion of mirrored IdPs when Identity Zone is deleted
adrianhoelzl-sap Dec 20, 2023
d985b8f
Add test for mirrored IdPs being removed when zones are deleted
adrianhoelzl-sap Dec 21, 2023
05acd82
Add tests for transaction handling
adrianhoelzl-sap Dec 21, 2023
7cde84c
Add caching of access tokens in IdentityProviderEndpointsAliasMockMvc…
adrianhoelzl-sap Dec 21, 2023
9106d32
Fix Sonar finding
adrianhoelzl-sap Dec 21, 2023
d10465f
Fix Sonar code smells
adrianhoelzl-sap Dec 21, 2023
49e025f
Fix Sonar code smells
adrianhoelzl-sap Dec 21, 2023
cea991d
Add unit test for deletion of an IdP with a mirrored IdP
adrianhoelzl-sap Dec 21, 2023
7c1c146
Add unit test for invalid alias properties during IdP creation
adrianhoelzl-sap Dec 21, 2023
b2ec24d
Add unit test for invalid alias properties during update of already m…
adrianhoelzl-sap Dec 21, 2023
c239ebd
Change log level from error to warn
adrianhoelzl-sap Dec 21, 2023
f668888
Remove empty test case
adrianhoelzl-sap Dec 21, 2023
eae8d84
Fix Sonar security warning
adrianhoelzl-sap Dec 21, 2023
780208a
Add unit test for successful mirroring during IdP creation
adrianhoelzl-sap Dec 21, 2023
6e3d0a9
Fix Sonar security warning
adrianhoelzl-sap Dec 21, 2023
bc2a4a9
Add unit test for update status call
adrianhoelzl-sap Dec 22, 2023
0bfe02c
Add unit test for successful update of IdP with mirrored IdP
adrianhoelzl-sap Dec 22, 2023
4fe4b04
Add unit test for IdentityProvider.toString
adrianhoelzl-sap Dec 22, 2023
d329dcb
Add unit test for IdentityProvider.equals and hashCode
adrianhoelzl-sap Dec 22, 2023
f165928
Improve unit test for IdentityProvider.equals and hashCode
adrianhoelzl-sap Dec 22, 2023
2225d6b
Fix access token cache in IdentityProviderEndpointsAliasMockMvcTests
adrianhoelzl-sap Jan 5, 2024
2bf9edc
Make access token cache in IdentityProviderEndpointsAliasMockMvcTests…
adrianhoelzl-sap Jan 5, 2024
e215139
Ignore dangling references to no longer existing mirrored IdPs during…
adrianhoelzl-sap Jan 8, 2024
c4c97c6
Add identity zone ID field to IdentityProvider#toString
adrianhoelzl-sap Jan 10, 2024
7fda6f0
Use AlphanumericRandomValueStringGenerator in IdentityProviderEndpoin…
adrianhoelzl-sap Jan 10, 2024
8624058
Restrict mirroring to a fixed set of IdP types
adrianhoelzl-sap Jan 10, 2024
cc5ed2d
Remove obsolete unit test for update status of mirrored IdP
adrianhoelzl-sap Jan 10, 2024
10614d4
Replace transaction manager usage with Transactional annotation
adrianhoelzl-sap Jan 10, 2024
dbb3063
Fix unit tests
adrianhoelzl-sap Jan 10, 2024
625c63a
Revert "Replace transaction manager usage with Transactional annotation"
adrianhoelzl-sap Jan 11, 2024
23ffb2d
Fix position of redactSensitiveData in IdP create endpoint
adrianhoelzl-sap Jan 12, 2024
49c413e
Change wording from "mirrored" to "alias" in IdentityProviderEndpoint…
adrianhoelzl-sap Jan 12, 2024
82bec21
Change wording from "mirrored" to "alias" in IdentityProviderEndpoints
adrianhoelzl-sap Jan 12, 2024
83aaf86
Change wording from "mirrored" to "alias" in JdbcIdentityProviderProv…
adrianhoelzl-sap Jan 12, 2024
d75de2d
Change wording from "mirrored" to "alias" in IdentityProviderTest
adrianhoelzl-sap Jan 12, 2024
438e7c3
Change wording from "mirrored" to "alias" in IdentityProviderEndpoint…
adrianhoelzl-sap Jan 12, 2024
8bb24eb
Change wording from "mirrored" to "alias" in IdentityProviderEndpoint…
adrianhoelzl-sap Jan 12, 2024
15b4c0f
Improve endpoint documentation for identity provider alias properties
adrianhoelzl-sap Jan 12, 2024
b556f63
Improve endpoint documentation
adrianhoelzl-sap Jan 12, 2024
1b6798f
Fix endpoint docs of alias properties
adrianhoelzl-sap Jan 12, 2024
1e5cb69
Adjust description of update and create operation
adrianhoelzl-sap Jan 12, 2024
3d9f9d9
Fix endpoint docs again
adrianhoelzl-sap Jan 12, 2024
bd5e70c
Fix endpoint docs again
adrianhoelzl-sap Jan 12, 2024
6ba43cf
Clean up IdentityProviderEndpointDocs
adrianhoelzl-sap Jan 15, 2024
fb9f22b
Improve test for JdbcIdentityProviderProvisioning#deleteByIdentityZone
adrianhoelzl-sap Jan 15, 2024
b12464e
Improve response code if an IdP with the same origin key already exis…
adrianhoelzl-sap Jan 15, 2024
05969e1
Add unit tests for additional error cases of IdP endpoints
adrianhoelzl-sap Jan 15, 2024
276b79e
Add unit test for IdpAliasFailedException
adrianhoelzl-sap Jan 15, 2024
e17f89c
Add further unit tests
adrianhoelzl-sap Jan 15, 2024
0dd25b8
Merge branch 'develop' into feature/alias-id-and-alias-zid-for-identi…
adrianhoelzl-sap Jan 15, 2024
f438c59
Replace SAML IdPs with OIDC IdPs in IdentityProviderEndpointsAliasMoc…
adrianhoelzl-sap Jan 15, 2024
da2773e
Add tests about redacting relying party secret
adrianhoelzl-sap Jan 15, 2024
4e3a827
Add feature flag to uaa configuration
adrianhoelzl-sap Jan 24, 2024
34b141b
Add handling of feature flag to alias property validation
adrianhoelzl-sap Jan 24, 2024
ccdf1ab
Add handling of alias feature flag to IdP deletion
adrianhoelzl-sap Jan 24, 2024
9efb118
Add breaking of reference during create and update
adrianhoelzl-sap Jan 25, 2024
9957813
Add mock mvc tests for alias feature flag handling
adrianhoelzl-sap Jan 25, 2024
e21b862
Change log level back to error
adrianhoelzl-sap Jan 25, 2024
02a2583
Merge branch 'develop' into feature/alias-id-and-alias-zid-for-identi…
adrianhoelzl-sap Jan 25, 2024
5d48a9d
Adjust to new UaaTokenUtils.getClaims method
adrianhoelzl-sap Jan 25, 2024
a9698da
Merge branch 'feature/alias-id-and-alias-zid-for-identity-providers-f…
adrianhoelzl-sap Jan 25, 2024
af95978
Fix IdentityProviderEndpointsTest
adrianhoelzl-sap Jan 25, 2024
1e847bd
Move aliasEntitiesEnabled flag to login
adrianhoelzl-sap Jan 29, 2024
f12dc96
Add check for 'active' to IdentityProviderEndpointsAliasMockMvcTests#…
adrianhoelzl-sap Jan 29, 2024
179794e
Merge branch 'develop' into feature/alias-id-and-alias-zid-for-identi…
adrianhoelzl-sap Jan 29, 2024
a6ac355
Add unit tests for handling disabled alias entities feature
adrianhoelzl-sap Jan 29, 2024
9ea5973
Refactor
adrianhoelzl-sap Jan 29, 2024
291144c
Refactor
adrianhoelzl-sap Jan 29, 2024
e5f5791
Fix Sonar finding
adrianhoelzl-sap Feb 8, 2024
8919c63
Merge branch 'develop' into feature/alias-id-and-alias-zid-for-identi…
adrianhoelzl-sap Feb 8, 2024
9515079
Fix Flyway migration
adrianhoelzl-sap Feb 8, 2024
fafe033
Add unit tests about missing aliasId or missing alias IdP during brea…
adrianhoelzl-sap Feb 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ public class IdentityProvider<T extends AbstractIdentityProviderDefinition> {
public static final String FIELD_IDENTITY_ZONE_ID = "identityZoneId";
public static final String FIELD_CONFIG = "config";
public static final String FIELD_TYPE = "type";
public static final String FIELD_ALIAS_ID = "aliasId";
public static final String FIELD_ALIAS_ZID = "aliasZid";
//see deserializer at the bottom

private String id;
@NotNull
private String originKey;
Expand All @@ -71,7 +74,8 @@ public class IdentityProvider<T extends AbstractIdentityProviderDefinition> {
private Date lastModified = new Date();
private boolean active = true;
private String identityZoneId;

private String aliasId;
private String aliasZid;
public Date getCreated() {
return created;
}
Expand Down Expand Up @@ -197,6 +201,24 @@ public IdentityProvider setIdentityZoneId(String identityZoneId) {
return this;
}

public String getAliasId() {
return aliasId;
}

public IdentityProvider<T> setAliasId(String aliasId) {
this.aliasId = aliasId;
return this;
}

public String getAliasZid() {
return aliasZid;
}

public IdentityProvider<T> setAliasZid(String aliasZid) {
this.aliasZid = aliasZid;
return this;
}

@Override
public int hashCode() {
final int prime = 31;
Expand All @@ -208,6 +230,8 @@ public int hashCode() {
result = prime * result + ((name == null) ? 0 : name.hashCode());
result = prime * result + ((originKey == null) ? 0 : originKey.hashCode());
result = prime * result + ((type == null) ? 0 : type.hashCode());
result = prime * result + ((aliasId == null) ? 0 : aliasId.hashCode());
result = prime * result + ((aliasZid == null) ? 0 : aliasZid.hashCode());
adrianhoelzl-sap marked this conversation as resolved.
Show resolved Hide resolved
result = prime * result + version;
return result;
}
Expand Down Expand Up @@ -256,6 +280,20 @@ public boolean equals(Object obj) {
return false;
} else if (!type.equals(other.type))
return false;
if (aliasId == null) {
if (other.aliasId != null) {
return false;
}
} else if (!aliasId.equals(other.aliasId)) {
return false;
}
if (aliasZid == null) {
if (other.aliasZid != null) {
return false;
}
} else if (!aliasZid.equals(other.aliasZid)) {
return false;
}
if (version != other.version)
return false;
return true;
Expand All @@ -265,10 +303,33 @@ public boolean equals(Object obj) {
public String toString() {
final StringBuffer sb = new StringBuffer("IdentityProvider{");
sb.append("id='").append(id).append('\'');

sb.append(", identityZoneId=");
if (identityZoneId != null) {
sb.append('\'').append(identityZoneId).append('\'');
} else {
sb.append("null");
}

sb.append(", originKey='").append(originKey).append('\'');
sb.append(", name='").append(name).append('\'');
sb.append(", type='").append(type).append('\'');
sb.append(", active=").append(active);

adrianhoelzl-sap marked this conversation as resolved.
Show resolved Hide resolved
sb.append(", aliasId=");
if (aliasId != null) {
sb.append('\'').append(aliasId).append('\'');
} else {
sb.append("null");
}

sb.append(", aliasZid=");
if (aliasZid != null) {
sb.append('\'').append(aliasZid).append('\'');
} else {
sb.append("null");
}

sb.append('}');
return sb.toString();
}
Expand Down Expand Up @@ -304,6 +365,8 @@ public void serialize(IdentityProvider value, JsonGenerator gen, SerializerProvi
writeDateField(FIELD_LAST_MODIFIED, value.getLastModified(), gen);
gen.writeBooleanField(FIELD_ACTIVE, value.isActive());
gen.writeStringField(FIELD_IDENTITY_ZONE_ID, value.getIdentityZoneId());
gen.writeStringField(FIELD_ALIAS_ID, value.getAliasId());
gen.writeStringField(FIELD_ALIAS_ZID, value.getAliasZid());
gen.writeEndObject();
}

Expand Down Expand Up @@ -369,6 +432,8 @@ public IdentityProvider deserialize(JsonParser jp, DeserializationContext ctxt)
result.setLastModified(getNodeAsDate(node, FIELD_LAST_MODIFIED));
result.setActive(getNodeAsBoolean(node, FIELD_ACTIVE, true));
result.setIdentityZoneId(getNodeAsString(node, FIELD_IDENTITY_ZONE_ID, null));
result.setAliasId(getNodeAsString(node, FIELD_ALIAS_ID, null));
result.setAliasZid(getNodeAsString(node, FIELD_ALIAS_ZID, null));
return result;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
package org.cloudfoundry.identity.uaa.provider;

import static org.assertj.core.api.Assertions.assertThat;
import static org.cloudfoundry.identity.uaa.constants.OriginKeys.UAA;

import org.junit.jupiter.api.Test;

class IdentityProviderTest {

@Test
void testToString_ShouldContainAliasProperties() {
final IdentityProvider<OIDCIdentityProviderDefinition> idp = new IdentityProvider<>();
idp.setId("12345");
idp.setName("some-name");
idp.setOriginKey("some-origin");
idp.setAliasZid("custom-zone");
idp.setAliasId("id-of-alias-idp");
idp.setActive(true);
idp.setIdentityZoneId(UAA);
final OIDCIdentityProviderDefinition config = new OIDCIdentityProviderDefinition();
config.setIssuer("issuer");
idp.setConfig(config);

assertThat(idp.getAliasId()).isEqualTo("id-of-alias-idp");
assertThat(idp.getAliasZid()).isEqualTo("custom-zone");
assertThat(idp).hasToString("IdentityProvider{id='12345', identityZoneId='uaa', originKey='some-origin', name='some-name', type='oidc1.0', active=true, aliasId='id-of-alias-idp', aliasZid='custom-zone'}");
}

@Test
void testToString_AliasPropertiesAndIdzIdNull() {
final IdentityProvider<OIDCIdentityProviderDefinition> idp = new IdentityProvider<>();
idp.setId("12345");
idp.setName("some-name");
idp.setOriginKey("some-origin");
idp.setAliasZid(null);
idp.setAliasId(null);
idp.setActive(true);
idp.setIdentityZoneId(null);
final OIDCIdentityProviderDefinition config = new OIDCIdentityProviderDefinition();
config.setIssuer("issuer");
idp.setConfig(config);

assertThat(idp).hasToString("IdentityProvider{id='12345', identityZoneId=null, originKey='some-origin', name='some-name', type='oidc1.0', active=true, aliasId=null, aliasZid=null}");
}

@Test
void testEqualsAndHashCode() {
final String customZoneId = "custom-zone";
final String aliasIdpId = "id-of-alias-idp";

final IdentityProvider<OIDCIdentityProviderDefinition> idp1 = new IdentityProvider<>();
idp1.setId("12345");
idp1.setName("some-name");
idp1.setOriginKey("some-origin");
idp1.setAliasZid(customZoneId);
idp1.setAliasId(aliasIdpId);
idp1.setActive(true);
idp1.setIdentityZoneId(UAA);
final OIDCIdentityProviderDefinition config1 = new OIDCIdentityProviderDefinition();
config1.setIssuer("issuer");
idp1.setConfig(config1);

final IdentityProvider<OIDCIdentityProviderDefinition> idp2 = new IdentityProvider<>();
idp2.setId("12345");
idp2.setName("some-name");
idp2.setOriginKey("some-origin");
idp2.setAliasZid(customZoneId);
idp2.setAliasId(aliasIdpId);
idp2.setActive(true);
idp2.setIdentityZoneId(UAA);
final OIDCIdentityProviderDefinition config2 = new OIDCIdentityProviderDefinition();
config2.setIssuer("issuer");
idp2.setConfig(config2);

idp2.setCreated(idp1.getCreated());
idp2.setLastModified(idp1.getLastModified());

// initially, the tow IdPs should be equal
assertThat(idp1.equals(idp2)).isTrue();
assertThat(idp1).hasSameHashCodeAs(idp2);

// remove aliasZid
idp2.setAliasZid(null);
assertThat(idp1.equals(idp2)).isFalse();
assertThat(idp2.equals(idp1)).isFalse();
idp2.setAliasZid(customZoneId);

// remove aliasId
idp2.setAliasId(null);
assertThat(idp1.equals(idp2)).isFalse();
assertThat(idp2.equals(idp1)).isFalse();
}

}
Loading
Loading