Monday, February 09, 2015

Spring Boot with AngularJS form authentication leveraging Spring Session

In this blog post I would like to show you how you can distribute the session on Heroku via Spring Session. In order to get started quickly I am using Dave Syer's code from the II part of the awesome "Spring and Angular JS" blog series. I highly recommend to read them.

I did some modifications to the initial code, like using npm and bower instead of wro4j to manage front end dependencies. If you would like to jump right to the code, you can find it here.

The http sessions will be stored in a Redis instance, which all web dynos will have access to. This enables to deploy the web application on multiple dyno's and the login will still work. Heroku has a stateless architecture where the routers use a random selection algorithm for HTTP request load balancing across web dynos, there is no sticky session functionality.
I chose Redis Cloud service on Heroku since it gave me a 25MB free data plan. After adding
heroku addons:add rediscloud
The REDISCLOUD_URL environment is available where the connection settings are provided as seen below.



The BUILDPACK_URL was used to configure a multipack build using this library. Basically it allowed to run first the npm install and then the ./gradlew build command.
Via the embedded-redis library it is possible to start a redis server during initialisation. The related Redis configuration can be found below

Running on Heroku we needed another Redis configuration which connects to the previously defined Redis Cloud service.


You can connect to the Redis cloud service also from your localhost via
redis-cli -h hostname -p port -a password
And you will see the created keys which correspond to the value of your SESSION cookie.
Try to increase the dynos for your web application and you will see the login will still work.

28 comments:

Raju Kumar said...

Thanks for sharing.Keep update your blog
Angularjs Training In Hyderabad

caroline jesi said...

Thanks for sharing about Angular,It’s a structural framework for dynamic web application; it lets you extend the syntax of HTML to demonstrate your apps components clearly. All functionality happens inside the browser making it an ultimate companion with any server technology.
Regards,
Angularjs training in chennai|Angularjs course in chennai

Priya said...

The oracle database is capable of storing the data in two forms such as logically in the form of table spaces and physically like data files.
Oracle Training in Chennai | oracle dba training in chennai

geethu said...

Angularjs is the great javascript framework that has some compelling features not for developers but also for the designers. Angularjs is very essential for the web developers to know about its importance.
Angularjs Training in Chennai | angularjs course in chennai

Sankar lp said...

Very good explanation Spring Boot with AngularJS.

Online AngularJS Training | Online Angular2 Training | AngularJS Training in Chennai

Iqbal Dlk said...

very nice
be projects in chennai

2016 ieee projects in chennai

Iqbal Dlk said...

very good

lenovo laptop service center chennai

Aswin Karthick said...

good one java training in chennnai

mythily mythu said...

very nice.the best msbi training in chennai» the best msbi training in chennai.

mythily mythu said...

good. the best informatica training in chennai» the best informatica training in chennai.

mythily mythu said...

very nice.the best informix training in chennai» the best informix training in chennai.

mythily mythu said...

good.the best sybase training in chennai» the best sybase training in chennai.

mythily mythu said...

super.the best loadrunner training in chennai» the best loadrunner training in chennai.

1croreprojects said...

very useful information..

be projects in chennai
ieee projects in chennai

yasar said...

ece projects in chennai

embedded projects chennai

vlsi projects chennai
embedded training in chennai
matlab training in chennai

for IT the said...

Java Online Training Java Online Training Java Online Training Java Online Training Java Online Training Java Online Training

Hibernate Online Training Hibernate Online Training Spring Online Training Spring Online Training Spring Batch Training Online Spring Batch Training Online

for IT the said...

Interesting Article

Spring online training Spring online training Spring Hibernate online training Spring Hibernate online training Java online training

spring training in chennai spring hibernate training in chennai

Iqbal Dlk said...

very nice and informative blog
java training in chennai
dot net training in chennai

1croreprojects said...

Thanks for sharing this valuable information.
java projects in chennai
dotnet projects in chennai
mba projects in chennai

Wiztech Automation said...

Nice post...thanks for sharing in this post...

Embedded system training in chennai
Embedded system course training in chennai
Embedded system training institute in chennai chennai
Embedded training in chennai
Matlab training in chennai

Xplorant Seo said...

Wonderful blog.. Thanks for sharing informative blog.. its very useful to me..

iOS Training in Chennai

onlinetrainings expert said...
This comment has been removed by the author.
Words Doctorate said...

Words Doctorate is providing PhD-Master Thesis, Dissertation and Research related support for PhD - Master Students-all stream.

PhD Thesis Writing Services
Dissertation Writing Services
Research Paper Writing Services
Master Thesis Writing Services

yasar said...

very nice and informative blog
big data projects chennai
mobile computing projects chennai
cloud computing projects chennai
secure computing projects chennai

yasar said...

very nice and informative blog
matlab projects in chennai
ieee android projects in chennai
robotics projects in chennai
iot projects in chennai

Kamalakar said...



I Visited lot of blogs and Web sites But in this AngularJS Blog Information is Very usefulthanks for sharing it........

ravi kumar said...

aaaa

ravi kumar said...

I read lot of blogs but this one is really impress me.I gather lot of infirmation in this blog.Thanks for sharing.keep sharing more blogs.


Angularjs Online Training