Skip to content

Instantly share code, notes, and snippets.

@rsato
Last active December 15, 2015 20:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rsato/5317349 to your computer and use it in GitHub Desktop.
Save rsato/5317349 to your computer and use it in GitHub Desktop.
[solved]Making Grails app with Twitter authentication, using "spring-security-twitter" is not work well...
# DevEnv
+ JDK 7 update 17
+ GGTS 3.2.0RELEASE
+ Grails 2.2.1
# Operations
1.Create Grails Project "test"
2. Add to BuildConfig.groovy
compile ":spring-security-core:1.2.7.3"
3. 'refresh-dependencies'
4. 's2-quickstart test Person Role'
5. Add to BuildConfig.groovy
compile ":spring-security-twitter:0.4.4"
6. 'refresh-dependencies'
7. 's2-init-twitter' and set Consumer Key and Secret
8. Add to grails-app/views/login/auth.gsp
<link rel="stylesheet" href="${resource(dir:'css',file:'twitter-auth.css')}" />
<twitterAuth:button/>
9. 'run-app'
10. Access http://localhost:8080/test/login/auth
11. Click "Sign in with Twitter" and authentication
12. Call-backed my app(login succeeded)
13. 'exit'
----
14. Move TwitterUser.groovy to "test" package(use Refactor>Move in GGTS)
15. Set Config.groovy
security.twitter.domain.classname = 'test.TwitterUser'
16. 'run-app'
17. Access and Twitter authentication, error has occurred
Error 500: Internal Server Error
URI
/test/j_spring_twitter_security_check
Class
java.lang.NullPointerException
Message
Cannot get property 'clazz' on null object
Around line 24 of DefaultConnectedTwitterAuthDao.groovy
21: String rolesPropertyName
22:
23: TwitterUserDomain findUser(String username) {
24: Class<?> User = grailsApplication.getDomainClass(domainClassName).clazz
25: def user = null
26: User.withTransaction { status ->
27: user = User.findWhere(screenName: username)
Around line 28 of TwitterAuthProvider.groovy
25: Authentication authenticate(Authentication authentication) {
26: TwitterAuthToken token = authentication
27:
28: TwitterUserDomain user = authDao.findUser(token.screenName)
29:
30: if (user == null) {
31: if (!createNew) {
Around line 67 of TwitterAuthFilter.groovy
64: token: token.token
65: )
66: securityToken.authenticated = true
67: Authentication auth = getAuthenticationManager().authenticate(securityToken)
68: if (auth.authenticated) {
69: rememberMeServices.loginSuccess(request, response, auth)
70: log.info "Successful authentication"
Trace
Line | Method
->> 24 | findUser in DefaultConnectedTwitterAuthDao.groovy
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 28 | authenticate in TwitterAuthProvider.groovy
| 67 | attemptAuthentication in TwitterAuthFilter.groovy
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run . . . . . . . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 722 | run in java.lang.Thread
18. Unset "security.twitter.domain.classname", same error occurred
19.Moving TwitterUser.groovy is cause? or "security.twitter.domain.classname" is not working...
- Key "security.twitter.domain.classname" is incorrect.
- This key is shown at http://grails.org/plugin/spring-security-twitter as default config.
- Fix this likely automatically added key "grails.plugins.springsecurity.twitter.app.consumerKey".
- "grails.plugins.springsecurity.twitter.domain.classname" is correct.
- And it works well!
- This issue has posted:-P https://github.com/splix/grails-spring-security-twitter/issues/10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment