Skip to content

Commit

Permalink
[Bastion] add auth type password for rdp and fix line formatting issue (
Browse files Browse the repository at this point in the history
Azure#7023)

* add auth type password for rdp and fix line formatting issue

* bump version

* lint

* add warning message

* lint fix
  • Loading branch information
aavalang authored Nov 23, 2023
1 parent f00d174 commit a9c1aca
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
5 changes: 5 additions & 0 deletions src/bastion/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
Release History
===============
0.2.7
++++++
* add support for auth type password in RDP connection
* line formatting issue with IP connect

0.2.6
++++++
* Adding auth type aad for RDP to mimic the enable-mfa flag.
Expand Down
16 changes: 10 additions & 6 deletions src/bastion/azext_bastion/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ def ssh_bastion_host(cmd, auth_type, target_resource_id, target_ip_address, reso
if ip_connect:
if int(resource_port) not in [22, 3389]:
raise UnrecognizedArgumentError("Custom ports are not allowed. Allowed ports for Tunnel with IP connect is 22, 3389.")
target_resource_id = f"/subscriptions/{get_subscription_id(cmd.cli_ctx)}/resourceGroups/{resource_group_name}"
f"/providers/Microsoft.Network/bh-hostConnect/{target_ip_address}"
target_resource_id = f"/subscriptions/{get_subscription_id(cmd.cli_ctx)}/resourceGroups/{resource_group_name}" \
f"/providers/Microsoft.Network/bh-hostConnect/{target_ip_address}"

_validate_resourceid(target_resource_id)
bastion_endpoint = _get_bastion_endpoint(cmd, bastion, resource_port, target_resource_id)
Expand Down Expand Up @@ -252,6 +252,10 @@ def rdp_bastion_host(cmd, target_resource_id, target_ip_address, resource_group_
if auth_type is None:
# do nothing
pass
elif auth_type.lower() == "password":
# do nothing
logger.warning("No need to provide auth-type password for RDP connections.")
pass
elif auth_type.lower() == "aad":
enable_mfa = True

Expand All @@ -264,8 +268,8 @@ def rdp_bastion_host(cmd, target_resource_id, target_ip_address, resource_group_
if int(resource_port) not in [22, 3389]:
raise UnrecognizedArgumentError("Custom ports are not allowed. Allowed ports for Tunnel with IP connect is 22, 3389.")

target_resource_id = f"/subscriptions/{get_subscription_id(cmd.cli_ctx)}/resourceGroups/{resource_group_name}"
f"/providers/Microsoft.Network/bh-hostConnect/{target_ip_address}"
target_resource_id = f"/subscriptions/{get_subscription_id(cmd.cli_ctx)}/resourceGroups/{resource_group_name}" \
f"/providers/Microsoft.Network/bh-hostConnect/{target_ip_address}"

_validate_resourceid(target_resource_id)
bastion_endpoint = _get_bastion_endpoint(cmd, bastion, resource_port, target_resource_id)
Expand Down Expand Up @@ -379,8 +383,8 @@ def create_bastion_tunnel(cmd, target_resource_id, target_ip_address, resource_g

ip_connect = _is_ipconnect_request(bastion, target_ip_address)
if ip_connect:
target_resource_id = f"/subscriptions/{get_subscription_id(cmd.cli_ctx)}/resourceGroups/"
f"{resource_group_name}/providers/Microsoft.Network/bh-hostConnect/{target_ip_address}"
target_resource_id = f"/subscriptions/{get_subscription_id(cmd.cli_ctx)}/resourceGroups/" \
f"{resource_group_name}/providers/Microsoft.Network/bh-hostConnect/{target_ip_address}"

if ip_connect and int(resource_port) not in [22, 3389]:
raise UnrecognizedArgumentError("Custom ports are not allowed. Allowed ports for Tunnel with IP connect is 22, 3389.")
Expand Down
2 changes: 1 addition & 1 deletion src/bastion/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


# HISTORY.rst entry.
VERSION = '0.2.6'
VERSION = '0.2.7'

# The full list of classifiers is available at
# https://pypi.python.org/pypi?%3Aaction=list_classifiers
Expand Down

0 comments on commit a9c1aca

Please sign in to comment.