Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 0 additions & 4 deletions scripts/ci/dependency_check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 1 addition & 4 deletions scripts/install_full.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions scripts/release/debian/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 3 additions & 11 deletions scripts/release/debian/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
7 changes: 1 addition & 6 deletions scripts/release/debian/prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions scripts/release/rpm/Dockerfile.centos
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 && \
Expand Down
4 changes: 2 additions & 2 deletions scripts/release/rpm/Dockerfile.fedora
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
17 changes: 4 additions & 13 deletions scripts/release/rpm/azure-cli.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion scripts/release/rpm/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
54 changes: 6 additions & 48 deletions src/azure-cli-core/azure/cli/core/_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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()
Expand Down
9 changes: 2 additions & 7 deletions src/azure-cli-core/azure/cli/core/tests/test_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 0 additions & 1 deletion src/azure-cli/requirements.py3.Darwin.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/azure-cli/requirements.py3.Linux.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/azure-cli/requirements.py3.windows.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down