bawei-cloud/笔记.md

62 lines
1.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

1、鉴权登录 JWT -> token -> 前端 -> http请求头中携带token -> 接口 -> 拦截请求 -> 验证 token
登录方法:
a、 非空验证【数据的合法性】
b、 验证用户是否存在 【鉴权微服务不涉及数据库】 -> 远程调用 -> 系统微服务
c、 比对密码
d、 登录成功 -> 生成 JWT token
(1)、 用户的id
(2)、 生成 userKey -> 相当于redis的key
e、 用户信息存入redis 中 可以 是 前缀 + userKey
f、 返回 信息 【JwtResponse】
token
expireTime
sentinel限流
1 引入依赖
<dependency>
<groupId>com.alibaba.csp</groupId>
<artifactId>sentinel-spring-cloud-gateway-adapter</artifactId>
</dependency>
2 复制限流配置类
initGatewayRules 规定限流参数
initCustomizedApis 规定接口
方式:
1 对整个服务进行限流
2 针对于接口进行限流 √
短信验证码登录: 本月使用 阿里大鱼
1、 发送验证码的接口
a、入参 手机号
b、出参 提示发送成功
2、 短信验证码登录接口
a、入参 短信验证码 以及手机号
b、出参 token
1、引入sentinel的依赖 【 远程调用方 】
2、开启熔断
feign.sentinel.enable=true
3、解决循环依赖报错
spring.main.allow-circular-references=true
4、代码
hystrix
注意: 处理熔断情况
核心区分 熔断 还是 正常服务调通