Spring Security Integration #7

Merged
merged 3 commits into from Feb 16, 2012

3 participants

@sronderos
Grail Multi-Tenant Plugins member

Would someone on the project team mind checking over these changes before they are commited to the main line?

I've tested the functionality as best I can, I'd like to know if anyone objects the the way that I've integrated Spring Secuirty. There is probably a lot of room for improvement on this script, so another question is how much more does it need before it can be released?

sronderos added some commits Jan 25, 2012
@sronderos sronderos Adding Spring Security Core integration via quickstart script d8edd40
@sronderos sronderos Completing Spring Secuirty install script
Fixed messaging
Added intro message when plugin is installed
Added messaging about editing Spring Security User
f6892a4
@kimble kimble commented on the diff Jan 27, 2012
.../SpringSecurityTenantResolverSkeleton.groovy.template
+import grails.plugin.multitenant.core.resolve.TenantResolver
+import grails.plugins.springsecurity.SpringSecurityService
+
+import javax.servlet.http.HttpServletRequest
+
+/**
+ * Spring Security Tenant Resolver
+ * Extracts the userTenantId
+ * @see http://multi-tenant.github.com/grails-multi-tenant-single-db/
+ */
+class ${tenantResolverClassName} implements TenantResolver {
+ SpringSecurityService springSecurityService
+
+ @Override
+ Integer resolve(HttpServletRequest request) throws TenantResolveException {
+ def user = springSecurityService.getCurrentUser()
@kimble
Grail Multi-Tenant Plugins member
kimble added a note Jan 27, 2012

Would user typically be an instance of a class implementing the Tenant interface?

@sronderos
Grail Multi-Tenant Plugins member

No, I figured that a user has one tenant but one tenant could have many users.
'user' in this case would be the user domain from Spring Security's perspective. I'll need to also add this part to the documentation, but how I planned for it to work is that the Spring Security user domain will need to have a userTenantId field added to it which matches the id of the Tenant implementation.

@kimble
Grail Multi-Tenant Plugins member
kimble added a note Jan 27, 2012

I see! Perhaps we should add an interface for classes related to a tenant? I know that it isn't very "groovy-ish", but personally I find that it makes code easier to read.

@sronderos
Grail Multi-Tenant Plugins member

I considered that as well, but if we go that far it seems like we start getting into an area where we should have a separate plugin. I don't really know how to do the annotation that would integrate with Spring Security without relying on spring-security-core at compile time.

@kimble
Grail Multi-Tenant Plugins member
kimble added a note Jan 28, 2012

That's a very fair point. Adding spring-security-core as a compile time dependency is not an option. Anyway, I look at those scripts as more of a help-me-get-started kinda thing then ready production code.

Feel free to merge changes whenever you feel like it. Oh, an old version has been published to grails.org by LucasTeixeira. You can probably get in touch with him for more information if you want to publish a new version to the grails plugin repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@kimble
Grail Multi-Tenant Plugins member

Looks great to me!

I've started in a new job so I'm not that invested in this plugin anymore, but after spending quite a bit of time working on the plugin it makes me very happy to see that someone is still working on it!

@lucastex
Grail Multi-Tenant Plugins member

Hi guys...

I'm already in contact with sronderos, we'll get this working.

[]s,

@lucastex lucastex merged commit c03d6be into multi-tenant:master Feb 16, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment