spring-projects / spring-projects/spring-security

Providing support in the ACL to enable implementation of custom database support

Open
#13,548 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: waiting-for-triage type: enhancement
Dominant language
Java
Stars
9.6k
Forks
6.3k
Avg merge
2d 11h
Merged PRs (30d)
52

Description

Expected Behavior

In JdbcMutableAclService add getters for the following attributes:

  • insertSid
  • selectClassPrimaryKey
  • selectSidPrimaryKey

Or implement standard identity query mechanism.

Current Behavior

There is no possibility to retrieve the values of the attributes in a subclass.

Context

The Spring Security ACL don't support H2 (#11231). In the JdbcMutableAclService there is a classIdentityQuery and sidIdentityQuery attributes that contain the following query: call identity(). The H2 don't support this. I don't know any select to retreive the generated id. I would like to create a subclass and override the createOrRetrieveClassPrimaryKey and createOrRetrieveSidPrimaryKey methods. In this methods I need the insertSid, selectClassPrimaryKey and selectSidPrimaryKey values.

Much better solution is to use a standard identity query mechanism:

KeyHolder keyHolder = new GeneratedKeyHolder();
this.jdbcOperations.update(connection -> {
    PreparedStatement ps =
            connection.prepareStatement(insertSid,
                    Statement.RETURN_GENERATED_KEYS);
    ps.setBoolean(1, sidIsPrincipal);
    ps.setString(2, sidName);
    return ps;
}, keyHolder
);

Assert.isTrue(TransactionSynchronizationManager.isSynchronizationActive(), "Transaction must be running");
return (Long) keyHolder.getKeys().get("id");

You find my solution here: https://github.com/vicziani/jtechlog-spring-security-acl/blob/master/src/main/java/jtechlog/acltutorial/H2JdbcMutableAclService.java

(I also replaced the deprecated queryForList method - using varargs.)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with JdbcMutableAclService, especially createOrRetrieveClassPrimaryKey and createOrRetrieveSidPrimaryKey, and inspect how insertSid, selectClassPrimaryKey, and selectSidPrimaryKey are used. Done means a subclass can support custom database identity handling, or the service uses a standard identity mechanism that works beyond the current call identity() queries.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
databases, security
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.