当前位置:网站首页>oauth2.0鉴权,登录访问 “/oauth/token”,请求头Authorization(basicToken)如何取值???
oauth2.0鉴权,登录访问 “/oauth/token”,请求头Authorization(basicToken)如何取值???
2022-07-03 02:16:00 【君临天下tjm】
springcloud项目通常使用oauth2.0做鉴权管理微服务模块,当使用grantType="password"和jwt存储token时,需要设置clientId和clientSecret,这两个值可以随便取,配置在application.yml文件里面。访问 “/oauth/token”,参数@RequestHeader("Authorization")的取值是Basic开头,加空格,加clientId:clientSecret格式进行base64加密后的字符串。


在做用户登录的时候,需要传入username和password,然后通过openfeign访问oauth2.0里面的入口"/oauth/token"方法,获取token,token可以保存到redis(当网关过滤/验证token的时候,查询redis,判断token是否有效,有效则放行),再对token解析后,可以拿到jwtJson,再取到"user_name"和"authorities",根据user_name查询需要的信息,返回给前端。
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-oauth2</artifactId>
</dependency>




通过openfeign访问oauth2.0的获取token入口@PostMapping("/oauth/token")。

边栏推荐
- Swift development learning
- Machine learning notes (constantly updating...)
- Comment le chef de file gère - t - il l'équipe en cas d'épidémie? Contributions communautaires
- awk从入门到入土(1)awk初次会面
- 詳細些介紹如何通過MQTT協議和華為雲物聯網進行通信
- How to find summer technical internship in junior year? Are you looking for a large company or a small company for technical internship?
- [fluent] fluent debugging (debug debugging window | viewing mobile phone log information | setting normal breakpoints | setting expression breakpoints)
- 机器学习流程与方法
- Coroutinecontext in kotlin
- 去除网页滚动条方法以及内外边距
猜你喜欢

easyExcel

A 30-year-old software tester, who has been unemployed for 4 months, is confused and doesn't know what to do?

Button button adaptive size of wechat applet

4. 类和对象

stm32F407-------DMA

基于线程池的生产者消费者模型(含阻塞队列)

全链路数字化转型下,零售企业如何打开第二增长曲线

MySQL学习03

Distributed transaction solution

Return a tree structure data
随机推荐
Bottleneck period must see: how can testers who have worked for 3-5 years avoid detours and break through smoothly
【CodeForces】CF1338A - Powered Addition【二进制】
Y54. Chapter III kubernetes from introduction to mastery -- ingress (27)
Machine learning process and method
[camera topic] complete analysis of camera dtsi
String replace space
File class (check)
各国Web3现状与未来
[Flutter] dart: class; abstract class; factory; Class, abstract class, factory constructor
Button button adaptive size of wechat applet
A 30-year-old software tester, who has been unemployed for 4 months, is confused and doesn't know what to do?
微服务组件Sentinel (Hystrix)详细分析
创建+注册 子应用_定义路由,全局路由与子路由
MySQL learning 03
Comment communiquer avec Huawei Cloud IOT via le Protocole mqtt
iptables 4层转发
我的创作纪念日
leetcode961. Find the elements repeated N times in the array with length 2n
Summary of ES6 filter() array filtering methods
Anna: Beibei, can you draw?
https://www.qvdv.com/tools/qvdv-base64.html