一 代码位置

https://github.com/cakin24/spring-cloud-code/tree/master/ch8-2

二 测试

1 启动eureka-server

2 启动zuul-server

3 启动auth-server

4 启动client-a

5 浏览器输入:http://localhost:5555/client/test

出现错误是因为还没有登录授权

6 浏览器输入:http://localhost:5555

跳转到auth-server的默认登录页面,使用admin与admin登录。

7 使用浏览器再次访问:http://localhost:5555/client/test

头部权限信息如下:

authorization: bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1NzM0MTI4MDEsInVzZXJfbmFtZSI6ImFkbWluIiwiYXV0aG9yaXRpZXMiOlsiV1JJR1RIX1dSSVRFIiwiV1JJR1RIX1JFQUQiXSwianRpIjoiZGQzZDE2YzMtM2NmZi00OGJkLTg3NmItZjI4NGE0NTE1MTUyIiwiY2xpZW50X2lkIjoienV1bF9zZXJ2ZXIiLCJzY29wZSI6WyJXUklHVEgiLCJyZWFkIl19.F0t6aIeGPZ42Tt0nxtJfgpi7FaPti1DizGDjf6HWCac

解析后为:

{"alg":"HS256","typ":"JWT"}
{"exp":1573412801,"user_name":"admin","authorities":["WRIGTH_WRITE","WRIGTH_READ"],"jti":"dd3d16c3-3cff-48bd-876b-f284a4515152","client_id":"zuul_server","scope":["WRIGTH","read"]}
FaJDHfhdjafhsdafdjkslhgaskdjfdsfhasdfjas

它们分别是jwt token的头部,荷载、签名信息

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐