HTTP Basic/Digest Authentication、OAuth

HTTP Authentication

[code]
auth-scheme = token
auth-param = token "=" ( token | quoted-string )
challenge = auth-scheme 1*SP 1#auth-param
[/code]
The 401 (Unauthorized) response message is used by an origin server to challenge the authorization of a user agent
This response MUST include a WWW-Authenticate header field containing at least one challenge applicable to the requested resource
The 407 (Proxy Authentication Required) response message is used by a proxy to challenge the authorization of a client and MUST include a Proxy-Authenticate header field containing at least one challenge applicable to the proxy for the requested resource
[code]
D:\projects\maui>curl -I http://ar-code.svn.engineyard.com/
HTTP/1.1 401 Authorization Required
Date: Fri, 09 Jan 2009 04:15:16 GMT
Server: Apache
WWW-Authenticate: Basic realm="Engine Yard SVN Cluster: ar-code"
Content-Type: text/html; charset=iso-8859-1
[/code]
The authentication parameter realm is defined for all authentication schemes:
[code]
realm = "realm" "=" realm-value
realm-value = quoted-string
[/code]

A user agent that wishes to authenticate itself with an origin server--usually, but not necessarily, after receiving a 401 (Unauthorized)--MAY do so by including an Authorization header field with the request
A client that wishes to authenticate itself with a proxy--usually, but not necessarily, after receiving a 407 (Proxy Authentication Required)--MAY do so by including a Proxy-Authorization header field with the request
[code]
credentials = auth-scheme #auth-param
[/code]

[b]Basic Access Authentication Scheme[/b]
The "basic" authentication scheme is based on the model that the client must authenticate itself with a user-ID and a password for each realm
The realm value should be considered an opaque string which can only be compared for equality with other realms on that server
[code]
challenge = "Basic" realm
credentials = "Basic" basic-credentials
[/code]
[code]
WWW-Authenticate: Basic realm="WallyWorld"
[/code]
To receive authorization, the client sends the userid and password, separated by a single colon (":") character, within a base64 encoded string in the credentials
[code]
basic-credentials = base64-user-pass
base64-user-pass = <base64 encoding of user-pass, except not limited to 76 char/line>
user-pass = userid ":" password
userid = *<TEXT excluding ":">
password = *TEXT
[/code]
[code]
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
[/code]

[b]Digest Access Auhtenticaton Scheme[/b]
Basic Authentication Scheme is not considered to be a secure method of user authentication, as the user name and password are passed over the network in an unencrypted form
The Digest scheme challenges using a nonce value. A valid response contains a checksum (by default, the MD5 checksum) of the username, the password, the given nonce value, the HTTP method, and the requested URI
The WWW-Authenticate Response Header:
[code]
challenge = "Digest" digest-challenge

digest-challenge = 1#( realm | [ domain ] | nonce |
[ opaque ] |[ stale ] | [ algorithm ] |
[ qop-options ] | [auth-param] )


domain = "domain" "=" <"> URI ( 1*SP URI ) <">
URI = absoluteURI | abs_path
nonce = "nonce" "=" nonce-value
nonce-value = quoted-string
opaque = "opaque" "=" quoted-string
stale = "stale" "=" ( "true" | "false" )
algorithm = "algorithm" "=" ( "MD5" | "MD5-sess" |
token )
qop-options = "qop" "=" <"> 1#qop-value <">
qop-value = "auth" | "auth-int" | token
[/code]
The Authorization Request Header:
[code]
credentials = "Digest" digest-response
digest-response = 1#( username | realm | nonce | digest-uri
| response | [ algorithm ] | [cnonce] |
[opaque] | [message-qop] |
[nonce-count] | [auth-param] )

username = "username" "=" username-value
username-value = quoted-string
digest-uri = "uri" "=" digest-uri-value
digest-uri-value = request-uri ; As specified by HTTP/1.1
message-qop = "qop" "=" qop-value
cnonce = "cnonce" "=" cnonce-value
cnonce-value = nonce-value
nonce-count = "nc" "=" nc-value
nc-value = 8LHEX
response = "response" "=" request-digest
request-digest = <"> 32LHEX <">
LHEX = "0" | "1" | "2" | "3" |
"4" | "5" | "6" | "7" |
"8" | "9" | "a" | "b" |
"c" | "d" | "e" | "f"
[/code]
The Authentication-Info header is used by the server to communicate some information regarding the successful authentication in the response
[code]
AuthenticationInfo = "Authentication-Info" ":" auth-info
auth-info = 1#(nextnonce | [ message-qop ]
| [ response-auth ] | [ cnonce ]
| [nonce-count] )
nextnonce = "nextnonce" "=" nonce-value
response-auth = "rspauth" "=" response-digest
response-digest = <"> *LHEX <">
[/code]
Example:
[code]
HTTP/1.1 401 Unauthorized
WWW-Authenticate: Digest
realm="testrealm@host.com",
qop="auth,auth-int",
nonce="dcd98b7102dd2f0e8b11d0f600bfb0c093",
opaque="5ccc069c403ebaf9f0171e9517f40e41"

Authorization: Digest username="Mufasa",
realm="testrealm@host.com",
nonce="dcd98b7102dd2f0e8b11d0f600bfb0c093",
uri="/dir/index.html",
qop=auth,
nc=00000001,
cnonce="0a4f113b",
response="6629fae49393a05397450978507c4ef1",
opaque="5ccc069c403ebaf9f0171e9517f40e41"
[/code]

The most serious flaw in Basic authentication is that it results in the essentially cleartext transmission of the user's password over the physical network

Before transmission, the username and password are encoded as a sequence of base-64 characters
For example, the user name Aladdin and password open sesame would be combined as Aladdin:open sesame – which is equivalent to QWxhZGRpbjpvcGVuIHNlc2FtZQ== when encoded in Base64
Little effort is required to translate the encoded string back into the user name and password, and many popular security tools will decode the strings "on the fly"

Digest Authentication does not provide a strong authentication mechanism, when compared to public key based mechanisms, for example
However, it is significantly stronger than (e.g.) CRAM-MD5, which has been proposed for use with LDAP, POP and IMAP (see RFC 2195)
It is intended to replace the much weaker and even more dangerous Basic mechanism
Digest authentication is basically an application of MD5 cryptographic hashing with usage of nonce values to prevent cryptanalysis

[color=red]Any service in present use that uses Basic should be switched to Digest as soon as practical[/color]

[b]OAuth[/b]
OAuth is an open protocol, initiated by Blaine Cook and Chris Messina, to allow secure API authorization in a simple and standard method for desktop, mobile and web applications
WWW-Authenticate Header:
[code]
WWW-Authenticate: OAuth realm="http://sp.example.com/"
[/code]
Authorization Header:
[code]
Authorization: OAuth realm="http://sp.example.com/",
oauth_consumer_key="0685bd9184jfhq22",
oauth_token="ad180jjd733klru7",
oauth_signature_method="HMAC-SHA1",
oauth_signature="wOJIO9A2W5mFwDgiDvZbTSMK%2FPY%3D",
oauth_timestamp="137131200",
oauth_nonce="4572616e48616d6d65724c61686176",
oauth_version="1.0"
[/code]
[url=http://oauth.net/core/1.0]OAuth Core 1.0[/url], the main protocol, was finalized in December
It is stable and ready to be implemented
[url=http://oauth.net/code]Libraries[/url] are already available for many popular platforms such as PHP, Rails, Python, .NET, C, and Perl
HTTP认证演进:从Basic到JWT与OAuth 2.0的完整指南 认证是Web应用安全的核心基础,它解决了HTTP无状态协议下的用户身份识别问题。其原理是通过凭证验证机制,在客户端与服务器之间建立信任关系。这项技术的价值在于为分布式系统提供可扩展的身份管理方案,并保障API通信的安全边界。当前主流应用场景涵盖传统Web登录、前后端分离架构、微服务间调用及第三方平台集成。本文聚焦JWT和OAuth 2.0等现代认证协议,深入解析其实现机制与工程实践中的关键考量。 阅读详情

相关推荐

Ubuntu 18.04下Apache HTTP Basic认证配置全解

HTTP Basic认证是一种轻量级、无状态的Web访问控制机制,基于RFC 7617标准,通过Authorization请求头传输Base64编码的凭据。其核心原理是服务端校验用户名密码哈希(如bcrypt或APR-MD5),无需会话管理或数据库依赖,具备低延迟、高兼容性与部署简易的技术价值。典型应用场景包括内部测试页、静态文档库、监控面板等需快速启用密码保护的轻量级服务。在Ubuntu 18.04系统中,结合a2enmod启用mod_auth_basic模块、htpasswd生成加密密码文件,并通过Al

weixin_34226182的博客 310

HTTP Digest Authentication 使用心得

浏览器弹出这个原生的对话框,想必大家都不陌生,就是 HTTP Baisc 认证的机制。这是浏览器自带的,遵循 RFC2617/7617 协议。但必须指出的是,遇到这界面,不一定是 Basic Authentication,也可能是 Digest Authentication。可參照了解更多。Basic 为最简单版本,密码就用 Base64 编码一下,安全性低等于裸奔,好处是够简单;今天说的 Digest,不直接使用密码,而是密码的 MD5。虽说不是百分百安全(也不存在百分百)但安全性立马高级很多。

zhangxin09的专栏 2106

RFC 2617中文版(HTTP Digest Authentication)

RFC2617描述了HTTP Digest Authentication,这个是中文版,根据原英文版进行了校正,并重新排版。

http digest鉴权流程

通过哈希加密技术确保用户凭据的安全性,避免密码明文传输。客户端和服务器交换信息时会使用nonce和URI等动态元素来增加安全性。通过这种方式,即使攻击者窃取了传输的数据,也无法恢复出原始密码,因为哈希值不可逆。这种方式比 Basic Authentication 更为安全,因为它不会在每次请求中发送明文密码,并且能够防止重放攻击和中间人攻击。

qq_22325611的博客 1749

Windows 2012 SYSVOL复制失败的处理

题外话:晓原理、知架构、查日志是排错的三件法宝今天在DC1上新建并链接了一个组策略对像,在客户端刷新时,却报下面的错误:“处理组策略失败。Windows无法应用组策略对象LDAP….”如下图所示:于是在客户端用\\domain.com访问,发现\\domain.com\SYSVOL\domain.com\policies下面没有上面报错的组策略对象。这是怎么一回事呢,pin...

weixin_33989780的博客 1669

Fofa API高阶玩法:用Python批量获取漏洞资产(含OA系统扫描实战)

本文详细介绍了如何利用Python结合Fofa API实现自动化漏洞资产收集的高阶实战技巧。通过构建健壮的客户端、设计精准查询语法、实现多线程批量采集,并以OA系统漏洞扫描为例,演示了从资产发现、过滤验证到报告生成的全流程,旨在提升安全运维与应急响应的效率。

weixin_28607671的博客 497

http 权限控制和认证的通用方式,Http Basic authentication 和Http Digest authentication 分别是什么,区别

http 权限控制和认证的通用方式,Http Basic authentication 和Http Digest authentication 分别是什么,区别

weixin_45428910的博客 953

2024“华为杯”中国研究生数学建模竞赛(A题)深度剖析_数学建模完整过程+详细思路+代码全解析

目标是优化风力涡轮机的功率调度,使其在给定的实时风速数据下,最小化涡轮机关键组件(如塔架和主轴)的疲劳损伤。问题的挑战在于,考虑通信延迟和测量噪声的同时,要确保功率输出与风速变化的响应快速且准确。

2401_82549447的博客 6628

Java【算法 04】HTTP的认证方式之DIGEST认证详细流程说明及举例

Java【算法 04】HTTP的认证方式之DIGEST认证详细流程说明及举例

Java与大数据相关实践内容分享! 4011

i茅台APP加密参数逆向分析:MT-Device-ID与mt-v生成算法

在移动应用安全领域,参数加密是防止API滥用的重要手段。通过对通信协议的逆向分析,可以揭示加密参数的生成原理,这对理解移动应用安全机制具有重要意义。以i茅台APP为例,其关键接口使用了MT-Device-ID和mt-v两个加密参数,前者基于设备硬件信息生成,后者则通过动态签名机制确保请求时效性。这类技术广泛应用于电商、金融等需要高安全性的场景。通过抓包工具和逆向工程手段,可以还原出从设备指纹生成到动态签名的完整技术链条,其中涉及MD5、SHA256等常见哈希算法的应用。掌握这些加密参数的生成逻辑,不仅有助于

weixin_28568819的博客 320

利用ArcGIS创建渔网计算渔网内土地利用占比划分中国北方农牧交错带

依据土地利用数据,根据参考文献划分要求,利用ArcGIS创建渔网对地物进行重分类,划分农业带、牧业带以及农牧交错带。

m0_60672527的博客 3059

Digest, Basic, and Bearer Authentication

I recently posted aproblemI was having with authentication, but didn't receive any replies so I thought of another way to ask the question without being redundant. What I'm seeing in the applicationsdocumentationare three ways to pass the access token...

xiaokanfuchen86的博客 677

AutoSAR系列讲解(入门篇)2.2-SWC的类型

该章讲解了两种SWC的分类,并且映射到实际的工程中应该是具体的什么文件类型

雪云飞星的博客 4万+

Connect-auth HTTP认证指南:Basic、Digest和MAC认证的完整实现

🚀 在Node.js应用中实现安全可靠的HTTP认证是每个开发者的必修课。今天我们将深入探讨**connect-auth**这个强大的认证中间件,它提供了完整的HTTP认证解决方案,包括Basic、Digest和MAC三种主流认证方式。无论你是构建API服务还是Web应用,connect-auth都能为你提供专业级的认证保护。 ## 🔐 为什么选择connect-auth进行HTTP认证?

gitblog_00510的博客 693

通用抓取————6D位姿估计

这意味着算法在没有物体的先验知识(如 CAD 模型)的情况下,依然能够通过神经网络捕捉物体的外观、形状和几何特征,生成相关的 6D 位姿估计。通过输入物体类别的描述,算法能够推断出该类别物体的位姿和尺度,无需特定物体的 CAD 模型。在这个坐标空间中,物体的位姿和尺度都是已知的,基于这个标准化表示,算法可以对输入图像中的物体进行 6D 位姿和尺寸的估计。○优势: ICP 是一种非常有效的位姿优化算法,特别适合精细调整物体的位姿,确保最终估计的位姿与真实物体的点云或模型高度一致。

具身机器人和通用AI 2379

多出来的那一截:Java 堆外内存 OOM 的来源分账、分流排查与治理解析

Java进程的RES常比-Xmx多出一截,堆却平稳。本文把堆外内存拆成直接缓冲区、Unsafe、JNI本地库、线程栈、元空间与文件映射六类,用JDK 8与17的六组实验对照RSS、NMT、BufferPool三本账:clear()不释放内存;MaxDirectMemorySize默认约等于堆上限且只管直接缓冲区;禁用显式GC会让申请线程退避半秒后失败;未关闭的Deflater零GC下让RSS涨1GB;Netty池内泄漏GC救不回。最后给出定性、对账、定位的排查路线与预算、编码、监控三层治理。

曾经“等你生日那天”都遥远得像未来,如今却可欢愉的挥手说“下个十年见” 14万+

HTTP认证全解析:从Basic到OAuth 2.0,实战排错与安全实践

HTTP认证是现代Web安全的核心机制,它定义了客户端与服务器之间安全交换身份凭据的标准流程。其基本原理是挑战-应答模型,服务器通过401状态码和WWW-Authenticate头发起挑战,客户端则通过Authorization头进行应答。这一机制的技术价值在于为Web应用提供了标准化的身份验证基础,确保了资源访问的安全性。从简单的Basic认证到更安全的Digest认证,再到如今广泛应用的Bearer Token与OAuth 2.0授权框架,HTTP认证方案不断演进以适应不同安全需求。在实际应用场景中,无

weixin_30291791的博客 369

蓝牙模块HM-10手册

蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。

HTTP认证全解析:从Basic到OAuth 2.0,构建安全API网关实战

HTTP认证是Web安全的基础机制,它通过标准化的挑战-应答流程实现身份验证。其核心原理是服务器通过WWW-Authenticate头发起挑战,客户端使用Authorization头携带凭证应答。这一机制的技术价值在于为应用提供了协议层的统一认证方案,避免了各应用自行实现的安全不一致问题。在应用场景上,从内部工具的基础防护到现代分布式系统的API安全,HTTP认证都扮演着关键角色。本文聚焦Basic认证、Digest认证和Bearer Token三大类型,深入剖析其安全特性与适用场景,并针对常见的remot

weixin_30719711的博客 357

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

开发者必备知识 - HTTP 认证(HTTP Authentication)

本文介绍了HTTP认证的发展历程,从Basic、Digest到OAuth 1.0/2.0,再到JWT,展现其从简单凭证到令牌化、无状态、便于第三方集成的演进,适应现代Web与移动应用需求。

zhangxin09的专栏 1302

Spring Boot HTTP认证实战:从基础协议到JWT与OAuth2集成

认证是Web应用安全的第一道防线,它通过验证用户身份来保护资源访问。其原理基于HTTP协议标准或扩展的令牌机制,在服务端构建安全链路以确认请求者身份。这一技术的核心价值在于为应用提供可靠的身份识别与访问控制基础,是现代系统实现用户登录、API保护和第三方集成不可或缺的环节。在Spring Boot开发中,借助Spring Security框架,开发者可以高效实现表单登录、HTTP Basic、JWT等主流认证方案,并能集成OAuth2.0支持第三方登录。本文聚焦于**JWT**和**OAuth2.0**这两

weixin_33875564的博客 393

HTTP Authentication

First Authentication andAuthorization are different two concept. Http Base Auth Put user name and password inheader which in base64 encoding. HTTP Digest Auth Like Http Base, user name ...

weixin_30399055的博客 369

spring-security-oauth2授权服务原理

本文为Spring Security OAuth2 授权服务的源码解析

onePlus5T的博客 1488

Connect-auth:Node.js Connect框架的终极身份验证中间件完全指南

Connect-auth 是一款基于 Node.js Connect 框架的强大身份验证中间件,为开发者提供了丰富的身份验证策略,帮助快速构建安全可靠的用户认证系统。无论是简单的匿名访问控制,还是复杂的第三方 OAuth 登录集成,Connect-auth 都能提供一站式解决方案。 ## 为什么选择 Connect-auth? 🚀 在现代 Web 应用开发中,身份验证是保障系统安全的第一道防

gitblog_00970的博客 707

关于 RESTFUL API 安全认证方式的一些总结

RESTful API是基于HTTP协议的API(Application Programming Interface),它的核心是将所有的API都理解为一个网络资源,客户端请求资源时操作的是资源的表述而不是资源本身,每条请求都应包含足够的信息来让服务器知道如何处理该消息,即将所有的客户端和服务器的状态转移封装到HTTP请求的Method之中,它拥有Url唯一资源对应的特性。 由于RESTful Api是基于HTTP协议的API,并且是无状态传输,意味着服务器不会保存客户端的状态,每一次的调用和上一次调用请求

DreamSun的博客 2080

Ubuntu 18.04 + Apache 密码认证实战:5分钟启用HTTP Basic Auth

HTTP Basic Auth 是一种轻量级、协议原生的Web资源访问控制机制,基于RFC 7617标准,由Web服务器在应用层前完成凭证校验。其核心原理是通过Base64编码传输用户名密码,并依赖服务端模块(如Apache的mod_auth_basic)进行解码与比对。该方案技术价值突出:零依赖、低延迟、高兼容,且无需改动应用代码或引入数据库。典型应用场景包括测试环境门禁、后台管理区保护、临时演示站点隔离等对快速部署和运维简洁性要求极高的场合。本文聚焦Ubuntu 18.04系统下Apache 2.4环境

weixin_30603633的博客 366

前后端分离开发,六大方案全揭秘:HTTP API 认证授权术

文章作者:陈皓文章出处:https://coolshell.cn我们知道,HTTP 是无状态的,所以,当我们需要获得用户是否在登录的状态时,我们需要检查用户的登录状态,一般来说,用户的登...

emprere的博客 595
上一篇: URL/HTML/JavaScript的encode/escape
下一篇: BI architecture & MicroStrategy Platform
hidetobj
博客等级 码龄19年 16粉丝 301原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值