using grails security model (acegi) outside of grails
I have an existing grails application that was developed using the older acegi security plugin. I would like to develop additional applications (non-grails) that开发者_Python百科 uses the same security model. I have two questions:
Can I use the Spring Security project to achieve this?
Can you provide an example of how I would authenticate?
Also, by 'security model' I really mean the existing database that has the users and roles.
Yes! the old acegi plugin is about spring security 2.x (new plugin is spring security 3.x). So be sure to download the right jar
as or code, be sure that your xml config for configuring match your database schema, for instance:
<authentication-provider>
<jdbc-user-service data-source-ref="dataSource"
users-by-username-query="SELECT U.username, U.password, U.accountEnabled AS 'enabled' FROM User U where U.username=?"
authorities-by-username-query="SELECT U.username, R.name as 'authority' FROM User U JOIN Authority A ON u.id = A.userId JOIN Role R ON R.id = A.roleId WHERE U.username=?"/>
</authentication-provider>
more info at http://java.dzone.com/tips/pathway-acegi-spring-security-
精彩评论