> For the complete documentation index, see [llms.txt](https://long0419.gitbook.io/mileworks-microservice-kit/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://long0419.gitbook.io/mileworks-microservice-kit/fu.md).

# 上篇的追加：基于JWT的Token认证的理解

**重要**说明一点的是：**前后端分离的项目一定要加认证和鉴权的功能！！！** 于是基于JWT的Token认证鉴权功能的解决方案又是跑不掉了。这里单独作为一个章节就是要告知其重要性。[Krakend](https://www.krakend.io/docs/overview/introduction/)中使用的话也要加上JWT 。 前期是花了一部分时间去研究的，java语言也是基于spring security来做的这套东西。一般token认证鉴权的流程如下:

![](https://user-images.githubusercontent.com/1064859/42557268-943551c8-8520-11e8-9c38-e1c518cd6ed3.jpg)而基于微服务或者更简单来说只要前后端分离之后，大致OAuth 2.0认证鉴权流程是如下的：

[![](https://user-images.githubusercontent.com/1064859/42986178-32b3d7cc-8c27-11e8-9dd8-d216fc1bb962.png)](https://www.renren.io/guide)参考性文章：

```
https://www.jdon.com/artichect/json-web-tokens.html
https://segmentfault.com/a/1190000009164779
http://blueskykong.com/2017/10/19/security1/
http://blog.didispace.com/spring-security-oauth2-xjf-1/
https://www.callicoder.com/spring-boot-spring-security-jwt-mysql-react-app-part-2/
```

自己针对JWT 例子：（对每个部分代码已经做了解释）

```
https://github.com/Mileworks/MileWorks-Auth/tree/master/client-credentials
```

~~最近因为找RN 的例子不小心翻到一个比较合理的~~[~~工程~~](https://github.com/walljser/backend_cloud_commodity)~~，后期可以使用。是基于SpringBoot + Mybatis + MySql + Redis + Token方案~~

~~客户端中如何使用JWT的注意下！！！~~


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://long0419.gitbook.io/mileworks-microservice-kit/fu.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
