-
Notifications
You must be signed in to change notification settings - Fork 6k
Allow use of non-numeric (e.g. UUID) values for ObjectIdentity.getIdentifier() #4424
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
Allow use of non-numeric (e.g. UUID) values for ObjectIdentity.getIdentifier() #4424
Conversation
…ntifier() Prior to this commit, the ObjectIdentity id had to be a number. This commit allows for domain objects to use UUIDs as their identifier. The fully qualified class name of the identifier type can be specified in the acl_object_identity table and a ConversionService can be provided to BasicLookupStrategy to convert from String to the actual identifier type. There are the following other changes: - BasicLookupStrategy has a new property, aclClassIdSupported, which is used to retrieve the new column from the database. This preserves backwards-compatibility, as it is false by default. - JdbcMutableAclService has the same property, aclClassIdSupported, which is needed to modify the insert statement to write to the new column. Defaults to false for backwards-compatibility. - Tests have been updated to verify both the existing functionality for backwards-compatibility and the new functionality. Fixes SEC-972
Any idea if / when this will be implemented |
Merged changes from master that fixed the broken tests, all tests pass locally now |
I tested this PR and it works for me |
👍 |
Hello @pwheel , there is still one class needs to be modified, it is JdbcAclService. If you look into its findChildren method (which is used by JdbcMutableAclService), you should see this And this is the obj_id per DEFAULT_SELECT_ACL_WITH_PARENT_SQL So because we are using Uuid this cast will cause a problem. |
Feedback from PR, the JdbcAclService.findChildren method would have been broken. As logic now needs to be in JdbcAclService & BasicLookupStrategy, I've refactored the logic into an AclClassIdUtils class. Also realised that I'd missed this as JdbcMutableAclServiceTestsWithAclClassId was not covering all scenarios; I needed to create UUID versions of the ObjectIdentity instances to trigger the new behaviour.
Thanks @truongvanluan good catch. I updated some of the tests to cover this & confirm was a problem. I've done a little bit of refactoring as needed to use some of the logic in to classes now, so created a utility class AclClassIdUtils to handle it. I had to merge in master as had compile time errors due to Spring 5 snapshot dependencies, & had to do some updates for checkstyle & Apache licence too. Commit history isn't so clean now… I can squash / rebase again but wanted to push this up for feedback first. Hope that's alright! |
That's awesome, thanks @rwinch! |
Hi thanks for this, been waiting a while for this to be implemented so been keen to try it out... I've added However, I'm still getting an error in The offending method in Thanks |
Hi @graeme-dougal, yes you do. If you take a look at the test setup here that should hopefully answer your question - spring-security/acl/src/test/resources/jdbcMutableAclServiceTestsWithAclClass-context.xml Line 9 in 63e2db7
Cheers, |
Hi Paul Thanks for response. I'm using java config rather than xml config. My issue with wiring in I'd like to do the following but this won't compile due to the class not being public.
` Thanks |
Ah, yeah, got it, doh. I refactored this a couple of times and originally thought this class would be internal. It should be public now, for sure. Raised #4814 will fix this week |
Hi, i still have the issue to inject a My problem:
My questions:
|
This PR fixes #1224.
I discussed the general idea for this change over a year ago with @rwinch on gitter and shared pwheel@f388281#comments with him.
This took a while to get ready for a PR as when I got round to writing the tests properly, there was a problem with how HSQLDB was handling converting UUID to varchar so I had to submit a fix for that which came out in HSQLDB 2.4.0 earlier this year.
The change allows for the fully qualified class name of the ObjectIdentity identifier type to be specified in the acl_class table and a ConversionService can be provided to BasicLookupStrategy to convert from String to the actual identifier type.
There are the following other changes:
BasicLookupStrategy has a new property, aclClassIdSupported, which
is used to retrieve the new column from the database. This preserves
backwards-compatibility, as it is false by default.
JdbcMutableAclService has the same property, aclClassIdSupported,
which is needed to modify the insert statement to write to the
new column. Defaults to false for backwards-compatibility.
Tests have been updated to verify both the existing functionality
for backwards-compatibility and the new functionality.
Other things to call out:
I haven't updated the documentation; I can do that but wanted feedback first as it may result in changes.
I've changed the default schemas to use varchar for acl_object_identity.object_id_identity column, but I haven't added the new acl_class.class_id_type column by default. That seems a bit inconsistent in retrospect but again appreciate your feedback here.
Master isn't building atm (fails with sample.HelloWebfluxApplicationTests on my machine at least) but the tests for the acl module pass. Apologies for submitting in this state, I wanted to kick-start the process.
Cheers,
Paul