Session, Token and SSO 有什么区别
Session, Token and SSO 有什么区别
Basic Compareation
Session-based Authentication
In Session-based Authentication the Server does all the heavy lifting server-side. Broadly speaking a client authenticates with its credentials and receives a session_id (which can be stored in a cookie) and attaches this to every subsequent outgoing request. So this could be considered a "token" as it is the equivalent of a set of credentials.There is however nothing fancy about this session_id-String. It is just an identifier and the server does everything else. It is stateful. It associates the identifier with a user account (e.g. in memory or in a database). It can restrict or limit this session to certain operations or a certain time period and can invalidate it if there are security concern and more importantly it can do and change all of this on the fly. Furthermore it can log the users every move on the website(s). Possible disadvantages are bad scale-ability (especially over more than one server farm) and extensive memory usage.
Token-based Authentication
In Token-based Authentication no session is persisted server-side (stateless). The initial steps are the same. Credentials are exchanged against a token which is then attached to every subsequent request (It can also be stored in a cookie).However for the purpose of decreasing memory usage, easy scale-ability and total flexibility (tokens can be exchanged with another client) a string with all the necessary information is issued (the token) which is checked after each request made by the client to the server.
Detail Comparation
Session Based Authentication
Session based authentication has been the default, tried-and-true method for handling user authentication for a long time.Session based authentication is stateful. This means that an authentication record or session must be kept both server and client-side. The server needs to keep track of active sessions in a database, while on the front-end a cookie is created that holds a session identifier, thus the name cookie based authentication. Let's look at the flow of traditional cookie based authentication:
1. User enters their login credentials
2. Server verifies the credentials are correct and creates a session which is then stored in a database
3. A cookie with the session ID is placed in the users browser
4. On subsequent requests, the session ID is verified against the database and if valid the request processed
5. Once a user logs out of the app, the session is destroyed both client and server side
Token-Based Authentication
Token-based authentication has gained prevalence over the last few years due to rise of single page applications, web APIs, and the Internet of Things (IoT). When we talk about authentication with tokens, we generally talk about authentication with JSON Web Tokens (JWTs). While there are different ways to implement tokens, JWTs have become the de-facto standard. With this context in mind, the rest of the article will use tokens and JWTs interchangeably.Token-based authentication is stateless. The server does not keep a record of which users are logged in or which JWTs have been issued. Instead, every request to the server is
accompanied by a token which the server uses to verify the authenticity of the request. The token is generally sent as an addition Authorization header in form of Bearer {JWT}, but can additionally be sent in the body of a POST request or even as a query parameter. Let's see how this flow works:
1. User enters their login credentials
2. Server verifies the credentials are correct and returns a signed token
3. This token is stored client-side, most commonly in local storage - but can be stored in session storage or a cookie as well
4. Subsequent requests to the server include this token as an additional Authorization header or through one of the other methods mentioned above
5. The server decodes the JWT and if the token is valid processes the request
6. Once a user logs out, the token is destroyed client-side, no interaction with the server is necessary
Single sign on (SSO) Authentication
Sooner or later web development teams face one problem: you have developed an application at domain X and now you want your new deployment at domain Y to use the same login information as the other domain. In fact, you want more: you want users who are already logged-in at domain X to be already logged-in at domain Y. This is what SSO is all about.The obvious solution to this problem is to share session information across different domains. However, for security reasons, browsers enforce a policy known as the same origin policy. This policy dictates that cookies (and other locally stored data) can only be accessed by its creator (i.e. the domain that originally requested the data to be stored). In other words, domain X cannot access cookies from domain Y or vice versa. This is what SSO solutions solve in one way or the other: sharing session information across different domains.
Refereence URLs
https://stackoverflow.com/questions/40200413/sessions-vs-token-based-authentication
https://auth0.com/blog/cookies-vs-tokens-definitive-guide/
https://security.stackexchange.com/questions/81756/session-authentication-vs-token-authentication
https://auth0.com/blog/what-is-and-how-does-single-sign-on-work/
Session, Token and SSO 有什么区别的更多相关文章
- Session、Cookie、Cache、Token分别是什么及区别
一.Session 1 )Session 解释 Session 是单用户的会话状态.当用户访问网站时,产生一个 sessionid.并存在于 cookies中.每次向服务器请求时,发送这个 cooki ...
- Python Web学习笔记之Cookie,Session,Token区别
一.Cookie,Session,Token简介 # 这三者都解决了HTTP协议无状态的问题 session ID or session token is a piece of data that i ...
- cookie,session,token之间的联系与区别
发展史 1.很久很久以前,Web 基本上就是文档的浏览而已, 既然是浏览,作为服务器, 不需要记录谁在某一段时间里都浏览了什么文档,每次请求都是一个新的HTTP协议, 就是请求加响应, 尤其是我不用 ...
- cookie,session,token的定义及区别
参考了很多文章总结的. 1.cookie(储存在用户本地终端上的数据) 服务器生成,发送给浏览器,浏览器保存,下次请求同一网站再发送给服务器. 2.session(会话) a.代表服务器与浏览器的一次 ...
- cookie & session & token compare
cookie & session & token compare cookie.session.token 区别和优缺点 存储位置 cookie 存在 client 端 session ...
- cookie, session, token 是什么 以及相应的安全考量
Cookie cookie 最常见的是用来保存一些账号信息,比如下图里的 记住账号 就是记录到了cookie里面 cookie 更主要的是针对和server通信的,我们知道http 是无状态的,那如果 ...
- cookie session token详解
cookie session token详解 转自:http://www.cnblogs.com/moyand/ 发展史 1.很久很久以前,Web 基本上就是文档的浏览而已, 既然是浏览,作为服务器, ...
- cookie,session,token介绍
本文目录 发展史 Cookie Session Token 回到目录 发展史 1.很久很久以前,Web 基本上就是文档的浏览而已, 既然是浏览,作为服务器, 不需要记录谁在某一段时间里都浏览了什么文档 ...
- SESSION和cookie的使用和区别
PHP中SESSION和cookie的使用和区别 cookie 是一种在远程浏览器端储存数据并以此来跟踪和识别用户的机制. PHP在http协议的头信息里发送cookie, 因此 setcookie( ...
随机推荐
- 【数据库】——SQLite使用drop column删除表字段
由于项目需求变更,我需要在sqlite的表中删除一个字段,通用的sql操作语句如下: alter table task drop column custom_fields; 结果数据库提示如下错误: ...
- myeclipse16怎么去掉项目中的CodeLive Panel?
http://www.jb51.net/softjc/524823.html —————————————————————————————————————————————————— 在Servers视图 ...
- mac:Go安装和配置+GoLand安装和使用之完整教程
前言 作为一个go语言程序员,觉得自己有义务为go新手开一条更简单便捷的上手之路.纵使网上教程很多,但总不尽人意.go的入门门槛还是非常低的,无论是安装还是使用. go安装 go 语言支持以下系统: ...
- python设计模式之猴子补丁模式
1.所有书中都没有把猴子补丁作为一种设计模式来看待.因为设计模式的模式的命名是根据java中提炼出来的,语言方式决定了java绝对不会有也不需要有这种操作,不存在的.那自然设计模式不会包括猴子补丁模式 ...
- 最强Android书 架构大剖析 作者网站
http://newandroidbook.com/ jonathan levin (最强Android书 架构大剖析) http://newandroidbook.com/AIvI-M-R ...
- kubernetes-deployments
Kubernetes令部署应用.管理应用变得简单直白,令大多数操作简化为单个API或单个命令行,包括发布新的应用程序,升级.那么为什么我们还需要部署呢? 自动化Deployment和滚动更新程序.相比 ...
- Golang pprof详解
go的pprof包 go中有pprof包来做代码的性能监控,在两个地方有包: net/http/pprof runtime/pprof 其实net/http/pprof中只是使用runtime/ppr ...
- Linux下的awk文本分析命令实例(二)
awk实现求和.平均.最大值和最小值的计算操作 准备和数据文件 [finance@master2-dev ~]$ cat data.txt 求和 [finance@master2-dev ~]$ ca ...
- python set和get实现
import math class Square: # 正方形 def __init__(self, l): self.length = l # 边长 def __setattr__(self, ke ...
- cf 938E
哇自闭了. 一样个毛啊. 和之前见过的几道感觉很类似啊. 首先一个数如果有贡献那么在他后面一定有一个大于它的数,并且前面的全比他小,然后我就跑偏了... 于是我们先排个序,显然无影响,我们可以考虑从 ...