-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(registrar): allow more SSH key types
- Extended check on SSH keys validity to support more key types.
- Loading branch information
Showing
2 changed files
with
16 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,11 @@ | |
*/ | ||
public class SshKeysTextAreaValidator extends TextAreaValidator { | ||
|
||
RegExp regExp = RegExp.compile("^(ssh-rsa|ssh-dsa|ecdsa-sha2-nistp256|ecdsa-sha2-nistp384|ecdsa-sha2-nistp521|ssh-ed25519|sk-ed25519|sk-ecdsa) (([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)?)( [^,\n]+)?$"); | ||
RegExp regExp = RegExp.compile("^(" + | ||
"(ssh-(rsa|dss|ed25519)([email protected])?)|" + | ||
"(sk-(ssh-ed25519|ecdsa-sha2-nistp256)(-cert-v01)[email protected])|" + | ||
"(ecdsa-sha2-nistp(256|384|521)([email protected])?))" + | ||
" (([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)?)( [^,\n]+)?$"); | ||
|
||
@Override | ||
public boolean validateLocal(TextArea textArea) { | ||
|
@@ -65,6 +69,8 @@ public boolean validateLocal(TextArea textArea) { | |
return false; | ||
} | ||
|
||
// FIXME - this doesn't make sense anymore, as we have multiple different SSH keys prefixes, which needs to be checked. | ||
/* | ||
if (sshKeys.indexOf("ssh-") != sshKeys.lastIndexOf("ssh-")) { | ||
// there are at least two keys | ||
if (!sshKeys.contains(",ssh-") && !sshKeys.contains("\nssh-")) { | ||
|
@@ -73,6 +79,7 @@ public boolean validateLocal(TextArea textArea) { | |
return false; | ||
} | ||
} | ||
*/ | ||
|
||
// normalize value just in case | ||
sshKeys = sshKeys.replaceAll("(\n)+", ","); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,11 @@ | |
*/ | ||
public class SshKeysTextFieldValidator extends TextFieldValidator { | ||
|
||
RegExp regExp = RegExp.compile("^(ssh-rsa|ssh-dsa|ecdsa-sha2-nistp256|ecdsa-sha2-nistp384|ecdsa-sha2-nistp521|ssh-ed25519|sk-ed25519|sk-ecdsa) (([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)?)( [^,\n]+)?$"); | ||
RegExp regExp = RegExp.compile("^(" + | ||
"(ssh-(rsa|dss|ed25519)([email protected])?)|" + | ||
"(sk-(ssh-ed25519|ecdsa-sha2-nistp256)(-cert-v01)[email protected])|" + | ||
"(ecdsa-sha2-nistp(256|384|521)([email protected])?))" + | ||
" (([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)?)( [^,\n]+)?$"); | ||
|
||
@Override | ||
public boolean validateLocal(TextField textField) { | ||
|
@@ -53,6 +57,8 @@ public boolean validateLocal(TextField textField) { | |
return false; | ||
} | ||
|
||
// FIXME - this doesn't make sense anymore, as we have multiple different SSH keys prefixes, which needs to be checked. | ||
/* | ||
if (sshKeys.indexOf("ssh-") != sshKeys.lastIndexOf("ssh-")) { | ||
// there are at least two keys | ||
if (!sshKeys.contains(",ssh-")) { | ||
|
@@ -61,6 +67,7 @@ public boolean validateLocal(TextField textField) { | |
return false; | ||
} | ||
} | ||
*/ | ||
|
||
// normalize value just in case | ||
sshKeys = sshKeys.replaceAll("(,)+", ","); | ||
|