Skip to content

sdqali/jwt-demo

Repository files navigation

JWT Demo

An example Spring Boot application with an API capable of authenticating with JWTs and a front end capable of authenticating against this API. For motivation and discussion of the code, please see my series of blog posts.

Dependencies

  • Maven
  • Spring Boot
  • Spring Security
  • jjwt
  • Bower
  • Angular JS

Deploying

  • Install front end dependencies using bower
bower install
  • Start the application
mvn spring-boot:run

Usage

The application can be accessed by navigating to http://localhost:8080 in a browser. Please look inside src/main/resources/profiles.json for credentials.

API

  • Obtain a JWT:
curl -v -X POST "http://localhost:8080/login" -d '{"username":"greenrabbit948", "password":"celeste"}' --header "Content-Type: application/json"
  • Authenticating using the obtained JWT:
curl -s "http://localhost:8080/profile/details/greenrabbit948" --header "Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJncmVlbnJhYmJpdDk0OCIsImV4cCI6MTQ2ODE0MDg1MiwiaXNzIjoiaW4uc2RxYWxpLmp3dCJ9.t9pqrOmYfaVkzuAQgo4D4VbN2PibQuHPuPA6RKYU-keTzbFAX58l77hQTc4Cq28HpjFOeiDvNpNEgilNHFOfVA"

Releases

No releases published

Packages

No packages published