Skip to content

Commit

Permalink
enh: allow @ as a valid remote user char (fixes #437)
Browse files Browse the repository at this point in the history
  • Loading branch information
speed47 committed Mar 5, 2024
1 parent d8f9423 commit 42e73e8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/perl/OVH/Bastion.pm
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ sub is_valid_port {
sub is_valid_remote_user {
my %params = @_;
my $user = $params{'user'};
if ($user =~ /^([a-zA-Z0-9._!-]{1,128})$/) {
if ($user =~ /^([a-zA-Z0-9._@!-]{1,128})$/) {
return R('OK', value => $1);
}
return R('ERR_INVALID_PARAMETER', msg => "Specified user doesn't seem to be valid");
Expand Down
8 changes: 5 additions & 3 deletions tests/functional/tests.d/350-groups.sh
Original file line number Diff line number Diff line change
Expand Up @@ -144,20 +144,22 @@ EOS
plgfail a1_add_access_force_key_and_pwd_g1 $a1 --osh groupAddServer --host 127.1.2.3 --user-any --port-any --force --force-password '$1$2$3456' --force-key "$key1fp" --group $group1
json .error_code ERR_INCOMPATIBLE_PARAMETERS

success a1_add_access_force_key_g1 $a1 --osh groupAddServer --host 127.1.2.3 --user-any --port-any --force --force-key "$key1fp" --group $group1
success a1_add_access_force_key_g1 $a1 --osh groupAddServer --host 127.1.2.3 --user 'ar@base' --port-any --force --force-key "$key1fp" --group $group1
.value.user 'ar@base'

success a1_list_servers_check_force_key_g1 $a1 --osh groupListServers --group $group1
json '.value|.[]|select(.ip=="127.1.2.3")|.forceKey' "$key1fp"
json '.value|.[]|select(.ip=="127.1.2.3")|.user' "ar@base"

# try to use the force key

run a1_connect_g1_with_forcekey $a1 forcedkey@127.1.2.3 -- false
run a1_connect_g1_with_forcekey $a1 ar@base@127.1.2.3 -- false
contain 'Connecting...'
contain 'FORCED IN ACL'
contain "$key1fp"
nocontain "$key0fp"

success a1_remove_forcekey_acl_g1 $a1 --osh groupDelServer --host 127.1.2.3 --user-any --port-any --group $group1
success a1_remove_forcekey_acl_g1 $a1 --osh groupDelServer --host 127.1.2.3 --user 'ar@base' --port-any --group $group1

# /force-key

Expand Down

0 comments on commit 42e73e8

Please sign in to comment.