Giter Site home page Giter Site logo

spring-session's Introduction

Grails 3

The 2.X version of the plugin is compatible only with grails 3.

spring-session-grails-plugin

This plugin provides spring-session support in grails application. SpringSession provides nice features:

  • HttpSession
    • Clustered Sessions
    • Multiple Browser Sessions
    • RESTful APIs
  • WebSocket

SpringSession uses Redis to persist the HTTP Sessions. You can find official documentation for Spring Session project here: http://docs.spring.io/spring-session/docs/1.0.1.RELEASE/reference/html5/

Currently this plugin provides support for HttpSession only. WebSocket support will be added in further release.

Using

Just add a plugin in BuildConfig.groovy.

plugins {
    runtime ":spring-session:1.2"
    ...
}

Note: Redis must be installed on your machine.

Configuration

1. Redis Configuration

Default configuration will lookup Redis server on your localhost port 6379. To override default configuration add below code in Config.groovy

springsession.redis.connectionFactory.hostName = "<redis server ip>"
springsession.redis.connectionFactory.port = 6379
springsession.redis.connectionFactory.password = "<password>"
springsession.redis.connectionFactory.timeout = 2000
springsession.redis.connectionFactory.usePool = true
springsession.redis.connectionFactory.dbIndex = 0

2. Change Session Strategy Configuration

Default session strategy is Cookie based and session cookie name is SESSION You can override the default session strategy

springsession.strategy.defaultStrategy='HEADER'

This will enable HTTP Header based session strategy. Default token name is x-auth-token you can override this

springsession.strategy.token.headerName = "new token name"

To change default cookie name add below configuration.

springsession.strategy.cookie.name="Your Cookie name"

(Note: Property springsession.strategy.defaultStrategy.cookie.name is no longer available in version 1.1 and higher)

3. Configure redis sentinel

springsession.redis.sentinel.master="<Sentinel master name>"
springsession.redis.sentinel.nodes=[[host: "hostname", port: xxxx], [host: "another host", port: xxxx]]
springsession.redis.sentinel.password="Sentinel password"

4. Enable update mutable objects in session

By default spring session doesn't update mutable object value stored in session. You can override this behaviour by setting below property to true. By default this value is false.

springsession.allow.persist.mutable = true

Version Support

  • Grails 2.4 +
  • Redis 2.8 +

spring-session's People

Contributors

jitendra-bisht avatar jeetmp3 avatar burtbeckwith avatar peh avatar mugren avatar ajdevries avatar erichelgeson avatar jgfaust avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.