Azure / azure-storage-python

Microsoft Azure Storage Library for Python
https://azure-storage.readthedocs.io
MIT License
338 stars 240 forks source link

BlobPermissions missing List permission #579

Closed briglx closed 5 years ago

briglx commented 5 years ago

Which service(blob, file, queue) does this issue concern?

blob

Which version of the SDK was used? Please provide the output of pip freeze.

From Azure Notebooks absl-py==0.7.0 adal==1.2.1 alabaster==0.7.11 altair==2.4.1 anaconda-client==1.7.2 anaconda-navigator==1.9.2 anaconda-project==0.8.2 antlr4-python3-runtime==4.7.2 appdirs==1.4.3 applicationinsights==0.11.7 argcomplete==1.9.4 arrow==0.13.1 asn1crypto==0.24.0 astor==0.7.1 astroid==2.0.4 astropy==3.0.4 atomicwrites==1.2.1 attrs==18.2.0 Automat==0.7.0 azure==4.0.0 azure-applicationinsights==0.1.0 azure-batch==4.1.3 azure-cli-core==2.0.54 azure-cli-nspkg==3.0.3 azure-cli-telemetry==1.0.1 azure-common==1.1.18 azure-cosmosdb-nspkg==2.0.2 azure-cosmosdb-table==1.0.5 azure-datalake-store==0.0.43 azure-eventgrid==1.2.0 azure-graphrbac==0.40.0 azure-keyvault==1.1.0 azure-kusto-data==0.0.20 azure-kusto-ingest==0.0.20 azure-loganalytics==0.1.0 azure-mgmt==4.0.0 azure-mgmt-advisor==1.0.1 azure-mgmt-applicationinsights==0.1.1 azure-mgmt-authorization==0.50.0 azure-mgmt-batch==5.0.1 azure-mgmt-batchai==2.0.0 azure-mgmt-billing==0.2.0 azure-mgmt-cdn==3.0.0 azure-mgmt-cognitiveservices==3.0.0 azure-mgmt-commerce==1.0.1 azure-mgmt-compute==4.4.0 azure-mgmt-consumption==2.0.0 azure-mgmt-containerinstance==1.4.0 azure-mgmt-containerregistry==2.7.0 azure-mgmt-containerservice==4.4.0 azure-mgmt-cosmosdb==0.4.1 azure-mgmt-datafactory==0.6.0 azure-mgmt-datalake-analytics==0.6.0 azure-mgmt-datalake-nspkg==3.0.1 azure-mgmt-datalake-store==0.5.0 azure-mgmt-datamigration==1.0.0 azure-mgmt-devspaces==0.1.0 azure-mgmt-devtestlabs==2.2.0 azure-mgmt-dns==2.1.0 azure-mgmt-eventgrid==1.0.0 azure-mgmt-eventhub==2.3.0 azure-mgmt-hanaonazure==0.1.1 azure-mgmt-iotcentral==0.1.0 azure-mgmt-iothub==0.5.0 azure-mgmt-iothubprovisioningservices==0.2.0 azure-mgmt-keyvault==1.1.0 azure-mgmt-loganalytics==0.2.0 azure-mgmt-logic==3.0.0 azure-mgmt-machinelearningcompute==0.4.1 azure-mgmt-managementgroups==0.1.0 azure-mgmt-managementpartner==0.1.0 azure-mgmt-maps==0.1.0 azure-mgmt-marketplaceordering==0.1.0 azure-mgmt-media==1.0.0 azure-mgmt-monitor==0.5.2 azure-mgmt-msi==0.2.0 azure-mgmt-network==2.5.1 azure-mgmt-notificationhubs==2.0.0 azure-mgmt-nspkg==3.0.2 azure-mgmt-policyinsights==0.1.0 azure-mgmt-powerbiembedded==2.0.0 azure-mgmt-rdbms==1.7.0 azure-mgmt-recoveryservices==0.3.0 azure-mgmt-recoveryservicesbackup==0.3.0 azure-mgmt-redis==5.0.0 azure-mgmt-relay==0.1.0 azure-mgmt-reservations==0.2.1 azure-mgmt-resource==2.0.0 azure-mgmt-scheduler==2.0.0 azure-mgmt-search==2.0.0 azure-mgmt-servicebus==0.5.3 azure-mgmt-servicefabric==0.2.0 azure-mgmt-signalr==0.1.1 azure-mgmt-sql==0.9.1 azure-mgmt-storage==2.0.0 azure-mgmt-subscription==0.2.0 azure-mgmt-trafficmanager==0.50.0 azure-mgmt-web==0.35.0 azure-nspkg==3.0.2 azure-servicebus==0.21.1 azure-servicefabric==6.3.0.0 azure-servicemanagement-legacy==0.20.6 azure-storage-blob==1.5.0 azure-storage-common==1.4.0 azure-storage-file==1.4.0 azure-storage-queue==1.4.0 azureml-contrib-notebook==1.0.17 azureml-core==1.0.17.1 azureml-dataprep==1.0.16 azureml-dataprep-native==11.2.2 azureml-explain-model==1.0.17 azureml-pipeline==1.0.17 azureml-pipeline-core==1.0.17 azureml-pipeline-steps==1.0.17 azureml-sdk==1.0.17 azureml-telemetry==1.0.17 azureml-train==1.0.17 azureml-train-automl==1.0.17.1 azureml-train-core==1.0.17 azureml-train-restclients-hyperdrive==1.0.17 azureml-widgets==1.0.17 Babel==2.6.0 backcall==0.1.0 backports.shutil-get-terminal-size==1.0.0 backports.tempfile==1.0 backports.weakref==1.0rc1 bcrypt==3.1.6 beautifier==0.5.5 beautifulsoup4==4.6.3 bitarray==0.8.3 bkcharts==0.2 blaze==0.11.3 bleach==1.5.0 bokeh==0.13.0 boto==2.49.0 boto3==1.4.8 botocore==1.8.50 Bottleneck==1.2.1 bqplot==0.11.5 brewer2mpl==1.4.1 bz2file==0.98 CacheControl==0.12.5 certifi==2018.10.15 cffi==1.11.5 chardet==3.0.4 Click==7.0 cloudpickle==0.5.6 clyent==1.2.2 cntk==2.5.1 colorama==0.3.9 conda==4.5.11 conda-build==3.16.0 constantly==15.1.0 contextlib2==0.5.5 coverage==3.7.1 coveralls==0.5 cryptography==2.3.1 cycler==0.10.0 Cython==0.28.5 cytoolz==0.9.0.1 dask==0.19.3 datacleaner==0.1.5 datascience==0.10.6 datashape==0.5.4 decorator==4.3.0 defusedxml==0.5.0 Deprecated==1.2.5 dill==0.2.9 distributed==1.23.3 distro==1.4.0 docker==3.7.0 docker-py==1.10.6 docker-pycreds==0.4.0 docopt==0.6.2 docutils==0.14 Dora==0.0.2 dotnetcore2==2.1.7 edward==1.3.5 elasticsearch==6.3.1 entrypoints==0.2.3 et-xmlfile==1.0.1 fastcache==1.0.2 feedparser==5.2.1 filelock==3.0.8 Flask==1.0.2 Flask-Cors==3.0.6 folium==0.2.1 ftfy==5.3.0 future==0.16.0 futures==3.1.1 gast==0.2.2 GDAL==2.3.0 gevent==1.3.6 ggplot==0.11.5 glob2==0.6 gmpy2==2.0.8 graphviz==0.10.1 greenlet==0.4.15 grpcio==1.19.0 gym==0.12.0 h5py==2.8.0 hdmedians==0.13 heapdict==1.0.0 holoviews==1.10.7 html5lib==0.9999999 humanfriendly==4.18 hyperlink==18.0.0 idna==2.7 imageio==2.4.1 imagesize==1.1.0 incremental==17.5.0 ipykernel==5.1.0 ipython==7.1.1 ipython-genutils==0.2.0 ipywidgets==7.4.2 isodate==0.6.0 isort==4.3.4 itsdangerous==0.24 jdcal==1.4 jedi==0.13.1 jeepney==0.4 Jinja2==2.10 jmespath==0.9.4 joblib==0.12.5 JsonForm==0.0.2 jsonpickle==1.1 jsonschema==2.6.0 JsonSir==0.0.2 jupyter==1.0.0 jupyter-client==5.2.3 jupyter-console==6.0.0 jupyter-core==4.4.0 jupyterlab==0.34.12 jupyterlab-launcher==0.13.1 kafka-python==1.4.4 kazoo==2.5.0 Keras==2.2.2 Keras-Applications==1.0.7 Keras-Preprocessing==1.0.9 keyring==13.2.1 kiwisolver==1.0.1 klein==17.10.0 knack==0.5.1 Kqlmagic==0.1.91 lancet-ioam==0.9.0 lazy-object-proxy==1.3.1 libarchive-c==2.8 lightgbm==2.2.1 line-profiler==2.1.2 llvmlite==0.25.0 locket==0.2.0 lockfile==0.12.2 luigi==2.8.2 lxml==4.2.5 Markdown==3.0.1 MarkupSafe==1.1.0 matplotlib==3.0.0 mccabe==0.6.1 memory-profiler==0.55.0 mistune==0.8.4 mkl-fft==1.0.6 mkl-random==1.0.1 mock==2.0.0 more-itertools==4.3.0 mpmath==1.0.0 msgpack==0.5.6 msrest==0.6.4 msrestazure==0.6.0 multipledispatch==0.6.0 natsort==5.4.0 navigator-updater==0.2.1 nbconvert==5.4.0 nbformat==4.4.0 ndg-httpsclient==0.5.1 networkx==2.2 nltk==3.3 nose==1.3.7 notebook==5.7.2 numba==0.40.0 numexpr==2.6.8 numpy==1.14.6 numpydoc==0.8.0 oauthlib==3.0.1 odo==0.5.1 okpy==1.13.11 olefile==0.46 onnx==1.4.1 onnxmltools==1.3.0 onnxruntime==0.1.4 opencv-python==4.1.0.25 openfst==1.6.1 openpyxl==2.5.8 packaging==18.0 pandas==0.22.0 pandasql==0.7.3 pandocfilters==1.4.2 param==1.7.0 paramiko==2.4.2 parso==0.3.1 partd==0.3.8 path.py==11.1.0 pathlib2==2.3.2 pathspec==0.5.9 patsy==0.5.1 pbr==4.2.0 pep8==1.7.1 pexpect==4.6.0 phonenumbers==8.10.6 pickleshare==0.7.5 Pillow==5.3.0 pkginfo==1.4.2 plotly==3.6.1 pluggy==0.7.1 ply==3.11 portalocker==1.2.1 prettypandas==0.0.4 prettytable==0.7.2 prometheus-client==0.4.2 prompt-toolkit==2.0.7 protobuf==3.7.0 psutil==5.4.7 psycopg2==2.7.5 ptyprocess==0.6.0 py==1.6.0 pyang==1.7.8 pyasn1==0.4.4 pyasn1-modules==0.2.2 pycodestyle==2.4.0 pycosat==0.6.3 pycparser==2.19 pycrypto==2.6.1 pycurl==7.43.0.2 pydot==1.4.1 pyflakes==2.0.0 PyGithub==1.43.5 pyglet==1.3.2 Pygments==2.2.0 PyHamcrest==1.9.0 PyJWT==1.7.1 pykafka==2.8.0 pylint==2.1.1 pymc==2.3.6 pymc3==3.6 pymongo==3.7.1 Pympler==0.6 pymssql==2.1.1 PyMySQL==0.9.2 PyNaCl==1.3.0 pyodbc==3.1.1 pyOpenSSL==18.0.0 pypachy==0.1.5 pyparsing==2.3.0 pyprof2calltree==1.4.4 PySocks==1.6.8 pytest==3.8.2 pytest-arraydiff==0.2 pytest-astropy==0.4.0 pytest-doctestplus==0.1.3 pytest-openfiles==0.3.0 pytest-remotedata==0.3.0 python-daemon==2.1.2 python-dateutil==2.7.5 Python-EasyConfig==0.1.7 pytz==2018.7 pyviz-comms==0.6.0 PyWavelets==1.0.1 PyYAML==3.13 pyzmq==17.1.2 QtAwesome==0.5.0 qtconsole==4.4.2 QtPy==1.5.1 requests==2.21.0 requests-oauthlib==1.2.0 Resource==0.2.1 retrying==1.3.3 rope==0.11.0 rpy2==3.0.1 ruamel-yaml==0.15.46 ruamel.yaml==0.15.51 s3transfer==0.1.13 scikit-bio==0.5.4 scikit-image==0.13.0 scikit-learn==0.19.1 scipy==1.1.0 scrubadub==1.2.0 seaborn==0.9.0 SecretStorage==3.1.0 Send2Trash==1.5.0 service-identity==17.0.0 shap==0.28.5 simplegeneric==0.8.1 singledispatch==3.4.0.3 six==1.11.0 sklearn==0.0 sklearn-pandas==1.7.0 snakeviz==1.0.0 snowballstemmer==1.2.1 sortedcollections==1.0.1 sortedcontainers==2.0.5 Sphinx==1.8.1 sphinxcontrib-websupport==1.1.0 spyder==3.3.1 spyder-kernels==0.2.6 SQLAlchemy==1.2.14 statsmodels==0.9.0 sympy==1.3 tables==3.4.4 tabulate==0.8.2 tblib==1.3.2 tensorboard==1.12.2 tensorflow==1.12.0 tensorflow-tensorboard==0.1.8 termcolor==1.1.0 terminado==0.8.1 testpath==0.4.2 textblob==0.10.0 tf2onnx==0.3.1 Theano==1.0.3 toolz==0.9.0 torch==0.4.1 torchvision==0.2.1 tornado==4.5.3 tqdm==4.26.0 traitlets==4.3.2 traittypes==0.2.1 treq==18.6.0 Twisted==18.7.0 typed-ast==1.1.0 typing==3.6.6 typing-extensions==3.7.2 unicodecsv==0.14.1 update-checker==0.16 urllib3==1.23 wcwidth==0.1.7 webencodings==0.5.1 websocket-client==0.55.0 Werkzeug==0.14.1 wget==3.2 widgetsnbextension==3.4.2 word2vec==0.10.2 wrapt==1.10.11 xlrd==1.1.0 XlsxWriter==1.1.1 xlwt==1.3.0 zict==0.1.3 zope.interface==4.5.0

What problem was encountered?

Orginally getting : AzureHttpError: Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature. ErrorCode: AuthenticationFailed

From this code:

container_sas_token = \
        block_blob_client.generate_container_shared_access_signature(
            container_name,
            permission=azureblob.BlobPermissions.READ,
            expiry=datetime.datetime.utcnow() + datetime.timedelta(hours=2))

blob_service = BlockBlobService(_STORAGE_ACCOUNT_NAME, container_sas_token)
containers = blob_service.list_containers()

Tried adding LIST
permission=azureblob.BlobPermissions.READ | azureblob.BlobPermissions.LIST but then get

type object 'BlobPermissions' has no attribute 'LIST'

Have you found a mitigation/solution?

No

Note: for table service, please post the issue here instead: https://github.com/Azure/azure-cosmosdb-python.

zezha-msft commented 5 years ago

Hi @briglx, thanks for reaching out!

For listing, you should generate a container SAS instead. There is no List permission for blob (doc here).

briglx commented 5 years ago

Thanks for the help... I should have been passing permission=azureblob.ContainerPermissions.READ | azureblob.ContainerPermissions.LIST