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

【顾邦小讲堂】第十九期 RC Snubber吸收电路详解:抑制MOSFET振铃现象与过冲的设计技巧!

通过RC Snubber电路有效抑制MOSFET DS端的过冲及振铃现象,帮助工程师们在设计中提升电路的稳定性和可靠性

GBupupup的博客 3787

eDP接口信号组成认识

eDP接口信号主要由Main Link、AUXCH与HPD三部分组成,如下图所示。 Main Link:表示主通道,用来传输各类型视频数据和音频数据; AUX CH:表示辅助通道,用于传输低带宽需求的数据,以及链路管理和设备控制信号; HPD:表示热插拔检测通道。 Main Link南1~4对数据线组成,每对数据线都是一对差分线。对于一款液晶屏而言,Main Link具体需几对数据线,这取决于屏幕的分辨率和彩色位数。 在该通道中传送的信号有视频像素信号、视频定时信号、视频格式信号、比特/像素及

精诚所至 2万+

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

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

weixin_45428910的博客 953

虚幻引擎5 AR开发教程02:构建和测试AR Android App

在本教程中,我们将学习如何在虚幻引擎 5 上构建和测试 AR 安卓应用。

mopanchun的博客 2650

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

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

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

MaxEnt物种分布预测中的常见误区与优化技巧:如何提高模型准确率

本文深入探讨了MaxEnt物种分布预测模型从基础应用到精准预测的进阶实践。针对模型准确率提升,文章系统分析了环境变量筛选、模型参数调优、结果批判性解读等核心环节的常见误区,并提供了基于生态位模型原理的深度优化技巧,帮助研究者产出更可靠、可解释的预测结果。

weixin_29219539的博客 594

Windows11+VS2022驱动开发环境搭建实战:从零到编译(避坑指南)

本文详细介绍了在Windows11系统下使用VS2022搭建驱动开发环境的完整流程,包括版本匹配、工具安装、环境配置及常见问题解决。重点强调了WDK与系统版本的严格匹配,以及VS2022中驱动开发组件的正确配置方法,帮助开发者高效避坑并成功编译第一个驱动程序。

weixin_29251337的博客 527

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

HexView 脚本自动化工具:从刷写文件处理到批量转换实战

本文详细介绍了如何利用HexView脚本自动化工具高效处理嵌入式刷写文件。通过实战演示,文章展示了如何使用bat脚本实现S19、HEX等格式文件的剪切、填充、合并与批量转换,构建自动化流水线,从而显著提升汽车电子等领域的开发与生产效率。

weixin_29237635的博客 356

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

搭建问答系统

数据描述 import docx import jieba from gensim.models import Word2Vec import os import numpy as np import pickle as pk import warnings from copy import deepcopy warnings.filterwarnings("ignore") from mu...

微信号:RunsenLiu 1840

【YOLOv8系列】YOLOv8的webUI界面设计;通过Streamlit实现YOLOv8的可视化交互界面设计

但是我为了避免重复性的工作,且为了避免重复安装之前(安装pytorch和yolov8时)已经安装好的库,因此写了一个python脚本进行安装;需要提前在有网络连接的电脑上下载所有必要的依赖项,然后将这些文件传输到离线的机器上进行安装。脚本将自动跳过已安装的包,并安装其余的 .whl 文件。在离线的机器上,切换到包含下载好的文件的目录。证明我们的streamlit安装成功了。证明你的streamlit安装成功了。第一步:在有网络连接的电脑上下载。第二步:将下载的文件传输到离线机器。文件)传输到离线的机器上。

AnChenliang_1002的博客 1566

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

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

weixin_30291791的博客 369

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

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

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

weixin_30719711的博客 357

pscad IEEE标准系统搭建说明

pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

开发者必备知识 - 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、付费专栏及课程。

余额充值