Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[serviceconnector-passwordless] add extension information in user agent #6059

Merged
merged 11 commits into from
Mar 24, 2023
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/serviceconnector-passwordless/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,21 @@

Release History
===============
0.3.0
++++++
* Add extension information in API request.

0.2.2
++++++
* Update dependency psycopg2 to psycopg2-binary.

0.2.1
++++++
* Use the client ip in SQL connection output to update firewall rule.
* Update SQL connection.

0.2.0
++++++
* Remove firewall rule to avoid security issue. Prompt confirmation before open all IPs. Add param `--yes` to skip the confirmation.
* Fix some security issues. Prompt confirmation before open all IPs. Add param `--yes` to skip the confirmation.

0.1.0
++++++
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------


def cf_connection_cl(cli_ctx, *_):
from azure.mgmt.servicelinker import ServiceLinkerManagementClient
from .client_factory_util import get_mgmt_service_client
from .config import NAME, VERSION
cli_ctx.data['command_extension_name'] = NAME
cli_ctx.data['command_extension_version'] = VERSION
return get_mgmt_service_client(cli_ctx, ServiceLinkerManagementClient,
subscription_bound=False, api_version="2022-11-01-preview")


def cf_linker(cli_ctx, *_):
return cf_connection_cl(cli_ctx).linker


def cf_connector(cli_ctx, *_):
return cf_connection_cl(cli_ctx).connector
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ class SqlHandler(TargetHandler):

server = ""
dbname = ""
ip = ""

def __init__(self, cmd, target_id, target_type, auth_type, connection_name, skip_prompt):
super().__init__(cmd, target_id, target_type, auth_type, connection_name, skip_prompt)
Expand Down Expand Up @@ -369,27 +370,19 @@ def create_aad_user(self):
logger.warning("Connecting to database...")
self.create_aad_user_in_sql(connection_args, query_list)
except AzureConnectionError as e:
if not self.ip:
raise e
logger.warning(e)
# allow local access
from requests import get
ip_address = self.ip or get(IP_ADDRESS_CHECKER).text
ip_address = self.ip
self.set_target_firewall(True, ip_name, ip_address, ip_address)
try:
# create again
self.create_aad_user_in_sql(connection_args, query_list)
except AzureConnectionError as e:
logger.warning(e)
try:
if not self.skip_prompt:
if not prompt_y_n(OPEN_ALL_IP_MESSAGE):
raise AzureConnectionError(
"Please confirm local environment can connect to database and try again.") from e
except NoTTYException as e:
raise CLIInternalError(
'Unable to prompt for confirmation as no tty available. Use --yes.') from e
self.set_target_firewall(True, ip_name, '0.0.0.0', '255.255.255.255')
# create again
self.create_aad_user_in_sql(connection_args, query_list)
raise AzureConnectionError(
"Please confirm local environment can connect to database and try again.") from e
finally:
self.set_target_firewall(False, ip_name)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"azext.isPreview": true,
"azext.minCliCoreVersion": "2.45.0"
"azext.minCliCoreVersion": "2.46.0"
}
Loading