Last updated by splix 10 months ago
grails install-plugin spring-security-twitter
Last updated by splix 8 months ago
Grails plugin for Twitter Authentication, as extension to Grails Spring Security Core plugin
Information
Sources:
https://github.com/splix/grails-spring-security-twitterRequirements:
- grails 1.3.7
- spring-security-core plugin 1.1+
- twitter4j (will be downloaded automatically)
How to install:
grails install-plugin spring-security-core
grails s2-quickstart
grails install-plugin spring-security-twitter
grails s2-init-twitter
Usage:
Add CSS into your view layout:
<link rel="stylesheet" href="${resource(dir:'css',file:'twitter-auth.css')}" />Put sign-in button:
after clicking this button user will be authenticated through twitter, and redirected to main page (configurable at spring-security-core)
Note that Twitter requires to use some domain name for your app (so 127.0.0.1 isn't working here), to achieve this you can add following line:
127.0.0.1 mytestdomain.local
into your /etc/hosts file (%SystemRoot%system32driversetc for Windows). Where mytestdomain.local is a domain name you would like to use for local testing.
Configuration
After plugin install you'll get twitter keys stored in your grails-app/conf/Config.groovy, that can be modified later.
Default config:
security {
twitter { language = "en_US"
button.text = "Login with Twitter"
popup = false autoCreate {
active = true
roles = ["ROLE_USER", "ROLE_TWITTER"]
} filter {
processUrl = "/j_spring_twitter_security_check"
processPopupUrl = "/twitterAuth/popup"
} domain {
classname = "TwitterUser"
connectionPropertyName = "user"
}
}
}How to
How to use my own DAO
You have to create a class, that implements com.the6hours.grails.springsecurity.twitter.TwitterAuthDao, put it as a bean into spring context (see docs) add following configuration into your Config.groovy:
grails.plugins.springsecurity.twitter.bean.dao='myOwnDaoBean'
Last updated by splix 10 months ago
Last updated by splix 10 months ago