Skip to content
secure spring-boot APIs with JWT
Java
Branch: master
Clone or download
Latest commit 05f2de4 Mar 11, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src init Aug 18, 2017
.gitignore
README.md Update README.md Mar 11, 2018
build.gradle
gradlew
gradlew.bat init Aug 18, 2017

README.md

jwt-boot-auth

secure spring-boot APIs with JWT

请求hello接口,由于没有登录,会收到403错误

curl http://localhost:8080/hello

注册一个新用户

curl -H "Content-Type: application/json" -X POST -d '{ "username": "admin", "password": "password" }' http://localhost:8080/users/signup

登录,会返回token,在http header中,Authorization: Bearer 后面的部分就是token

curl -i -H "Content-Type: application/json" -X POST -d '{ "username": "admin", "password": "password" }' http://localhost:8080/login

用登录成功后拿到的token再次请求hello接口

将请求中的XXXXXX替换成拿到的token,这次可以成功调用接口了

curl -H "Content-Type: application/json"
-H "Authorization: Bearer XXXXXX"
"http://localhost:8080/hello"

You can’t perform that action at this time.