当前位置:网站首页>Oauth2.0 - explanation of simplified mode, password mode and client mode
Oauth2.0 - explanation of simplified mode, password mode and client mode
2022-07-03 06:01:00 【Xiao bichao】
One 、OAuth2.0
In the last article, we have discussed OAuth2.0 I explained , And the authentication process of authorization code mode , And built a simple authentication service and resource service , In the previous article, we only explained the authentication login mode of authorization code , This article is about simplifying patterns 、 Password mode 、 Client mode these three modes are demonstrated and explained , Here is the address of the last article :
In the preparation of the previous article , We have released all models to c1 This customer id, So in the demonstration of the following mode, we can directly use the project built in the previous article :
Two 、 Simplified mode

The simplified mode is relative to the authorization code mode , It reduces the exchange through authorization code Token Steps for .
The resource owner opens the client , The client requires authorization from the resource owner , It redirects the browser to the authorization server , The identity information of the client will be attached during redirection
The browser displays the authorize to authorization server page , After that, the user agrees to authorize .
The authorization server sends the authorization code to the token (access_token) With Hash In the form of redirection uri Of fargment Send to browser .
Generally speaking , Simplified mode is used for third-party single page applications without server side , Because no server can receive authorization code .
characteristic
- Simple . The process is simple
- For pure front end applications
- unsafe . A bit careless ,Token Can be obtained by malicious scripts
- Token The validity period is short , When the browser is closed, it will fail
Browser access :
http://localhost:8020/oauth/authorize?client_id=c1&response_type=token&scope=all&redirect_uri=http://www.baidu.com


In the address bar, you can see the returned token:
Use Token Access resource interface :

3、 ... and 、 Password mode

- The resource owner will the user name 、 The password is sent to the client
- The client holds the user name of the resource owner 、 The password requests a token from the authorization server (access_token)
This model is very simple , But it means directly leaking sensitive user information to client, So this shows that this model can only be used for client It's our own development . So password patterns are generally used for our own development , The first is native App Or first party single page applications .
characteristic :
- Need to enter account password , Extremely unsafe , Third party applications need to be highly trusted
- It is applicable to situations where other authorization modes cannot be adopted
Use PostMan send out POST request :
http://localhost:8020/oauth/token?client_id=c1&client_secret=secret&grant_type=password&username=admin&password=1234

Use Token Access resource interface :
Four 、 Client mode

- The client sends its own identity information to the authorization server , And request a token (access_token)
- After confirming that the identity of the client is correct , Put the token (access_token) Send to client
This is the most convenient but insecure mode . So this requires us to be right client Complete trust , and client It's also safe . So this pattern is generally used to provide server-side services that we fully trust . such as , Partner system docking , Pull a set of user information .
characteristic
- The authorization dimension is the application dimension , Not user dimension . Therefore, it is possible for multiple users to share one Token The situation of
- Shared resources applicable to application dimensions
Use PostMan send out POST request :
http://localhost:8020/oauth/token?client_id=c1&client_secret=secret&grant_type=client_credentials

Use Token Access resource interface :

Love little buddy can pay attention to my personal WeChat official account. , Get more learning materials !
边栏推荐
- MySQL 5.7.32-winx64 installation tutorial (support installing multiple MySQL services on one host)
- Code generator - single table query crud - generator
- Leetcode solution - 01 Two Sum
- 2022.6.30DAY591
- Final review (Day2)
- 【一起上水硕系列】Day 10
- Method of finding prime number
- 2022.DAY592
- C 语言文件操作函数大全 (超详细)
- pytorch 搭建神经网络最简版
猜你喜欢

Sophomore dilemma (resumption)

项目总结--2(Jsoup的基本使用)
![[function explanation (Part 2)] | [function declaration and definition + function recursion] key analysis + code diagram](/img/29/1644588927226a49d4b8815d8bc196.jpg)
[function explanation (Part 2)] | [function declaration and definition + function recursion] key analysis + code diagram
![[video of Teacher Zhao Yuqiang's speech on wot] redis high performance cache and persistence](/img/a7/2140744ebad9f1dc0a609254cc618e.jpg)
[video of Teacher Zhao Yuqiang's speech on wot] redis high performance cache and persistence

Clickhouse learning notes (2): execution plan, table creation optimization, syntax optimization rules, query optimization, data consistency

Synthetic keyword and NBAC mechanism

Personal outlook | looking forward to the future from Xiaobai's self analysis and future planning
![[explain in depth the creation and destruction of function stack frames] | detailed analysis + graphic analysis](/img/df/884313a69fb1e613aec3497800f7ba.jpg)
[explain in depth the creation and destruction of function stack frames] | detailed analysis + graphic analysis

Kubernetes notes (I) kubernetes cluster architecture

Method of finding prime number
随机推荐
Method of finding prime number
Simple handwritten ORM framework
项目总结--01(接口的增删改查;多线程的使用)
Kubernetes notes (I) kubernetes cluster architecture
Detailed explanation of contextclassloader
PHP用ENV获取文件参数的时候拿到的是字符串
Installation of CAD plug-ins and automatic loading of DLL and ARX
Introduction to redis using Lua script
[together Shangshui Shuo series] day 7 content +day8
Skywalking8.7 source code analysis (I): agent startup process, agent configuration loading process, custom class loader agentclassloader, plug-in definition system, plug-in loading
The most responsible command line beautification tutorial
SVN分支管理
pytorch DataLoader实现miniBatch(未完成)
[teacher Zhao Yuqiang] RDB persistence of redis
Final review (Day2)
[teacher Zhao Yuqiang] redis's slow query log
Bernoulli distribution, binomial distribution and Poisson distribution, and the relationship between maximum likelihood (incomplete)
Kubernetes notes (VII) kuberetes scheduling
[teacher Zhao Yuqiang] the most detailed introduction to PostgreSQL architecture in history
项目总结--2(Jsoup的基本使用)