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.
- Maven
- Spring Boot
- Spring Security
- jjwt
- Bower
- Angular JS
- Install front end dependencies using bower
bower install
- Start the application
mvn spring-boot:run
The application can be accessed by navigating to http://localhost:8080 in a browser. Please look inside src/main/resources/profiles.json
for credentials.
- 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"