Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jhipster 2 : What is the difference between the authentication option?

I have updated the jhipster generator from version 1 to version 2. In the previous version we had to choices of authentication when generating a new project. We had the choice between Cookie authentication and Token authentication (with OAuth). This was very clear for me. But in version 2.1.1, we have now three choices :

1 > HTTP Session Authentication (stateful, default Spring Security mechanism)
2 > OAuth2 Authentication (stateless, with an OAuth2 server implementation)
3 > Token-based authentication (stateless, with a token)

I want to used the authentication both for web and mobile app (ionic-framework), which one to one between 2 and 3 ? Is this choice make my app scalable using clusters ? Thanks

like image 743
Pracede Avatar asked Feb 09 '15 05:02

Pracede


1 Answers

you will the basic info about jhipster authentication type here

http://jhipster.github.io/security/

from my personal experience in ionic-framework working with REST api of jhipster, I can say that don't use HTTP Session Authentication for mobile app (ionic-framework) because mobile apps don not play along with cookies in general which HTTP Session Authentication depends upon.

Both Oauth2 and JWT work fine with ionic hybrid app

HTTP Session Authentication

This is the "classical" Spring Security authentication mechanism, but we have improved it quite significantly. It uses the HTTP Session, so it is a stateful mechanism: if you plan to scale your application on multiple servers, you need to have a load balancer with sticky sessions so that each user stays on the same server.

OAuth2 Authentication

OAuth2 is a stateless security mechanism, so you might prefer it if you want to scale your application across several machines. Spring Security provides an OAuth2 implementation, which we have configured for you.

The biggest issue with OAuth2 is that requires to have several database tables in order to store its security tokens. If you are using an SQL database, we provide the necessary Liquibase changlog so that those tables are automatically created for you.

As Spring Security only supports OAuth2 with SQL databases, we have also implemented our own MongoDB version. We generate for you all the OAuth2 implementation for MongoDB, as well as the necessary MongoDB configuration.

This solution uses a secret key, which should be configured in your application.yml file, as the "authentication.oauth.secret" property.

JWT authentication

JSON Web Token (JWT) authentication, like OAuth2, is a stateless security mechanism, so it's another good option if you want to scale on several different servers.

This authentication mechanism doesn't exist by default with Spring Security, it's a JHipster-specific integration of the Java JWT project. It is easier to use and implement than OAuth2, as it does not require a persistence mechanism, so it works on all SQL and NoSQL options.

This solution uses a secure token that holds the user's login name and authorities. As the token is signed, it cannot be altered by a user.

The secret key should be configured in the application.yml file, as the jhipster.security.authentication.jwt.secret property.

like image 188
Abhishek Patil Avatar answered Oct 11 '22 11:10

Abhishek Patil