Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to implement Spring Security on my Spring 4.0 RestFul web service?

I just developed a simple restful web service by using Spring 4.0 and Hibernate 4.0, so it is without beans.xml file.

I would like to implement a Spring Security on the web service, since the roles will be performed on the HTTP functions GET, POST and DELETE, i.e. only admin who is allowed to DELETE, manager is allowed to do both POST and GET and the user can only GET data.

I'm looking for a detailed tutorial with example to implement Spring Security? or Do you think there is an easier security mechanism regardless it's strength?

like image 728
Kh.Taheri Avatar asked Feb 12 '15 17:02

Kh.Taheri


People also ask

How are REST services secured using Spring Security?

The following Spring security setup works as following: The user logs in with a POST request containing his username and password, The server returns a temporary / permanent authentication token, The user sends the token within each HTTP request via an HTTP header Authorization: Bearer TOKEN .

How do I add security to my spring application?

For adding a Spring Boot Security to your Spring Boot application, we need to add the Spring Boot Starter Security dependency in our build configuration file. Maven users can add the following dependency in the pom. xml file. Gradle users can add the following dependency in the build.


1 Answers

I just found that they in Spring.io added a detailed tutorial with real example developed by Java 8 in their own website, so it is completely annotation-based, which helps for building a RESTful webservice with Spring, testing it and also securing it.

It is really awesome, located HERE

like image 144
Kh.Taheri Avatar answered Sep 24 '22 08:09

Kh.Taheri