https://github.com/v5tech/spring-boot-jwt-sample
spring-boot-jwt-sample
https://github.com/v5tech/spring-boot-jwt-sample
jwt jwt-auth jwt-token spring-boot
Last synced: 7 months ago
JSON representation
spring-boot-jwt-sample
- Host: GitHub
- URL: https://github.com/v5tech/spring-boot-jwt-sample
- Owner: v5tech
- Created: 2018-05-29T13:16:41.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-05-30T02:19:48.000Z (over 7 years ago)
- Last Synced: 2024-10-11T18:01:43.593Z (over 1 year ago)
- Topics: jwt, jwt-auth, jwt-token, spring-boot
- Language: Java
- Size: 185 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# spring-boot-jwt-sample
spring boot整合jwt完成接口授权认证
1、注册用户(POST)
http://localhost:8081/api/v1.0/register
```json
{
"id": 1,
"userName": "admin",
"loginName": "admin",
"password": "admin",
"roles": "admin",
"email": "admin@ameizi.net",
"location": "xi'an",
"signature": "admin",
"createAt": "2018/5/30 10:06",
"updateAt": "2018/5/30 10:06"
}
```

2、获取token(POST)
http://localhost:8081/api/v1.0/auth/token
```json
{
"userName": "admin",
"loginName": "admin",
"password": "admin"
}
```


3、请求接口(GET)
http://localhost:8081/api/v1.0/users/current
在请求头中添加第二步操作生成的jwt token
在`Header`中添加`Authorization`其值为上一步生成的`token`信息如:`Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsImp0aSI6IjEiLCJyb2xlcyI6InVzZXIiLCJhdWQiOiJ3ZWIiLCJpYXQiOjE1Mjc2NDYxNjUsImlzcyI6ImFkbWluIiwiZXhwIjoxNTI3NzMyNTY1fQ.5kglv2hGTfmJ9PW61BFiak09NFW2aHRckP3GUdpkPe8W3K7psc0QCVOp7CNbfIB1LEC-JixX1RQCA6ymWyupIw`
