In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
What is OAuth2.0 token relay in SpringBootSecurity? I believe many inexperienced people don't know what to do about it. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.
Add Eureka
The projects described above are two separate authorization services and resource services, so that the check_token addresses in the resource service are all dead addresses:
Let's add eureka so that we can use the service name directly. The construction of eureka service is no longer discussed. Adding eureka to the service only needs to be changed in two areas, that is, adding dependency and modifying configuration:
The additional configuration is as follows:
You can then change the fixed ip in the resource service to the service name:
Increase token Relay
After obtaining a token from the authorization service, there is no problem to access a resource service directly, but if the resource service invokes other resource services, there will be a problem that the token cannot be passed down automatically. To implement token relay, we need to write an interceptor to put the token in the requested header.
First, add the feign component to the service:
Add comment @ EnableFeignClients:
Note that the dependencies and annotations above should be increased for both the caller and the callee. Then write an interface on the callee:
Use the feign call on the caller:
Then write a test interface at the caller:
If you apply for a token directly now, and then visit the caller test interface, the following 401 error will occur:
Here is to add an interceptor to the caller and a token in the header:
test
You can see the result of token relay by directly applying for the token and accessing the caller's test interface:
After reading the above, have you mastered what is the method of OAuth2.0 token relay in SpringBootSecurity? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.