Skip to content

Spring 5 web Application with JPA/Hibernate, Batch, OAuth2 Security, Thymeleaf, Selma, Swagger and many new features.

Notifications You must be signed in to change notification settings

pranav-patil/spring-mvc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Spring 5 MVC Showcase

Spring 5 MVC Application demonstrates the capabilities of the Spring 5 framework ranging from Spring MVC, Spring JPA, Spring Security. Also helps in understanding of new techniques such as Thymeleaf templates for UI development, Selma for object mappings, Swagger/SpringFox for API documentation etc.

In this showcase you'll see the following in action:

To run the application:

From the command line with Git and Maven:

$ git clone https://github.com/pranav-patil/spring-mvc.git
$ cd spring-mvc
$ mvn jetty:run (by default uses 8080]

Oauth2 Grant Type process for the application:

  • Request to get access token to access user registration service:

      curl -X POST -u register-app:secret http://localhost:8080/web/oauth/token?grant_type=client_credentials&client_id=register-app -H "Accept: application/json"
    
  • auth-server provides the JSON response with access token :

      {
          "access_token": "4d5364b6-f2b3-4c4a-ae54-96db71941ce4",
          "token_type": "bearer",
          "expires_in": 43199,
          "scope": "read"
      }
    
  • Call user registration service providing the access_token received earlier as Bearer header parameter, and user details along with credentials to register in POST Payload. The resource-server responds with success or failure confirmation.

      curl -X POST -H "Authorization: Bearer 4d5364b6-f2b3-4c4a-ae54-96db71941ce4" http://localhost:8080/web/user/register
           -d  '{
                    "username" : "user01",
                    "password" : "secret123",
                    "firstName" : "James",
                    "lastName" : "Bill",
                    "email" : "[email protected]"
                }'
    
  • Now using the user credentials for the user registered earlier, request for an access token :

      curl -X POST -u trusted-app:secret http://localhost:8080/web/oauth/token?grant_type=password&username=user01&password=secret123 -H "Accept: application/json"
    
  • auth-server returns the JSON response with access token :

      {
          "access_token": "45335e23-153b-41be-93fb-2f56df76b6a7",
          "token_type": "bearer",
          "refresh_token": "65baa098-e39c-4b98-8afc-06710b769319",
          "expires_in": 43199,
          "scope": "read write"
      }
    
  • Access resource with header parameter :

      curl -H "Authorization: Bearer 45335e23-153b-41be-93fb-2f56df76b6a7" http://localhost:8080/web/secure/api/weather
    
  • resource-server will give JSON response :

      {
      	"success":true,
      	"page":"admin",
      	"user":"admin"
      }
    

About

Spring 5 web Application with JPA/Hibernate, Batch, OAuth2 Security, Thymeleaf, Selma, Swagger and many new features.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published