当前位置:网站首页>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 .
边栏推荐
- [IDL] Research
- js promise.all
- Nonlinear optimization: steepest descent method, Newton method, Gauss Newton method, Levenberg Marquardt method
- 02-taildir source
- 【Unity3D】嵌套使用Layout Group制作拥有动态子物体高度的Scroll View
- 判断数组中是否存在重复元素
- Leetcode -- the nearest common ancestor of 236 binary tree
- Sus system availability scale
- webUI自动化学习
- 01安装虚拟机
猜你喜欢

webUI自动化学习

Allure -- common configuration items

《MySQL 8 DBA基础教程》简介

Considerations for Apache deploying static web page projects

MongoDB-快速上手MongoDB命令行的一些简单操作

Beautiful and intelligent, Haval H6 supreme+ makes Yuanxiao travel safer

Postman--使用

Test -- Summary of interview questions

13. Semaphore critical zone protection

01安装虚拟机
随机推荐
Blender摄像机环绕运动、动画渲染、视频合成
[unity3d] production progress bar - make image have the functions of filled and sliced at the same time
Blender stone carving
stm32和电机开发(上位系统)
Pytest framework implements pre post
Post disaster reconstruction -- Floyd thought
Message mechanism -- getting to know messages and message queues for the first time
Beautiful and intelligent, Haval H6 supreme+ makes Yuanxiao travel safer
【避坑指南】Unity3D项目接入腾讯Bugly工具时遇到的坑
【避坑指南】使用UGUI遇到的坑:Text组件无法首行缩进两格
Solution of mysql8 forgetting password file in Windows Environment
SPSS做Shapiro-Wilk正态分析
Flink calculates topn hot list in real time
Sus system availability scale
Flink实时计算topN热榜
【JetBrain Rider】构建项目出现异常:未找到导入的项目“D:\VisualStudio2017\IDE\MSBuild\15.0\Bin\Roslyn\Microsoft.CSh
虛幻AI藍圖基礎筆記(萬字整理)
Windows环境MySQL8忘记密码文件解决方案
pytest--之测试报告allure配置
MYSQL环境配置