mirror of
https://github.com/foss42/apidash.git
synced 2025-12-03 03:17:00 +08:00
refactor: remove unused digest authentication model import and clean up JWT handling comments
This commit is contained in:
@@ -3,7 +3,6 @@ import 'dart:math' as math;
|
|||||||
|
|
||||||
import 'package:convert/convert.dart';
|
import 'package:convert/convert.dart';
|
||||||
import 'package:crypto/crypto.dart' as crypto;
|
import 'package:crypto/crypto.dart' as crypto;
|
||||||
import '../../models/auth/auth_digest_model.dart';
|
|
||||||
import '../../models/models.dart';
|
import '../../models/models.dart';
|
||||||
|
|
||||||
Map<String, String>? splitAuthenticateHeader(String header) {
|
Map<String, String>? splitAuthenticateHeader(String header) {
|
||||||
@@ -221,17 +220,4 @@ class DigestAuth {
|
|||||||
final authString = 'Digest $authValuesString';
|
final authString = 'Digest $authValuesString';
|
||||||
return authString;
|
return authString;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Use this function
|
|
||||||
void initFromAuthenticateHeader(String /*!*/ authInfo) {
|
|
||||||
final values = splitAuthenticateHeader(authInfo);
|
|
||||||
if (values != null) {
|
|
||||||
_algorithm = values['algorithm'] ?? _algorithm;
|
|
||||||
_qop = values['qop'] ?? _qop;
|
|
||||||
_realm = values['realm'] ?? _realm;
|
|
||||||
_nonce = values['nonce'] ?? _nonce;
|
|
||||||
_opaque = values['opaque'] ?? _opaque;
|
|
||||||
_nc = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,12 +53,9 @@ Future<HttpRequestModel> handleAuth(
|
|||||||
case APIAuthType.jwt:
|
case APIAuthType.jwt:
|
||||||
if (authData.jwt != null) {
|
if (authData.jwt != null) {
|
||||||
final jwtAuth = authData.jwt!;
|
final jwtAuth = authData.jwt!;
|
||||||
|
|
||||||
// Generate JWT token
|
|
||||||
final jwtToken = generateJWT(jwtAuth);
|
final jwtToken = generateJWT(jwtAuth);
|
||||||
|
|
||||||
if (jwtAuth.addTokenTo == 'header') {
|
if (jwtAuth.addTokenTo == 'header') {
|
||||||
// Add to request header with prefix
|
|
||||||
final headerValue = jwtAuth.headerPrefix.isNotEmpty
|
final headerValue = jwtAuth.headerPrefix.isNotEmpty
|
||||||
? '${jwtAuth.headerPrefix} $jwtToken'
|
? '${jwtAuth.headerPrefix} $jwtToken'
|
||||||
: jwtToken;
|
: jwtToken;
|
||||||
@@ -67,7 +64,6 @@ Future<HttpRequestModel> handleAuth(
|
|||||||
);
|
);
|
||||||
updatedHeaderEnabledList.add(true);
|
updatedHeaderEnabledList.add(true);
|
||||||
} else if (jwtAuth.addTokenTo == 'query') {
|
} else if (jwtAuth.addTokenTo == 'query') {
|
||||||
// Add to query parameters(if selected)
|
|
||||||
final paramKey = jwtAuth.queryParamKey.isNotEmpty
|
final paramKey = jwtAuth.queryParamKey.isNotEmpty
|
||||||
? jwtAuth.queryParamKey
|
? jwtAuth.queryParamKey
|
||||||
: 'token';
|
: 'token';
|
||||||
|
|||||||
Reference in New Issue
Block a user