Persistent session StorageService, choosing and configuring

Rich Graves rgraves at carleton.edu
Fri Jan 27 17:52:43 EST 2017


I'm pretty sure I need server-side session storage, rather than
stateless encrypted cookies, because of an application that uses CAS.
Lemme know if otherwise.

The Easy Button was to use the default in-memory storage. But of
course that means jetty restart = session end.

I think I want to use MySQL, because it's something we understand and
use for other things. But I guess I could use memcached, if y'all
think that would be better? Needs: We are tiny and typically run one
non-clustered production IdP, a variety of test/staging IdPs, and we
do (near)zero downtime upgrades by NATing the public IP address. So we
don't need horizontal load-balancing and we rely on the virtualization
layers for HA, but some way to replicate the active sessions database
between our two servers would be nice. Even one-shot manual
dump/restore of the MySQL database would meet our needs. The main
thing I'm shooting for is that I want our 3.2.1->3.3 upgrade to be the
last jetty restart where sessions are lost. There are worse things
than users needing to authenticate but still.

Anyway, if you don't convince me to use memcached, I'm confused about
the MySQL config. I got this far by interpolating
StorageConfiguration,and some tips I found at tuakiri.ac.nz. There's
been a lot of chatter about the MySQL config; which is "latest" and
most authoritative for 3.3?

In attribute-resolver.xml, I have been doing this successfully. What's
the JPAStorageService equivalent?

   <dc:ApplicationManagedConnection
       jdbcDriver="com.mysql.jdbc.Driver" jdbcURL="jdbc:mysql://localhost/geoip"
       jdbcUserName="supersecret" jdbcPassword="seriously?" />

With this (in global.xml), Jetty fails early with
ClassNotFoundException: com.zaxxer.hikari.HikariDataSource. Where is
that supposed to be and why don't I need it for attribute resolution?

    <bean id="shibboleth.JPAStorageService"
        class="org.opensaml.storage.impl.JPAStorageService"
        p:cleanupInterval="%{idp.storage.cleanupInterval:PT10M}"
        c:factory-ref="shibboleth.JPAStorageService.EntityManagerFactory" />

    <bean id="shibboleth.JPAStorageService.EntityManagerFactory"
        class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
        <property name="persistenceUnitName" value="storageservice" />
        <property name="packagesToScan" value="org.opensaml.storage.impl" />
        <property name="dataSource"
ref="shibboleth.JPAStorageService.DataSource" />
        <property name="jpaVendorAdapter"
ref="shibboleth.JPAStorageService.JPAVendorAdapter" />
        <property name="jpaDialect">
            <bean
class="org.springframework.orm.jpa.vendor.HibernateJpaDialect" />
        </property>
    </bean>

    <bean id="shibboleth.JPAStorageService.JPAVendorAdapter"
        class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
        <property name="database" value="MYSQL" />
    </bean>

    <bean id="shibboleth.JPAStorageService.DataSource"
        class="com.zaxxer.hikari.HikariDataSource"
destroy-method="close" lazy-init="true"
        p:driverClassName="com.mysql.jdbc.Driver"
        p:jdbcUrl="jdbc:mysql://localhost:3306/idp_db?autoReconnect=true&sessionVariables=wait_timeout=31536000"
        p:username="supersecret"
        p:password="seriously?" />


More information about the users mailing list