Skip to content

Commit

Permalink
Set DB case-insensitivity flag in SimpleSearchQueryConverter used in …
Browse files Browse the repository at this point in the history
…JdbcScimUserProvisioning.retrieveByScimFilterOnlyActive
  • Loading branch information
adrianhoelzl-sap authored and Tallicia committed Apr 30, 2024
1 parent 20f1a47 commit 38a2048
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ public Logger getLogger() {
private final JdbcIdentityZoneProvisioning jdbcIdentityZoneProvisioning;
private final IdentityZoneManager identityZoneManager;

private boolean useCaseInsensitiveQueries = false;

public JdbcScimUserProvisioning(
final JdbcTemplate jdbcTemplate,
final JdbcPagingListFactory pagingListFactory,
Expand All @@ -159,6 +161,10 @@ public void setTimeService(TimeService timeService) {
this.timeService = timeService;
}

public void setUseCaseInsensitiveQueries(final boolean useCaseInsensitiveQueries) {
this.useCaseInsensitiveQueries = useCaseInsensitiveQueries;
}

@Override
public ScimUser retrieve(String id, String zoneId) {
try {
Expand All @@ -185,7 +191,15 @@ public List<ScimUser> retrieveByScimFilterOnlyActive(
final boolean ascending,
final String zoneId
) {
/* We cannot reuse the query converter from the superclass here since the later query operates on both the
* "users" and the "identity_provider" table and they both have a column named "id". Since the SCIM filter might
* contain clauses on the "id" field, we must ensure that the "id" of the "users" table is used, which is done
* by attaching an AttributeNameMapper. */
final SimpleSearchQueryConverter queryConverter = new SimpleSearchQueryConverter();

// ensure that the generated query handles the case-insensitivity of the underlying DB correctly
queryConverter.setDbCaseInsensitive(useCaseInsensitiveQueries);

validateOrderBy(queryConverter.map(sortBy));

/* since the two tables used in the query ('users' and 'identity_provider') have columns with identical names,
Expand Down
1 change: 1 addition & 0 deletions uaa/src/main/webapp/WEB-INF/spring/scim-endpoints.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
<property name="deactivateOnDelete" value="${scim.delete.deactivate:false}"/>
<property name="usernamePattern" value="${scim.username_pattern:[\p{L}+0-9+\-_.@'!]+}"/>
<property name="timeService" ref="timeService"/>
<property name="useCaseInsensitiveQueries" ref="useCaseInsensitiveQueries"/>
<constructor-arg name="passwordEncoder" ref="nonCachingPasswordEncoder"/>
</bean>

Expand Down

0 comments on commit 38a2048

Please sign in to comment.