mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-21 23:20:23 +00:00
Rework ssh host key trust handling
This commit is contained in:
parent
74d6ff7fa3
commit
ccea37e0e0
3 changed files with 11 additions and 5 deletions
|
@ -24,7 +24,7 @@ public class AskpassAlert {
|
|||
alert.setAlertType(Alert.AlertType.CONFIRMATION);
|
||||
|
||||
// Link to help page for double prompt
|
||||
if (!SecretManager.shouldCacheForPrompt(prompt)) {
|
||||
if (SecretManager.isSpecialPrompt(prompt)) {
|
||||
var type = new ButtonType("Help", ButtonBar.ButtonData.HELP);
|
||||
alert.getButtonTypes().add(type);
|
||||
var button = alert.getDialogPane().lookupButton(type);
|
||||
|
|
|
@ -47,13 +47,19 @@ public class SecretManager {
|
|||
return p;
|
||||
}
|
||||
|
||||
public static boolean shouldCacheForPrompt(String prompt) {
|
||||
public static boolean isSpecialPrompt(String prompt) {
|
||||
var l = prompt.toLowerCase(Locale.ROOT);
|
||||
// 2FA
|
||||
if (l.contains("passcode") || l.contains("verification code")) {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
// SSH host key trust prompt
|
||||
if (l.contains("authenticity of host") || l.contains("please type 'yes', 'no' or the fingerprint")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static SecretValue retrieve(SecretRetrievalStrategy strategy, String prompt, UUID secretId, int sub) {
|
||||
|
|
|
@ -115,7 +115,7 @@ public class SecretQueryProgress {
|
|||
|
||||
private boolean shouldCache(SecretQuery query, String prompt) {
|
||||
var shouldCache = query.cache()
|
||||
&& SecretManager.shouldCacheForPrompt(prompt)
|
||||
&& !SecretManager.isSpecialPrompt(prompt)
|
||||
&& (!query.respectDontCacheSetting()
|
||||
|| !AppPrefs.get().dontCachePasswords().get());
|
||||
return shouldCache;
|
||||
|
|
Loading…
Reference in a new issue