Sign inSign up

rayluomba/microsoft-authentication-extensions-for-python

By rayluomba

•Updated over 5 years ago

Microsoft Authentication extensions for MSAL (MSAL EX) Python images encrypt token cache on Linux.

Image
0

984

rayluomba/microsoft-authentication-extensions-for-python repository overview

⁠Overview

The original Microsoft Authentication extensions for MSAL (MSAL EX) Python supports token cache encryption on Linux, Windows and macOS. The docker images here, however, target Linux only, by pre-installing the required dependencies (keyring, msal, msal_extensions etc.) into a python:3-slim base image.

The images are currently used for testing and demonstration purpose.

⁠Usage

  1. Run the image with --privileged permission in an interactive session:

    docker run --rm -it --privileged rayluomba/microsoft-authentication-extensions-for-python
    

    That is it. You will be brought into a bash session which is already pre-configured to run token cache persistence with encryption.

  2. [Optional] You may want to test to ensure the token cache encryption work. You can test it by grabbing the official MSAL EX persistence sample⁠ and then run it to see the "Is this persistence encrypted? True" confirmation.

    root@cecfd79cace1:/home# pip list  # Optionally list the version numbers of installed msal and msal_extensions
    root@cecfd79cace1:/home# python -c "import requests; print(requests.get('https://raw.githubusercontent.com/AzureAD/microsoft-authentication-extensions-for-python/dev/sample/persistence_sample.py').text)" > persistence_sample.py
    root@cecfd79cace1:/home# python persistence_sample.py 
    Is this persistence encrypted? True
    

⁠Advanced Usage

  • MSAL EX maintainers can run that docker run ... command with an extra -w /home -v $PWD:/home parameter, while running in the local MSAL EX project directory, and then you can just run pytest to run the unit tests.

    cd path/to/microsoft-authentication-extensions-for-python
    docker run --rm -it --privileged -w /home -v $PWD:/home rayluomba/microsoft-authentication-extensions-for-python
    pip install -e .
    pytest
    
  • The default session comes with a default keyring password for testing purpose only. If you want to customize the keyring password, you can run the image with an bash suffix. This way, you will be dropped into a raw bash shell, then you can specify your own keyring password:

    docker run --rm -it --privileged rayluomba/microsoft-authentication-extensions-for-python bash
    ...
    root@cecfd79cace1:/home# echo my_own_password | gnome-keyring-daemon --unlock
    # Now the keyring is ready
    ...
    root@cecfd79cace1:/home# python persistence_sample.py 
    Is this persistence encrypted? True
    

Tag summary

Content type

Image

Digest

Size

267.4 MB

Last updated

over 5 years ago

docker pull rayluomba/microsoft-authentication-extensions-for-python