标签: digest-authentication

.Net Core HttpClient 摘要身份验证

在 .Net Core 3.1 应用程序中使用 Mongo Atlas API,但我无法HttpClient处理来自 Digest Authentication 的挑战。

该代码发送第一个请求,获得 401 响应,然后不通过正确的身份验证重新发送。

下面是我一直在努力工作的代码

var domain = "https://cloud.mongodb.com/";
var credCache = new CredentialCache();
credCache.Add(new Uri(domain),"Digest", new NetworkCredential(user,secret));
var httpClient = new HttpClient( new HttpClientHandler { Credentials = credCache});
var answer = await httpClient.GetAsync(new Uri($"{domain}api/atlas/v1.0/groups/{groupId}/databaseUsers"));
Run Code Online (Sandbox Code Playgroud)

这是我得到的回应

StatusCode: 401, ReasonPhrase: 'Unauthorized', Version: 1.1, Content: System.Net.Http.HttpConnectionResponseContent, Headers:
{
  Date: Mon, 27 Jan 2020 21:03:14 GMT
  WWW-Authenticate: Digest realm="MMS Public API", domain="", nonce="generatedNonce", algorithm=MD5, qop="auth", stale=false
  Content-Type: application/json
  Content-Length: 106
} …
Run Code Online (Sandbox Code Playgroud)

c# digest-authentication asp.net-core

3
推荐指数
1
解决办法
4029
查看次数

为什么加密哈希函数中的冲突检测会使查找其他冲突更容易?

从维基百科,我读到:

Joux [3]指出2次碰撞会导致n次碰撞:如果找到具有相同MD5散列的两条消息是可行的,那么找到与攻击者希望具有相同MD5哈希值一样多的消息实际上并不困难.

但为什么会这样呢?我无法想象为什么?算法是开放的,人们可以读取产生哈希的数学,这是摘要机制.因此,如果我们知道一次碰撞,为什么它有助于找到新的?

它只是对两个第一个碰撞消息进行小的迭代,然后监视它们的更改以重新映射它们吗?

security hash cryptography digest-authentication

2
推荐指数
1
解决办法
454
查看次数

Node.js中使用http.client进行摘要式身份验证的问题

我尝试在使用http.get时实现摘要请求,并且每次都得到" 摘要身份验证失败 "消息:(

var hashlib = require('hashlib'),
    http = require('http'),
    url = require('url'),
    qs = require('querystring'),
    hashlib = require('hashlib');


var username = 'user';
var password = 'pass';

var options = {
    'host' : 'username.livejournal.com',
    'path' : '/data/rss?auth=digest'
};

http.get(options, function(res) {
    res.setEncoding('utf-8');

    // got 401, okay
    res.on('data', function(chunk) {

        var authResponseParams = qs.parse(res.headers['www-authenticate'].substr(7), ', '); // cut "Digest "

        var ha1 = hashlib.md5(username + ':' + authResponseParams.realm + ':' + password);
        var ha2 = hashlib.md5('GET:' + options.path);
        var …
Run Code Online (Sandbox Code Playgroud)

digest-authentication node.js

2
推荐指数
1
解决办法
3154
查看次数

使用PHP POST到Web服务的摘要式身份验证的客户端部分

我正在尝试POST到Web服务(不是RESTful)并通过PHP获得响应.但是,该Web服务需要摘要式身份验证.

我一直在网上搜索,发现大多数讨论和文章是相反的(向用户请求摘要身份验证),而不是使用PHP响应它.

我能够使用此线程提供的代码生成摘要响应:PHP摘要在PHP中进行身份验证,但问题是与POST数据一起发送(或不发送?).

这是我正在使用的代码:

$domain = "https://api.example.com";
$uri = "/ws.asmx/do";

// get headers
$response1_array = get_headers($web_service_url);
// get request part of digest auth
$response1 = $response1_array[5];
// get things behind "WWW-Authenticate:"
$response1 = substr($response1, 18);

// response() is a invented function to calculate the response according to the RFC2617
$response2 = response($response1, "username", "password", "GET", $uri);

// manually add some headers for POST, and fill out the parts that the calculation function missed
// for auth
$header = …
Run Code Online (Sandbox Code Playgroud)

php digest-authentication

2
推荐指数
1
解决办法
1万
查看次数

如何使用摘要身份验证在 MongoDB Atlas API 进行身份验证?

我想使用其 API“ https://cloud.mongodb.com/api/atlas/v1.0/groups ”获取MongoDB 中的项目列表,但每次我收到错误消息“401 您无权使用此资源” ”。

根据文档摘要认证被使用。

似乎我以错误的方式传递 Private_key 和 Public_key 。

下面是我的请求对象

{
url: 'https://cloud.mongodb.com/api/atlas/v1.0/groups',
method: 'GET',
headers: {
  'Accept': 'application/json',
},
auth: {
  user: 'Public_Key',
  pass: 'Private_key'
  }
}  
Run Code Online (Sandbox Code Playgroud)

任何人都可以帮我解决这个问题。

authentication mongodb digest-authentication node.js mongodb-atlas

2
推荐指数
1
解决办法
949
查看次数

使用URLConnection进行摘要式身份验证

我正在实施单点登录功能,以使用摘要式身份验证自动登录到附属的https网站.目前我的代码是

URL url = new URL(protocol, ip, port, path);
URLConnection connection = url.openConnection(Proxy.NO_PROXY);
connection.connect();

if (connection != null && connection.getHeaderFields() != null) {
    if (connection.getHeaderFields().get(AUTHENTICATE_RESPONSE_HEADER) != null) {
        Map<String, String> authenticateParameters = identifyAuthentication(connection);

        String ha1 = calculateMD5(username + ":" + authenticateParameters.get("realm") + ":" + password);
        String ha2 = calculateMD5("GET" + ":" + path);
        String response = calculateMD5(ha1 + ":" + 
            authenticateParameters.get("nonce") + ":" +
            "00000001" + ":" +
            authenticateParameters.get("qop") + ":" +
            ha2);

            String authorizationRequest = authenticateParameters.get("challenge") + " " …
Run Code Online (Sandbox Code Playgroud)

java urlconnection digest-authentication

1
推荐指数
1
解决办法
5886
查看次数

如何解密该值

实际上我想从加密密码中取回密码.

密码加密如下:

MessageDigest md = MessageDigest.getInstance("SHA");
md.reset();
byte[] encryptedBinarySource = md.digest(source.getBytes("UTF-8"));
Run Code Online (Sandbox Code Playgroud)

如何解密价值encryptedBinarySource

java encryption digest-authentication cryptographic-hash-function

1
推荐指数
1
解决办法
2146
查看次数

Tomcat 9 DIGEST with JDBCRealm - 只接受摘要,不接受密码

新安装的 tomcat 9 - 并将应用程序从 tomcat 8 迁移到 tomcat 9。

验证我的配置是使用带有 mysql 数据库的 JDBCRealm。下面的配置在 tomcat 8 上运行得非常好,但在 tomcat 9 上,它只直接接受密码摘要,而不是直接接受“人类”密码(摘要存储在 tomcat_users 表中),而不是直接接受通常的密码。因此,当在 FORM 登录页面中提交人类可读的密码时,摘要算法 MD5 似乎不会在这里执行。

server.xml 里面的配置是

<Realm className="org.apache.catalina.realm.JDBCRealm" connectionName=“..." connectionPassword=“..." connectionURL="jdbc:mysql://127.0.0.1:3306/TOMSCHEMA" digest="MD5" driverName="org.gjt.mm.mysql.Driver" roleNameCol="role_name" userCredCol="password" userNameCol="user_name" userRoleTable="tomcat_users_roles" userTable="tomcat_users"/>
Run Code Online (Sandbox Code Playgroud)

一个应用程序的认证方法是 FORM,另一个应用程序内部相应的 API 是 DIGEST。这两个应用程序在交叉上下文中看到彼此。应用程序的 web.xml 包含:

<login-config>
    <auth-method>FORM</auth-method>
    <realm-name>NAME</realm-name>
    <form-login-config>
        <form-login-page>/WEB-INF/security/protected/login.jsp</form-login-page>
        <form-error-page>/WEB-INF/security/protected/error.jsp</form-error-page>
    </form-login-config>
</login-config>
Run Code Online (Sandbox Code Playgroud)

这里可能有什么问题?这一切都非常“标准”......我做了什么外壳才能再次使用 FORM 身份验证页面使用 DIGEST 输入人工密码,就像我在 tomcat 8 中一样?

非常感谢您提前

问候

tomcat digest-authentication jdbcrealm

1
推荐指数
1
解决办法
1623
查看次数