当前位置:网站首页>Session cookies and tokens
Session cookies and tokens
2022-07-02 10:40:00 【Big chicken legs are best】
session-cookie
Using the server session And the browser cookie To achieve front and rear end authentication , Created on the server session aggregate , Maintain the requests of the same client in their respective session in , Whenever the server receives the browser's cookie When asked , Will be in session Query the corresponding s_id, If there is, confirm the identity successfully .
shortcoming :
The server needs to store Session, And because of Session You need to find it often and quickly , Usually stored in memory or memory database , At the same time, when there are many online users, it needs to occupy a lot of server resources .
Vulnerable CSRF attack : be based on cookie A cross site forgery attack , be based on cookie To identify users , The user carries the value ,cookie Intercepted , Users can easily be forged ;
Poor expansion : When you need to expand , establish Session Your server may not be an authentication server Session Server for , So you need to put all Session Store and share separately .
Token authentication
Token Authentication is also called token , It is a stateless authentication method , There is no need to store user information in the server or Session The server internal friction problem is removed in ; When the user logs in for the first time , The server generates a token And back to the client , Except that the client will save token Beyond invalidation or deletion , In the next request , Just take this token to request data .
1. The user sends the request through the user name and password ;
2. Program validation ;
3. The program returns a signed token To the client ;
4. Client store token, And every request comes with it ;
5. Server side validation token And return the data .
advantage
- The server does not need to store information related to user authentication , Authentication information will be encrypted to Token in , The server only needs to read Token The authentication information contained in the .
- Avoid sharing Session Resulting in problems that are not easy to expand .
- Don't rely on Cookie, Effectively avoid Cookie It brings CSRF Attack problem
- Use CORS Can quickly solve cross domain problems .
边栏推荐
- [Lua] summary of common knowledge points (including common interview sites)
- Vscode auto format
- pytest学习--base
- Blender石头雕刻
- sqoop创建job出现的一系列问题解决方法
- MYSQL关键字
- Deep understanding of redis cache avalanche / cache breakdown / cache penetration
- ERROR 1118 (42000): Row size too large (> 8126)
- MPLS experiment
- 【JetBrain Rider】构建项目出现异常:未找到导入的项目“D:\VisualStudio2017\IDE\MSBuild\15.0\Bin\Roslyn\Microsoft.CSh
猜你喜欢
Blender ocean production
ue4材质的入门和原理笔记
Pytest framework implements pre post
MPLS experiment
Determine whether there are duplicate elements in the array
Blender体积雾
虛幻AI藍圖基礎筆記(萬字整理)
The nanny level tutorial of flutter environment configuration makes the doctor green to the end
pytest框架实现前后置
Blender camera surround motion, animation rendering, video synthesis
随机推荐
Operator exercises
VLAN experiment
Pytest framework implements pre post
lunix重新分配root 和 home 空间内存
Blender volume fog
Nonlinear optimization: steepest descent method, Newton method, Gauss Newton method, Levenberg Marquardt method
Allure -- common configuration items
Feature (5): how to organize information
Blender camera surround motion, animation rendering, video synthesis
4.随机变量
Solution of mysql8 forgetting password file in Windows Environment
【Lua】常见知识点汇总(包含常见面试考点)
Ks009 implement pet management system based on SSH
Is this code PHP MySQL redundant?
Blender摄像机环绕运动、动画渲染、视频合成
How to achieve the top progress bar effect in background management projects
【虚幻4】UMG组件的简介与使用(更新中...)
Delivery mode design of Spartacus UI of SAP e-commerce cloud
Lunix reallocates root and home space memory
Pytest learning --base