mirror of
https://github.com/foss42/apidash.git
synced 2025-12-04 03:46:57 +08:00
refactor for digest
This commit is contained in:
@@ -23,6 +23,9 @@ enum APIAuthType {
|
||||
final String displayType;
|
||||
}
|
||||
|
||||
const kDigestAlgos = ['MD5', 'MD5-sess', 'SHA-256', 'SHA-256-sess'];
|
||||
const kQop = ['auth', 'auth-int'];
|
||||
|
||||
enum HTTPVerb {
|
||||
get("GET"),
|
||||
head("HEAD"),
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:math' as math;
|
||||
|
||||
import 'package:convert/convert.dart';
|
||||
import 'package:crypto/crypto.dart' as crypto;
|
||||
import '../../consts.dart';
|
||||
import '../../models/models.dart';
|
||||
|
||||
Map<String, String>? splitAuthenticateHeader(String header) {
|
||||
@@ -130,7 +130,7 @@ Map<String, String?> computeResponse(
|
||||
if (qop == null) {
|
||||
final token3 = '$ha1:$nonce:$ha2';
|
||||
ret['response'] = md5Hash(token3);
|
||||
} else if (qop == 'auth' || qop == 'auth-int') {
|
||||
} else if (kQop.contains(qop)) {
|
||||
final token3 = '$ha1:$nonce:$nonceCount:$cnonce:$qop:$ha2';
|
||||
ret['response'] = md5Hash(token3);
|
||||
}
|
||||
@@ -138,7 +138,7 @@ Map<String, String?> computeResponse(
|
||||
if (qop == null) {
|
||||
final token3 = '$ha1:$nonce:$ha2';
|
||||
ret['response'] = sha256Hash(token3);
|
||||
} else if (qop == 'auth' || qop == 'auth-int') {
|
||||
} else if (kQop.contains(qop)) {
|
||||
final token3 = '$ha1:$nonce:$nonceCount:$cnonce:$qop:$ha2';
|
||||
ret['response'] = sha256Hash(token3);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user