grails / grails-spring-security-acl

Apache License 2.0
33 stars 52 forks source link

ACL NotFoundException when objects exists in Database #33

Open DamsoftDevelopers opened 6 years ago

DamsoftDevelopers commented 6 years ago

Hello everyone,

He implemented the ACL and reviewed the example of Issue # 32, and after trying and testing I can not know what is going on with my code.

Implemented ACL in my project, in which I use Grails 3.3.2 and a MariaDB database

If we start the application and enter data, the data will be correctly registered in its corresponding ACL tables and in its corresponding domain class tables.

But, if we turn off the application and turn it on again, when we bring lists filtering them by ACL and these lists return more than one object, it returns the following exception:

Class org.springframework.security.acls.model.NotFoundException Message null Caused by Unable to find ACL information for object identity 'org.springframework.security.acls.domain.ObjectIdentityImpl[Type: com.sample.test.Proyecto; Identifier: 2]'

Indicating that you can not find that information in the ACL, but this is not true because it does exist.

What's going on? Can anybody help me?

@sdelamo Can you help me?

sdelamo commented 6 years ago

Can you upload a sample project?

DamsoftDevelopers commented 6 years ago

Hello @sdelamo

I have already located the focus of the problem.

I had run the command 's2-create-acl-domains' this generates the domain classes for

plugin.springsecurity.acl.AclClass
plugin.springsecurity.acl.AclEntry
plugin.springsecurity.acl.AclObjectIdentity
plugin.springsecurity.acl.AclSid

but with the difference that they are not exactly the same as those that the plugin has by default since the one corresponding to the plugin is:

@EqualsAndHashCode (includes = 'objectId', callSuper = true)
@ToString (excludes = 'version', includeNames = true, includeSuper = true)
class AclObjectIdentity extends AbstractAclObjectIdentity {

private static final long serialVersionUID = 1

Long objectId

static mapping = {
version false
aclClass column: 'object_id_class'
owner column: 'owner_sid'
parent column: 'parent_object'
objectId column: 'object_id_identity'
}

static constraints = {
objectId unique: 'aclClass'
}
}

and the generated one:

class AclObjectIdentity extends AbstractAclObjectIdentity {

 Long objectId

 @Override
 String toString () {
 "AclObjectIdentity id $ id, aclClass $ aclClass.className," +
 "objectId $ objectId, entriesInheriting $ entriesInheriting"
 }

 static mapping = {
 version false
 aclClass column: 'object_id_class'
 owner column: 'owner_sid'
 parent column: 'parent_object'
 objectId column: 'object_id_identity'
 }

 static constraints = {
 objectId unique: 'aclClass'
 }
 }

As the next piece of code was not present, it was what was giving the problems.


@EqualsAndHashCode (includes = 'objectId', callSuper = true)
@ToString (excludes = 'version', includeNames = true, includeSuper = true)

When you delete these generated classes everything works normally.

Looking at the example of contacts, I have seen another problem (Maybe you should create another issue?)

When taking the example of contacts, and configure it to persist the data with a database, for example MySQL, the transactionality is not working correctly, or some problem must be, since data persists in the table corresponding to the domain class but not in the ACL tables

You can see the problem in the following repository or modify the example of contacts yourself

https://github.com/DamsoftDevelopers/grails-contact-fail-transactional