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

Introduce Spring Security ACL (Access Control Lists) #36

Merged
merged 27 commits into from
Jul 1, 2014

Conversation

buehner
Copy link
Member

@buehner buehner commented Jun 27, 2014

As described in #35, this PR introduces Spring Security ACLs.

The implementations are mainly based on this tutorial (under impact of this tutorial)

Here is a short list of features, that would be introduced by this PR:

  • Automatic creation of a H2-based ACL-database (separate from the SHOGun2 database)
  • (ACL-)Secured methods of the AbstractCrudService
  • Interception of the (secured) methods of the AbstractCrudService by using AOP/AspectJ in a custom AclManagement-aspect-class to create/update/delete entries in the ACL database. (This part has just been prepared and needs to be fully implemented.)
  • Full adaption of the webapp archetype to use/demonstrate the ACL mechanism.

Most parts of this PR are a proof of concept, which means that still some coding has to be done (especially to save/update/delete the ACL entries). But as it is working: Try the webapp archetype and feel free to merge.

The added SQL script works for H2 and Postgres. It will be executed on startup as configured in the context-init.xml. This way it is ensured that the ACL database exists on after starting up the system.
The SHOGun2 authentication provider will now request a user from the database. The accountName of the user will be used as the principal in the authentication object.
For the demonstration of the ACL usage, some access control entries were made.
The AOP libraries will be used to intercept the saveOrUpdate and delete method of the AbstractCrudService in a next step.
By using this aspect class, the saveOrUpdate and delete methods of the AbstractCrudService will be intercepted (if the webapp is configured properly).
Enabled AOP/AspectJ in archetype and use the SHOGun2 AclManagement aspect, which was commited in the previous step.
@coveralls
Copy link

Coverage Status

Coverage decreased (-18.48%) when pulling ed9e1c2 on buehner:security-acl into 7cea63c on terrestris:master.

This SidRetrievalStrategy behaves like the default (SidRetrievalStrategyImpl), but checks if the principal of the current authentication object is a SHOGun2 user object. In such cases, the accountName of the SHOGun2 user will be used to build a PrincipalSid.
The Shogun2AuthenticationProvider will now pass the SHOGun2-User object as the principal of the authentication. The authentication provider has also been enhanced by checking if the SHOGun2 user object actually has grantedAuthorities. (The last point is a preparation as we do not yet retrieve the authorities from our SHOGun2 database).
@buehner
Copy link
Member Author

buehner commented Jun 30, 2014

I added some more commits:

  • The Shogun2AuthenticationProvider will now use/pass an instance of the SHOGun2 User model as the principal of the current authentication.
  • To make this work with the ACL mechanism, I added a custom implementation of SidRetrievalStrategy (Shogun2SidRetrievalStrategyImpl), which takes care if the principal of the current authentication object is an instance of the SHOGun2 User model. If the principal is not a SHOGun2 user, the imlementation behaves like the default Spring/ACL implementation (SidRetrievalStrategyImpl)

@buehner
Copy link
Member Author

buehner commented Jun 30, 2014

As the test failed, i made it work again...
(One should not develop with -Dmaven.test.skip=true)

@coveralls
Copy link

Coverage Status

Coverage decreased (-22.01%) when pulling 92a08ad on buehner:security-acl into 7cea63c on terrestris:master.

The customized ACL service takes care if the principal object of the current authentication is a SHOGun2 User object.
@buehner
Copy link
Member Author

buehner commented Jun 30, 2014

I made some more enhancements:

  • Added a Util class that can be easily used with SHOGun2-objects to add/delete ACL permissions
  • Using a customized ACL service, which takes care if the principal of the authentication is a SHOGun2 user object

@marcjansen
Copy link
Member

Hey @buehner,

great work! I am sure this is the right direction for SHOGun2 wrt security.

Please merge.

Additionally it'd be great if you could turn the remaining TODOs into Github issues. If possible a tutorial on how to use the security mechanism would be great.

Thanks!

buehner added a commit that referenced this pull request Jul 1, 2014
Introduce Spring Security ACL (Access Control Lists)
@buehner buehner merged commit 96c2d1d into terrestris:master Jul 1, 2014
@buehner buehner deleted the security-acl branch July 4, 2014 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants