Skip to content

Commit

Permalink
[Service Connector] Use client ip in connection message to update sql…
Browse files Browse the repository at this point in the history
… firewall (#5963)

* update sql client ip

* update version

* update
  • Loading branch information
xfz11 committed Mar 13, 2023
1 parent 907a99d commit 97fe25b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/serviceconnector-passwordless/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
Release History
===============
0.2.1
++++++
* Use the client ip in SQL connection output to update firewall rule.

0.2.0
++++++
* Remove firewall rule to avoid security issue. Prompt confirmation before open all IPs. Add param `--yes` to skip the confirmation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ def create_aad_user(self):
logger.warning(e)
# allow local access
from requests import get
ip_address = get(IP_ADDRESS_CHECKER).text
ip_address = self.ip or get(IP_ADDRESS_CHECKER).text
self.set_target_firewall(True, ip_name, ip_address, ip_address)
try:
# create again
Expand Down Expand Up @@ -448,6 +448,11 @@ def create_aad_user_in_sql(self, connection_args, query_list):
logger.warning(e)
conn.commit()
except pyodbc.Error as e:
import re
search_ip = re.search(
"Client with IP address '(.*?)' is not allowed to access the server", str(e))
if search_ip is not None:
self.ip = search_ip.group(1)
raise AzureConnectionError("Fail to connect sql." + str(e)) from e

def get_connection_string(self):
Expand Down
2 changes: 1 addition & 1 deletion src/serviceconnector-passwordless/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

# TODO: Confirm this is the right version number you want and it matches your
# HISTORY.rst entry.
VERSION = '0.2.0'
VERSION = '0.2.1'

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

0 comments on commit 97fe25b

Please sign in to comment.