# g35_jwt_annotation **Repository Path**: wangquanjava/g35_jwt_annotation ## Basic Information - **Project Name**: g35_jwt_annotation - **Description**: No description available - **Primary Language**: Java - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2019-08-26 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README #### 简介 实现了JWT在web中应用流程 #### 实现原理 1. 使用拦截器来对需要token,但是没有token的访问进行拦截 2. 访问/login成功后,会使用userid来得到一个关联的token:{"alg":"HS256"}{"sub":"xxxx"} 3. 访问/get的时候,拦截器会解析token->id,并存储到request域中 4. 使用自定义resolver判断参数列表中是否有@GetUser注解,如果有就取出request域中id->user对象,进行注入 #### 演示流程 1. 访问/login 得到token 2. 把token加到header中,访问get,会返回user对象