Skip to content

v5tech/spring-boot-jwt-sample

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

spring-boot-jwt-sample

spring boot整合jwt完成接口授权认证

1、注册用户(POST)

http://localhost:8081/api/v1.0/register

{
  "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

{
  "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

Releases

No releases published

Packages

No packages published

Languages