Skip to content

Commit

Permalink
Merge pull request #48 from AzureAD/release-0.2.1
Browse files Browse the repository at this point in the history
Release 0.2.1
  • Loading branch information
rayluo authored Apr 23, 2020
2 parents 32914b3 + 885d0f9 commit fae4931
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 16 deletions.
2 changes: 1 addition & 1 deletion msal_extensions/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Provides auxiliary functionality to the `msal` package."""
__version__ = "0.2.0"
__version__ = "0.2.1"

import sys

Expand Down
41 changes: 30 additions & 11 deletions msal_extensions/libsecret.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,32 @@
"""
import logging

import gi # https://pygobject.readthedocs.io/en/latest/getting_started.html

# pylint: disable=no-name-in-module
gi.require_version("Secret", "1") # Would require a package gir1.2-secret-1
# pylint: disable=wrong-import-position
from gi.repository import Secret # Would require a package gir1.2-secret-1


logger = logging.getLogger(__name__)

try:
import gi # https://github.com/AzureAD/microsoft-authentication-extensions-for-python/wiki/Encryption-on-Linux
except ImportError:
logger.exception(
"""Runtime dependency of PyGObject is missing.
Depends on your Linux distro, you could install it system-wide by something like:
sudo apt install python3-gi python3-gi-cairo gir1.2-secret-1
If necessary, please refer to PyGObject's doc:
https://pygobject.readthedocs.io/en/latest/getting_started.html
""")
raise

try:
# pylint: disable=no-name-in-module
gi.require_version("Secret", "1") # Would require a package gir1.2-secret-1
# pylint: disable=wrong-import-position
from gi.repository import Secret # Would require a package gir1.2-secret-1
except (ValueError, ImportError):
logger.exception(
"""Require a package "gir1.2-secret-1" which could be installed by:
sudo apt install gir1.2-secret-1
""")
raise

class LibSecretAgent(object):
"""A loader/saver built on top of low-level libsecret"""
# Inspired by https://developer.gnome.org/libsecret/unstable/py-examples.html
Expand Down Expand Up @@ -111,9 +127,12 @@ def trial_run():
assert agent.load() == payload # This line is probably not reachable
agent.clear()
except (gi.repository.GLib.Error, AssertionError):
message = (
"libsecret did not perform properly. Please refer to "
"https://github.com/AzureAD/microsoft-authentication-extensions-for-python/wiki/Encryption-on-Linux") # pylint: disable=line-too-long
message = """libsecret did not perform properly.
* If you encountered error "Remote error from secret service:
org.freedesktop.DBus.Error.ServiceUnknown",
you may need to install gnome-keyring package.
* Headless mode (such as in an ssh session) is not supported.
"""
logger.exception(message) # This log contains trace stack for debugging
logger.warning(message) # This is visible by default
raise
Expand Down
4 changes: 2 additions & 2 deletions sample/persistence_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ def build_persistence(location, fallback_to_plaintext=False):
except: # pylint: disable=bare-except
if not fallback_to_plaintext:
raise
logging.exception("Encryption unavailable. Opting in to plain text.")
logging.warning("Encryption unavailable. Opting in to plain text.")
return FilePersistence(location)

persistence = build_persistence("storage.bin")
persistence = build_persistence("storage.bin", fallback_to_plaintext=False)
print("Is this persistence encrypted?", persistence.is_encrypted)

data = { # It can be anything, here we demonstrate an arbitrary json object
Expand Down
13 changes: 11 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,28 @@
io.open('msal_extensions/__init__.py', encoding='utf_8_sig').read()
).group(1)

try:
long_description = open('README.md').read()
except OSError:
long_description = "README.md is not accessible on TRAVIS CI's Python 3.5"

setup(
name='msal-extensions',
version=__version__,
packages=find_packages(),
long_description=long_description,
long_description_content_type="text/markdown",
classifiers=[
'Development Status :: 2 - Pre-Alpha',
],
package_data={'': ['LICENSE']},
install_requires=[
'msal>=0.4.1,<2.0.0',
'portalocker~=1.6',
"portalocker~=1.6;platform_system=='Windows'",
"portalocker~=1.0;platform_system!='Windows'",
"pathlib2;python_version<'3.0'",
"pygobject>=3,<4;platform_system=='Linux'",
## We choose to NOT define a hard dependency on this.
# "pygobject>=3,<4;platform_system=='Linux'",
],
tests_require=['pytest'],
)

0 comments on commit fae4931

Please sign in to comment.