I'm currently trying to use spring security rest (URL) and memcache. I used gorm with MySQL to validate my spring security config rest and it works fine.
Now I would like to use memcached to store the session instead of mySQL
Like is noticed here :
http://alvarosanchez.github.io/grails-spring-security-rest/docs/guide/single.html#authentication
I should set up this configuration :
Config key Default value
grails.plugin.springsecurity.rest.token.storage.useMemcached true
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
I did that and I got a problem. My token is successfully stored in memcache but when I try to validate my token with this route 'url:8080/myapp/api/validate' with "Autorisation : Bearer {MyToken}" the API send me a 401 error code.
Stack trace :
014-09-09 12:30:17,265 [Memcached IO over {MemcachedConnection to localhost/127.0.0.1:11211}] DEBUG memcached.MemcachedConnection - Read 816 bytes
2014-09-09 12:30:17,265 [Memcached IO over {MemcachedConnection to localhost/127.0.0.1:11211}] DEBUG binary.GetAndTouchOperationImpl - Reading 24 header bytes
2014-09-09 12:30:17,265 [Memcached IO over {MemcachedConnection to localhost/127.0.0.1:11211}] DEBUG binary.GetAndTouchOperationImpl - Reading 792 payload bytes
2014-09-09 12:30:17,268 [Memcached IO over {MemcachedConnection to localhost/127.0.0.1:11211}] WARN transcoders.SerializingTranscoder - Caught CNFE decoding 788 bytes of data
Message: org.springframework.security.core.userdetails.User$AuthorityComparator
Line | Method
->> 366 | run in java.net.URLClassLoader$1
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 355 | run in ''
| 354 | findClass . . . . . . . in java.net.URLClassLoader
| 425 | loadClass in java.lang.ClassLoader
| 358 | loadClass . . . . . . . in ''
| 270 | forName in java.lang.Class
| 625 | resolveClass . . . . . in java.io.ObjectInputStream
| 1612 | readNonProxyDesc in ''
| 1517 | readClassDesc . . . . . in ''
| 1771 | readOrdinaryObject in ''
| 1350 | readObject0 . . . . . . in ''
| 370 | readObject in ''
| 522 | readObject . . . . . . in java.util.TreeSet
| 1017 | invokeReadObject in java.io.ObjectStreamClass
| 1893 | readSerialData . . . . in java.io.ObjectInputStream
| 1798 | readOrdinaryObject in ''
| 1350 | readObject0 . . . . . . in ''
| 1990 | defaultReadFields in ''
| 1915 | readSerialData . . . . in ''
| 1798 | readOrdinaryObject in ''
| 1350 | readObject0 . . . . . . in ''
| 1990 | defaultReadFields in ''
| 1915 | readSerialData . . . . in ''
| 1798 | readOrdinaryObject in ''
| 1350 | readObject0 . . . . . . in ''
| 370 | readObject in ''
| 129 | deserialize . . . . . . in net.spy.memcached.transcoders.BaseSerializingTranscoder
| 88 | decode in net.spy.memcached.transcoders.SerializingTranscoder
| 1439 | gotData . . . . . . . . in net.spy.memcached.MemcachedClient$8
| 61 | decodePayload in net.spy.memcached.protocol.binary.GetAndTouchOperationImpl
| 204 | finishedPayload . . . . in net.spy.memcached.protocol.binary.OperationImpl
| 194 | readPayloadFromBuffer in ''
| 137 | readFromBuffer . . . . in ''
| 813 | readBufferAndLogMetrics in net.spy.memcached.MemcachedConnection
| 792 | handleReads . . . . . . in ''
| 672 | handleReadsAndWrites in ''
| 635 | handleIO . . . . . . . in ''
| 409 | handleIO in ''
^ 1334 | run . . . . . . . . . . in ''
2014-09-09 12:30:17,280 [Memcached IO over {MemcachedConnection to localhost/127.0.0.1:11211}] DEBUG binary.GetAndTouchOperationImpl - Transitioned state from READING to COMPLETE