I created this project using Grails 2.3.3 and added mongoDB GORM Plugin and Spring Security Core plugin to it. I followed this post spring-security-and-mongodb to make it work, I can see the user and role in mongodb collection, but when I enter username and password the application doesn't authenticate against it, or maybe there is something broken somewhere that says the authentication failed. I attached the project zip file here, can someone look at it and see if I mis-configured something that makes it not-working.
2 Answers
I used your attached application and the blog post you referenced to create a working application. See http://burtbeckwith.com/blog/?p=1992 for usage information and https://github.com/burtbeckwith/mongoSpringSecurity for the code.
In your BootStrap.groovy file you are saving Role and User objects but you also need to create an association between User and Role using UserRole object.
-
But I have the Authority embedded in user, right ? Can you explain how to do that ? Maybe paste the code you have in mind. Thanks– AlexConDec 1, 2013 at 16:35
-
I added the following code but it still doesn't authenticate. Did you manage to make it work ? "UserRole.create user, userRole, true"– AlexConDec 1, 2013 at 16:45
-
I tried the code you have in your github the mongoDB Blog, it has the same problem. Do you have a simple project that uses Spring Security and MongoDB at the same time and works ?– AlexConDec 2, 2013 at 0:07
-
Blog code that I have on github is running fine on heroku, you can clone the code in your local machine and try out. By the way as Burt mentioned above version 2 of Spring Security address issues which makes it work out of the box with MongoDB. Dec 2, 2013 at 11:21