4 Token Storage - Reference Documentation
Authors: Alvaro Sanchez-Mariscal
Version: 1.2.5
4 Token Storage
The tokens are stored on the server using atokenStorageService
bean. The plugin comes with out-of-the-box support
for Memcached and GORM, but you can use your own strategy implementing the
TokenStorageService
interface.
4.1 Memcached
To use Memcached, simply define the following configuration properties to match your environments accordingly:Config key | Default value |
---|---|
grails.plugin.springsecurity.rest.token.storage.useMemcached | false |
grails.plugin.springsecurity.rest.token.storage.memcached.hosts | localhost:11211 |
grails.plugin.springsecurity.rest.token.storage.memcached.username | '' |
grails.plugin.springsecurity.rest.token.storage.memcached.password | '' |
grails.plugin.springsecurity.rest.token.storage.memcached.expiration | 3600 |
grails.plugin.springsecurity.rest.token.storage.useMemcached = true
. It should work.
4.2 GORM
The GORM support is still experimental.To use GORM, those are the relevant configuration properties:
Config key | Default value |
---|---|
grails.plugin.springsecurity.rest.token.storage.useGorm | false |
grails.plugin.springsecurity.rest.token.storage.gorm.tokenDomainClassName | AuthenticationToken |
grails.plugin.springsecurity.rest.token.storage.gorm.tokenValuePropertyName | tokenValue |
grails.plugin.springsecurity.rest.token.storage.gorm.usernamePropertyName | username |
class AuthenticationToken { String tokenValue String username }
In this case, instead of storing the wholeUserDetails
object, only the username is stored. This is because applications using this strategy will probably have the standard User and Role domain classes. Then, the username is passed to the defaultuserDetailsService
bean, which in the case of the default Spring Security Core GORM implementation will fetch the information from the mentioned domain classes.