Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

securesocial fake log in when developing

I am using securesocial it works fine but now every time I change some scala code I have to login again. Is there a possibility to fake a user in the session when in development mode, so I don't have to login so often?

Thanks,

Joris Wijlens

like image 243
Joris Wijlens Avatar asked Nov 01 '12 15:11

Joris Wijlens


1 Answers

SecureSocial by default uses the default Play cache for storing authenticators (that match the cookies to the logged in user). The default play cache is EHCache and it's configured using the ehcache.xml that you can find in the jars. The default configuration is strictly in memory which means that when the app restarts, it loses all the values. Fortunately, it's pretty easy to overwrite the EHCache configuration to write to the disk.

Copy the ehcache.xml in the jars to your configuration directory. Add <diskStore path="java.io.tmpdir"/> and change diskPersistent to true

So mine looks like this:

<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../config/ehcache.xsd" updateCheck="false">
<diskStore path="java.io.tmpdir"/>
<defaultCache
        maxElementsInMemory="10000"
        eternal="false"
        timeToIdleSeconds="120"
        timeToLiveSeconds="120"
        overflowToDisk="false"
        maxElementsOnDisk="10000000"
        diskPersistent="true"
        diskExpiryThreadIntervalSeconds="120"
        memoryStoreEvictionPolicy="LRU"
        />
</ehcache>

If you're interested learning how to configure the rest of it, there is some documentation in the ehcache-failsafe.xml file that's also in the Play jars.

like image 157
David Weinberg Avatar answered Nov 13 '22 18:11

David Weinberg