diff --git a/scripts/ci/dependency_check.sh b/scripts/ci/dependency_check.sh index 947877ed06e..be374175aab 100755 --- a/scripts/ci/dependency_check.sh +++ b/scripts/ci/dependency_check.sh @@ -2,10 +2,6 @@ set -ev -if [ "$(uname)" != "Darwin" ]; then - sudo apt-get -y install libgirepository1.0-dev libcairo2-dev gir1.2-secret-1 -fi - REPO_ROOT="$(dirname ${BASH_SOURCE[0]})/../.." # Uninstall any cruft that can poison the rest of the checks in this script. diff --git a/scripts/install_full.sh b/scripts/install_full.sh index 736c7ad1bd0..bdda1836ef8 100755 --- a/scripts/install_full.sh +++ b/scripts/install_full.sh @@ -18,8 +18,5 @@ pushd ${REPO_ROOT} > /dev/null find src/ -name setup.py -type f | xargs -I {} dirname {} | grep -v azure-cli-testsdk | xargs pip install --no-deps pip install -r ./src/azure-cli/requirements.$(python ./scripts/get-python-version.py).$(uname).txt -if [ -f "./src/azure-cli/requirements.opt.$(python ./scripts/get-python-version.py).$(uname).txt" ]; then - echo "./src/azure-cli/requirements.opt.$(python ./scripts/get-python-version.py).$(uname).txt exists." - pip install -r ./src/azure-cli/requirements.opt.$(python ./scripts/get-python-version.py).$(uname).txt -fi + popd > /dev/null diff --git a/scripts/release/debian/Dockerfile b/scripts/release/debian/Dockerfile index 7fe630f18d8..3f621ac5c7d 100644 --- a/scripts/release/debian/Dockerfile +++ b/scripts/release/debian/Dockerfile @@ -3,8 +3,8 @@ FROM ${base_image} AS build-env # Update APT packages RUN apt-get update -RUN apt-get install -y libssl-dev libffi-dev python3-dev debhelper zlib1g-dev wget libgirepository1.0-dev \ - libcairo2-dev gir1.2-secret-1 gnome-keyring +RUN apt-get install -y libssl-dev libffi-dev python3-dev debhelper zlib1g-dev wget + # Download Python source code ARG python_version="3.6.10" ENV PYTHON_SRC_DIR=/usr/src/python diff --git a/scripts/release/debian/build.sh b/scripts/release/debian/build.sh index 332d9ca8e0f..1c3530afba4 100755 --- a/scripts/release/debian/build.sh +++ b/scripts/release/debian/build.sh @@ -22,8 +22,6 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" apt-get update apt-get install -y libssl-dev libffi-dev python3-dev debhelper zlib1g-dev apt-get install -y wget -apt-get install -y libgirepository1.0-dev libcairo2-dev gir1.2-secret-1 pkg-config gnome-keyring libgtk2.0-dev -apt-get install -y glib-2.0 gir1.2-gtk-3.0 # Download Python source code PYTHON_SRC_DIR=$(mktemp -d) @@ -35,22 +33,16 @@ $PYTHON_SRC_DIR/*/configure --srcdir $PYTHON_SRC_DIR/* --prefix $WORKDIR/python_ make make install +$WORKDIR/python_env/bin/python3 -m pip install --upgrade pip==21.0.1 + export PATH=$PATH:$WORKDIR/python_env/bin find ${WORKDIR}/src/ -name setup.py -type f | xargs -I {} dirname {} | grep -v azure-cli-testsdk | xargs pip3 install --no-deps pip3 install -r ${WORKDIR}/src/azure-cli/requirements.py3.$(uname).txt -if [[ -f "${WORKDIR}/src/azure-cli/requirements.opt.py3.$(uname).txt" && "${CLI_VERSION_REVISION:=1}" != *"trusty" && "${CLI_VERSION_REVISION:=1}" != *"jessie" ]]; then - pip3 install -r ${WORKDIR}/src/azure-cli/requirements.opt.py3.$(uname).txt -fi # Create create directory for debian build mkdir -p $WORKDIR/debian -if [[ "${CLI_VERSION_REVISION:=1}" == *"trusty" || "${CLI_VERSION_REVISION:=1}" == *"jessie" ]]; then - $SCRIPT_DIR/prepare.sh $WORKDIR/debian $WORKDIR/az.completion $WORKDIR -else - PYOBJECT_DEPENDENCY="gir1.2-secret-1, gnome-keyring" - $SCRIPT_DIR/prepare.sh $WORKDIR/debian $WORKDIR/az.completion $WORKDIR $PYOBJECT_DEPENDENCY -fi +$SCRIPT_DIR/prepare.sh $WORKDIR/debian $WORKDIR/az.completion $WORKDIR cd $WORKDIR dpkg-buildpackage -us -uc diff --git a/scripts/release/debian/prepare.sh b/scripts/release/debian/prepare.sh index 325509176fe..ab3ec5f9181 100755 --- a/scripts/release/debian/prepare.sh +++ b/scripts/release/debian/prepare.sh @@ -33,11 +33,6 @@ TAB=$'\t' debian_dir=$1 completion_script=$2 source_dir=$3 -setup_depends="" -if [ ! -z "$4" ]; then - setup_depends=$4 -fi - mkdir $debian_dir/source echo '1.0' > $debian_dir/source/format @@ -63,7 +58,7 @@ Homepage: https://github.com/azure/azure-cli Package: azure-cli Architecture: all -Depends: \${shlibs:Depends}, \${misc:Depends}, $setup_depends +Depends: \${shlibs:Depends}, \${misc:Depends} Description: Azure CLI A great cloud needs great tools; we're excited to introduce Azure CLI, our next generation multi-platform command line experience for Azure. diff --git a/scripts/release/rpm/Dockerfile.centos b/scripts/release/rpm/Dockerfile.centos index f02d34f4921..a3ca29f1324 100644 --- a/scripts/release/rpm/Dockerfile.centos +++ b/scripts/release/rpm/Dockerfile.centos @@ -4,7 +4,7 @@ FROM centos:${tag} AS build-env ARG cli_version=dev RUN yum update -y -RUN yum install -y wget rpm-build gcc libffi-devel python3-devel openssl-devel make bash coreutils diffutils patch dos2unix python3-virtualenv gobject-introspection-devel cairo-devel pkgconfig cairo-gobject-devel +RUN yum install -y wget rpm-build gcc libffi-devel python3-devel openssl-devel make bash coreutils diffutils patch dos2unix python3-virtualenv WORKDIR /azure-cli @@ -17,7 +17,7 @@ RUN dos2unix ./scripts/release/rpm/azure-cli.spec && \ FROM centos:${tag} AS execution-env RUN yum update -y -RUN yum install -y python3 python3-virtualenv cairo cairo-gobject +RUN yum install -y python3 python3-virtualenv COPY --from=build-env /azure-cli-dev.rpm ./ RUN rpm -i ./azure-cli-dev.rpm && \ diff --git a/scripts/release/rpm/Dockerfile.fedora b/scripts/release/rpm/Dockerfile.fedora index 9a926a3a06c..c95d7b31f39 100644 --- a/scripts/release/rpm/Dockerfile.fedora +++ b/scripts/release/rpm/Dockerfile.fedora @@ -4,7 +4,7 @@ FROM fedora:${tag} AS build-env ARG cli_version=dev RUN dnf update -y -RUN dnf install -y wget rpm-build gcc libffi-devel python3-devel python3-virtualenv openssl-devel make bash coreutils diffutils patch dos2unix perl gobject-introspection-devel cairo-devel pkgconfig cairo-gobject-devel +RUN dnf install -y wget rpm-build gcc libffi-devel python3-devel python3-virtualenv openssl-devel make bash coreutils diffutils patch dos2unix perl WORKDIR /azure-cli @@ -16,7 +16,7 @@ RUN dos2unix ./scripts/release/rpm/azure-cli.spec && \ FROM fedora:${tag} AS execution-env -RUN dnf install -y python3 python3-virtualenv cairo cairo-gobject +RUN dnf install -y python3 python3-virtualenv COPY --from=build-env /azure-cli-dev.rpm ./ RUN rpm -i ./azure-cli-dev.rpm diff --git a/scripts/release/rpm/azure-cli.spec b/scripts/release/rpm/azure-cli.spec index 1f601ee69ec..d172dc91092 100644 --- a/scripts/release/rpm/azure-cli.spec +++ b/scripts/release/rpm/azure-cli.spec @@ -25,10 +25,10 @@ Version: %{version} Release: %{release} Url: https://docs.microsoft.com/cli/azure/install-azure-cli BuildArch: x86_64 -Requires: %{python_cmd}, cairo, cairo-gobject +Requires: %{python_cmd} -BuildRequires: gcc, libffi-devel, openssl-devel, perl, binutils -BuildRequires: %{python_cmd}-devel, gobject-introspection-devel, cairo-devel, pkgconfig, cairo-gobject-devel +BuildRequires: gcc, libffi-devel, openssl-devel, perl +BuildRequires: %{python_cmd}-devel %global _python_bytecompile_errors_terminate_build 0 @@ -48,22 +48,13 @@ deactivate # Fix up %{buildroot} appearing in some files... for d in %{buildroot}%{cli_lib_dir}/bin/*; do perl -p -i -e "s#%{buildroot}##g" $d; done; -for d in %{buildroot}%{cli_lib_dir}/lib/pkgconfig/*; do perl -p -i -e "s#%{buildroot}##g" $d; done; # Create executable mkdir -p %{buildroot}%{_bindir} -python_version=$(ls %{buildroot}%{cli_lib_dir}/lib/ | grep "^python" | head -n 1) +python_version=$(ls %{buildroot}%{cli_lib_dir}/lib/ | head -n 1) printf "#!/usr/bin/env bash\nAZ_INSTALLER=RPM PYTHONPATH=%{cli_lib_dir}/lib/${python_version}/site-packages /usr/bin/%{python_cmd} -sm azure.cli \"\$@\"" > %{buildroot}%{_bindir}/az rm %{buildroot}%{cli_lib_dir}/bin/python* %{buildroot}%{cli_lib_dir}/bin/pip* -# strip debug info which contains build root info -set +e -find "%{buildroot}%{cli_lib_dir}/lib/${python_version}/site-packages/gi" -type f -name "*.so" | while read so_file -do - strip --strip-debug "$so_file" -done -set -e - # Remove unused Network SDK API versions pushd %{buildroot}%{cli_lib_dir}/lib/${python_version}/site-packages/azure/mgmt/network/ > /dev/null rm -rf v2016_09_01 v2016_12_01 v2017_03_01 v2017_06_01 v2017_08_01 v2017_09_01 v2017_11_01 v2018_02_01 v2018_04_01 v2018_06_01 v2018_10_01 v2018_12_01 v2019_04_01 v2019_08_01 v2019_09_01 v2019_11_01 v2019_12_01 v2020_03_01 diff --git a/scripts/release/rpm/build.sh b/scripts/release/rpm/build.sh index 269d63542bc..d59e9664b9c 100755 --- a/scripts/release/rpm/build.sh +++ b/scripts/release/rpm/build.sh @@ -5,7 +5,7 @@ yum check-update yum install -y gcc rpm-build rpm-level rpmlint make bash corutils diffutils \ path rpmdevtools python libffi-devel python3-devel openssl-devel \ - wget gobject-introspection-devel cairo-devel pkg-config cairo-gobject-devel + wget set -ev diff --git a/src/azure-cli-core/azure/cli/core/_profile.py b/src/azure-cli-core/azure/cli/core/_profile.py index c10aad50e9f..158e7a26f40 100644 --- a/src/azure-cli-core/azure/cli/core/_profile.py +++ b/src/azure-cli-core/azure/cli/core/_profile.py @@ -635,18 +635,6 @@ def get_access_token_for_resource(self, username, tenant, resource): """get access token for current user account, used by vsts and iot module""" return self.get_access_token_for_scopes(username, tenant, *resource_to_scopes(resource)) - def get_msal_token(self, scopes, data): - """ - This is added for vmssh feature with backward compatible interface. - data contains token_type (ssh-cert), key_id and JWK. - """ - account = self.get_subscription() - username = account[_USER_ENTITY][_USER_NAME] - subscription_id = account[_SUBSCRIPTION_ID] - credential, _, _ = self.get_login_credentials(subscription_id=subscription_id) - certificate = credential.get_token(*scopes, data=data) - return username, certificate.token - @staticmethod def _try_parse_msi_account_name(account): user_name = account[_USER_ENTITY].get(_USER_NAME) @@ -762,45 +750,15 @@ def get_raw_token(self, resource=None, scopes=None, subscription=None, tenant=No def get_msal_token(self, scopes, data): """ - This is added only for vmssh feature. - It is a temporary solution and will deprecate after MSAL adopted completely. + This is added for vmssh feature with backward compatible interface. + data contains token_type (ssh-cert), key_id and JWK. """ - from msal import ClientApplication - import posixpath account = self.get_subscription() username = account[_USER_ENTITY][_USER_NAME] - tenant = account[_TENANT_ID] or 'common' - _, refresh_token, _, _ = self.get_refresh_token() - authority = posixpath.join(self.cli_ctx.cloud.endpoints.active_directory, tenant) - app = ClientApplication(_CLIENT_ID, authority=authority) - result = app.acquire_token_by_refresh_token(refresh_token, scopes, data=data) - return username, result["access_token"] - - def get_refresh_token(self, resource=None, - subscription=None): - account = self.get_subscription(subscription) - user_type = account[_USER_ENTITY][_USER_TYPE] - username_or_sp_id = account[_USER_ENTITY][_USER_NAME] - resource = resource or self.cli_ctx.cloud.endpoints.active_directory_resource_id - - # Use ARM as the default scopes - if not scopes: - scopes = resource_to_scopes(self.cli_ctx.cloud.endpoints.active_directory_resource_id) - - if subscription and tenant: - raise CLIError("Please specify only one of subscription and tenant, not both") - - account = self.get_subscription(subscription) - identity_credential = self._create_identity_credential(account, tenant) - - from azure.cli.core.credential import CredentialAdaptor, _convert_token_entry - auth = CredentialAdaptor(identity_credential) - token = auth.get_token(*scopes) - # (tokenType, accessToken, tokenEntry) - cred = 'Bearer', token.token, _convert_token_entry(token) - return (cred, - None if tenant else str(account[_SUBSCRIPTION_ID]), - str(tenant if tenant else account[_TENANT_ID])) + subscription_id = account[_SUBSCRIPTION_ID] + credential, _, _ = self.get_login_credentials(subscription_id=subscription_id) + certificate = credential.get_token(*scopes, data=data) + return username, certificate.token def refresh_accounts(self, subscription_finder=None): subscriptions = self.load_cached_subscriptions() diff --git a/src/azure-cli-core/azure/cli/core/tests/test_profile.py b/src/azure-cli-core/azure/cli/core/tests/test_profile.py index e99d98476b5..1ba1171c2e9 100644 --- a/src/azure-cli-core/azure/cli/core/tests/test_profile.py +++ b/src/azure-cli-core/azure/cli/core/tests/test_profile.py @@ -1853,13 +1853,8 @@ def test_get_access_token_for_scopes(self, get_user_credential_mock): credential_mock.get_token.assert_called_with(*self.msal_scopes) self.assertEqual(token, self.raw_token1) - self.assertEqual(len(all_subscriptions), 1) - self.assertEqual(all_subscriptions[0].tenant_id, token_tenant) - self.assertEqual(all_subscriptions[0].home_tenant_id, home_tenant) - - @mock.patch('azure.cli.core._profile.CredsCache.retrieve_token_for_user', autospec=True) - @mock.patch('msal.ClientApplication.acquire_token_by_refresh_token', autospec=True) - def test_get_msal_token(self, mock_acquire_token, mock_retrieve_token_for_user): + @mock.patch('azure.cli.core._identity.Identity.get_user_credential', autospec=True) + def test_get_msal_token(self, get_user_credential_mock): """ This is added only for vmssh feature. It is a temporary solution and will deprecate after MSAL adopted completely. diff --git a/src/azure-cli/requirements.py3.Darwin.txt b/src/azure-cli/requirements.py3.Darwin.txt index c7c8458ffb0..1a5e2ff47e9 100644 --- a/src/azure-cli/requirements.py3.Darwin.txt +++ b/src/azure-cli/requirements.py3.Darwin.txt @@ -107,7 +107,6 @@ jsmin==2.2.2 knack==0.8.0rc2 MarkupSafe==1.1.1 mock==4.0.2 -msal==1.9.0 msrest==0.6.21 msrestazure==0.6.3 oauthlib==3.0.1 diff --git a/src/azure-cli/requirements.py3.Linux.txt b/src/azure-cli/requirements.py3.Linux.txt index c7c8458ffb0..1a5e2ff47e9 100644 --- a/src/azure-cli/requirements.py3.Linux.txt +++ b/src/azure-cli/requirements.py3.Linux.txt @@ -107,7 +107,6 @@ jsmin==2.2.2 knack==0.8.0rc2 MarkupSafe==1.1.1 mock==4.0.2 -msal==1.9.0 msrest==0.6.21 msrestazure==0.6.3 oauthlib==3.0.1 diff --git a/src/azure-cli/requirements.py3.windows.txt b/src/azure-cli/requirements.py3.windows.txt index 7d156a16643..4e222215d84 100644 --- a/src/azure-cli/requirements.py3.windows.txt +++ b/src/azure-cli/requirements.py3.windows.txt @@ -106,7 +106,6 @@ jsmin==2.2.2 knack==0.8.0rc2 MarkupSafe==1.1.1 mock==4.0.2 -msal==1.9.0 msrest==0.6.21 msrestazure==0.6.3 oauthlib==3.0.1