mirror of
https://github.com/foss42/apidash.git
synced 2025-12-01 18:28:25 +08:00
Merge branch 'foss42:main' into add-feature-oauth-2
This commit is contained in:
@@ -91,10 +91,91 @@ HttpRequestModel substituteHttpRequestModel(
|
||||
);
|
||||
}).toList(),
|
||||
body: substituteVariables(httpRequestModel.body, combinedEnvVarMap),
|
||||
authModel:
|
||||
substituteAuthModel(httpRequestModel.authModel, combinedEnvVarMap),
|
||||
);
|
||||
return newRequestModel;
|
||||
}
|
||||
|
||||
AuthModel? substituteAuthModel(
|
||||
AuthModel? authModel, Map<String, String> envVarMap) {
|
||||
if (authModel == null) return null;
|
||||
|
||||
switch (authModel.type) {
|
||||
case APIAuthType.basic:
|
||||
if (authModel.basic != null) {
|
||||
final basic = authModel.basic!;
|
||||
return authModel.copyWith(
|
||||
basic: basic.copyWith(
|
||||
username: substituteVariables(basic.username, envVarMap) ??
|
||||
basic.username,
|
||||
password: substituteVariables(basic.password, envVarMap) ??
|
||||
basic.password,
|
||||
),
|
||||
);
|
||||
}
|
||||
break;
|
||||
case APIAuthType.bearer:
|
||||
if (authModel.bearer != null) {
|
||||
final bearer = authModel.bearer!;
|
||||
return authModel.copyWith(
|
||||
bearer: bearer.copyWith(
|
||||
token: substituteVariables(bearer.token, envVarMap) ?? bearer.token,
|
||||
),
|
||||
);
|
||||
}
|
||||
break;
|
||||
case APIAuthType.apiKey:
|
||||
if (authModel.apikey != null) {
|
||||
final apiKey = authModel.apikey!;
|
||||
return authModel.copyWith(
|
||||
apikey: apiKey.copyWith(
|
||||
key: substituteVariables(apiKey.key, envVarMap) ?? apiKey.key,
|
||||
name: substituteVariables(apiKey.name, envVarMap) ?? apiKey.name,
|
||||
),
|
||||
);
|
||||
}
|
||||
break;
|
||||
case APIAuthType.jwt:
|
||||
if (authModel.jwt != null) {
|
||||
final jwt = authModel.jwt!;
|
||||
return authModel.copyWith(
|
||||
jwt: jwt.copyWith(
|
||||
secret: substituteVariables(jwt.secret, envVarMap) ?? jwt.secret,
|
||||
privateKey: substituteVariables(jwt.privateKey, envVarMap) ??
|
||||
jwt.privateKey,
|
||||
payload: substituteVariables(jwt.payload, envVarMap) ?? jwt.payload,
|
||||
),
|
||||
);
|
||||
}
|
||||
break;
|
||||
case APIAuthType.digest:
|
||||
if (authModel.digest != null) {
|
||||
final digest = authModel.digest!;
|
||||
return authModel.copyWith(
|
||||
digest: digest.copyWith(
|
||||
username: substituteVariables(digest.username, envVarMap) ??
|
||||
digest.username,
|
||||
password: substituteVariables(digest.password, envVarMap) ??
|
||||
digest.password,
|
||||
realm: substituteVariables(digest.realm, envVarMap) ?? digest.realm,
|
||||
nonce: substituteVariables(digest.nonce, envVarMap) ?? digest.nonce,
|
||||
qop: substituteVariables(digest.qop, envVarMap) ?? digest.qop,
|
||||
opaque:
|
||||
substituteVariables(digest.opaque, envVarMap) ?? digest.opaque,
|
||||
),
|
||||
);
|
||||
}
|
||||
break;
|
||||
case APIAuthType.oauth1:
|
||||
case APIAuthType.oauth2:
|
||||
case APIAuthType.none:
|
||||
break;
|
||||
}
|
||||
|
||||
return authModel;
|
||||
}
|
||||
|
||||
List<EnvironmentVariableSuggestion>? getEnvironmentTriggerSuggestions(
|
||||
String query,
|
||||
Map<String, List<EnvironmentVariableModel>> envMap,
|
||||
|
||||
@@ -21,7 +21,7 @@ Color getResponseStatusCodeColor(int? statusCode,
|
||||
}
|
||||
}
|
||||
if (brightness == Brightness.dark) {
|
||||
col = getDarkModeColor(col);
|
||||
col = col.toDark;
|
||||
}
|
||||
return col;
|
||||
}
|
||||
@@ -38,7 +38,7 @@ Color getAPIColor(
|
||||
APIType.graphql => kColorGQL,
|
||||
};
|
||||
if (brightness == Brightness.dark) {
|
||||
col = getDarkModeColor(col);
|
||||
col = col.toDark;
|
||||
}
|
||||
return col;
|
||||
}
|
||||
@@ -57,13 +57,6 @@ Color getHTTPMethodColor(HTTPVerb? method) {
|
||||
return col;
|
||||
}
|
||||
|
||||
Color getDarkModeColor(Color col) {
|
||||
return Color.alphaBlend(
|
||||
col.withValues(alpha: kOpacityDarkModeBlend),
|
||||
kColorWhite,
|
||||
);
|
||||
}
|
||||
|
||||
double? getJsonPreviewerMaxRootNodeWidth(double w) {
|
||||
if (w < 300) {
|
||||
return 150;
|
||||
|
||||
Reference in New Issue
Block a user