当前位置:网站首页>Web Security (x) what is OAuth 2.0?
Web Security (x) what is OAuth 2.0?
2022-07-01 05:22:00 【jinyangjie0】
One 、 summary
OAuth 2.0 It's the most popular authorization mechanism , Used to authorize third-party applications , Get user data .
Take the wechat scenario as an example . Wechat stores my friends' information , Third party applications need to get this information , You must be authenticated and authorized by wechat , Request to jump to wechat , Wechat users agree to authorize third-party applications , Get friend information .
In short ,OAuth It's a kind of authorization mechanism . The owner of the data tells the system , Agree to authorize third party applications to enter the system , Get the data . The system then generates a short-term entry token (token), In place of a password , For third party applications .
Two 、 Tokens and passwords
token (token) With the code (password) It's the same thing , You can enter the system , But there are three differences .
(1) The token is short-term , The expiration will automatically lapse , Users can't modify it themselves . Passwords are usually valid for a long time , Users don't modify , It won't change .
(2) The token can be revoked by the data owner , It's going to fail immediately . Passwords are generally not allowed to be revoked by others .
(3) The token has a scope of authority (scope). For Web Services , A read-only token is more secure than a read-write token . Passwords are generally full authority .
The above designs , The token ensures that the third-party application can obtain permission , At the same time, it can be controlled at any time , It won't endanger the system . This is it. OAuth 2.0 The advantages of .
Be careful , As long as you know the token , You can get into the system . The system generally does not reconfirm the identity , therefore Tokens must be kept confidential , The consequences of leaking a token are the same as leaking a password . That's why the validity period of the token , It's usually set very short .
3、 ... and 、OAuth 2.0 Four ways of
OAuth 2.0 There are four processes for obtaining tokens , According to the specific scene , Choose the right way , Issue tokens... To third-party applications .
Authorization code (authorization-code): It means that the third-party application applies for an authorization code first , Then use the code to get the token
Hidden (implicit): Issue a token directly to the front end . There are some WEB Applications are pure front end applications , No back end , The token must be stored on the front end .
Cryptogram (password): Provide the password directly , Request token by password . If you highly trust an app , You can use this method .
Client credentials (client credentials): For command line applications without a front end , That is, request the token at the command line .
Four 、 Update token
The validity of the token has reached , If you ask the user to go through the above process again , Apply for a new token , It's probably not a good experience , And there's no need .OAuth 2.0 Allow users to automatically update tokens .
The way to do it is ,B When the website issues the token , Two tokens at a time , One for getting data , Another is used to get a new token (refresh token Field ). Before the token expires , The user to use refresh token Send a request , To update token .
边栏推荐
- Print stream and system setout();
- 导电滑环使用的注意事项
- Fluentd is easy to use. Combined with the rainbow plug-in market, log collection is faster
- Introduction to 3D modeling and processing software Liu Ligang University of science and technology of China
- 导电滑环短路的原因以及应对措施
- Single page application
- [RootersCTF2019]babyWeb
- HCIP Day13
- Design and application of immutable classes
- AcWing 889. 01 sequence satisfying the condition (Cartland number)
猜你喜欢

Thread process foundation of JUC

Ebpf cilium practice (2) - underlying network observability

Use and principle of AQS related implementation classes

在Rainbond中一键部署高可用 EMQX 集群

Dynamic verification of new form items in El form; El form verifies that the dynamic form V-IF does not take effect;

Tcp/ip explanation (version 2) notes / 3 link layer / 3.2 Ethernet and IEEE 802 lan/man standards

导电滑环使用的注意事项

How to hide browser network IP address and modify IP internet access?

Application and principle of ThreadPoolExecutor thread pool

Set集合詳細講解
随机推荐
Txncoordsender of cockroachdb distributed transaction source code analysis
Copy baby prompt: material cannot be empty. How to solve it?
tar命令
提高企业产品交付效率系列(1)—— 企业应用一键安装和升级
Simple read / write verification of qdatastream
LevelDB源码分析之memtable
[daily question in summer] Luogu p7222 [rc-04] informatics competition
Global and Chinese market for kitchen range hoods 2022-2028: Research Report on technology, participants, trends, market size and share
Use and principle of reentrantlock
How to traverse massive data in redis
Explanation of characteristics of hydraulic slip ring
Rainbond结合NeuVector实践容器安全管理
Global and Chinese markets for soft ferrite cores 2022-2028: Research Report on technology, participants, trends, market size and share
Global and Chinese market of broadband amplifiers 2022-2028: Research Report on technology, participants, trends, market size and share
Vérification simple de la lecture et de l'écriture de qdatastream
Things generated by busybox
Go learning notes (5) basic types and declarations (4)
AcWing 887. Finding combinatorial number III (Lucas theorem)
Lock free concurrency of JUC (leguan lock)
Global and Chinese market of 3D design and modeling software 2022-2028: Research Report on technology, participants, trends, market size and share