当前位置:网站首页>JS - single sign on
JS - single sign on
2022-06-23 01:31:00 【hhzzcc_】
1、 introduction
Recently, I logged in the process at the front end of the renovation project , Some experience , Share how to achieve single sign on
2、 What is single sign on
Single sign on (Single Sign On), Also abbreviated as sso, This means that after a project is manually logged in , When accessing another project of the same login system, it will automatically log in .

3、 Realization
1、 Ideas
1、 Single point implementation
The normal login process exchanges the account and password to the backend token, Or get it from the back end through the account and password code, In use code Exchange for token, Either way , Eventually, the front end will get a token, Will be token Write to localStorage perhaps cookie, Bring this when the interface requests token Authenticate the backend , To realize the login . On this basis, we add a process , Use a public Iframe To store token, That is, each time the project logs in, it will token Save to public iframe Of localStorage in , When using it, it starts from this iframe Medium localStorage Remove from token, Simply put, each project shares one iframe To access token, Make each project share the same place token, Achieve single sign on .
2、 compatible
Because the login component uses vue2.0 Development , But some projects have started to use vue3.0 Development , Importing a component directly will result in an error , There may even be other framework projects in the future , In order to be compatible with this situation , Put the entire login into iframe To maintain , Including login interface 、 Login interface call 、token Storage and other core login processes , The external provider only contains js Of npm package , Mainly used to create iframe and iframe signal communication . Whether it's vue3.0 Or something else js The framework can directly access login components without burden
2、 Overall process

4、 Advantages and disadvantages
1、 advantage
Single sign on
The access of each frame is simple , Don't worry about compatibility , And the access party does not need to consider the interface cross domain problem
Easy to upgrade , The core processes are iframe in , Process upgrade does not need to be updated npm package
2、 shortcoming
iframe There is a white screen problem , It is suggested to add loading state
5、 Conclusion
Through the practice of this login, I also stepped on many pits , For example, all login components are based on npm Package form , Lead to vue3 Are not compatible vue2 Components , It took half a May Day holiday to reconstruct iframe form , This article mainly provides the implementation ideas , The implementation of other details is not complicated , It is mainly about the encapsulation and... Of login components iframe Communication between , A lot of knowledge and experience have been gained after the completion of the whole process .
边栏推荐
- Read Amazon memorydb database based on redis
- SQL programming task04 job - set operation
- Psychological analysis of the safest spot Silver
- [launch] redis Series 2: data persistence to improve availability
- The devil cold rice # 099 the devil said to travel to the West; The nature of the boss; Answer the midlife crisis again; Specialty selection
- Vector 6 (inheritance)
- Error reported when compiling basalt
- Do you know the memory components of MySQL InnoDB?
- JS to read the picture of the clipboard
- Day367: valid complete square
猜你喜欢

Overview of visual object detection technology based on deep learning
Voice network multiplayer video recording and synthesis support offline re recording | Nuggets technology solicitation
![[initial launch] there are too many requests at once, and the database is in danger](/img/c1/807575e1340b8f8fe54197720ef575.png)
[initial launch] there are too many requests at once, and the database is in danger

SAP ui5 application development tutorial 103 - how to consume third-party libraries in SAP ui5 applications
![[hdu] P6964 I love counting](/img/ff/f8e79d28758c9bd3019816c8f46723.png)
[hdu] P6964 I love counting
![[machine learning watermelon book] update challenge [Day1]: 1.1 INTRODUCTION](/img/f6/b0df192502a59a32d8bac8c0862d02.png)
[machine learning watermelon book] update challenge [Day1]: 1.1 INTRODUCTION

SFOD:无源域适配升级优化,让检测模型更容易适应新数据

On AI and its future trend | community essay solicitation

office2016+visio2016

Explain the startup process of opengauss multithreading architecture in detail
随机推荐
[sliding window] leetcode992 Subarrays with K Different Integers
Module 8 job
Debian10 configuring rsyslog+loganalyzer log server
HDU - 7072 double ended queue + opposite top
Overview of visual object detection technology based on deep learning
SQL programming task03 job - more complex query
Fluentd is easy to use. Combined with the rainbow plug-in market, log collection is faster
使用aggregation API扩展你的kubernetes API
Huawei cloud recruits partners in the field of industrial intelligence to provide strong support + commercial realization
Cadence spb17.4 - Chinese UI settings
Real topic of the 2020 Landbridge cup provincial competition - go square (dp/dfs)
Pat class A - 1015 reversible primes
[initial launch] there are too many requests at once, and the database is in danger
Binary String
Pat class A - 1014 waiting in line (bank queuing problem | queue+ simulation)
How about precious metal spot silver?
Openvino CPU acceleration survey
Ansible learning summary (7) -- ansible state management related knowledge summary
B tree and b+ tree
SQL programming task06 assignment - Autumn recruit secret script ABC