Skip to content

Spring Boot application written in Scala with JWT authentication

License

Notifications You must be signed in to change notification settings

banditopazzo/spring-scala-jwt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spring Boot application in Scala with JWT Authentication

The application in a simple Rest service that manages tasks and use MongoDB as database

A running MongoDB server on localhost:27017 is needed.

The application uses Spring Boot, Spring Security and Spring Data.

Additional dependencies are JacksonModule for scala and the JWT library.

Usage

  • To register a user make a POST request to:

    localhost:8080/api/users/sign-up

    with the User (see implementation) in the body. You should receive a success message.

  • To authenticate make a POST request to:

    localhost:8080/login

    with the User (see implementation) in the body. You should receive a blank message with the JWT token in the Authorization header. The token is a long string with "Bearer" prefix, something like that:

    Bearer eyJhbGciOiJI........A.LOT.OF.CHARACTERS.......eNRCd_76Q

  • To make authenticated requests against the task controller simply put the received token in the Authorization header of all your following requests.

How to build

You need to install gradle. Then go to the project directory and type:

$ gradle build

Now it should compile. The first time it takes a while because gradle have to download all the dependencies.