Skip to content

Commit fae4931

Browse files
authored
Merge pull request #48 from AzureAD/release-0.2.1
Release 0.2.1
2 parents 32914b3 + 885d0f9 commit fae4931

File tree

4 files changed

+44
-16
lines changed

4 files changed

+44
-16
lines changed

msal_extensions/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""Provides auxiliary functionality to the `msal` package."""
2-
__version__ = "0.2.0"
2+
__version__ = "0.2.1"
33

44
import sys
55

msal_extensions/libsecret.py

+30-11
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,32 @@
1515
"""
1616
import logging
1717

18-
import gi # https://pygobject.readthedocs.io/en/latest/getting_started.html
19-
20-
# pylint: disable=no-name-in-module
21-
gi.require_version("Secret", "1") # Would require a package gir1.2-secret-1
22-
# pylint: disable=wrong-import-position
23-
from gi.repository import Secret # Would require a package gir1.2-secret-1
24-
25-
2618
logger = logging.getLogger(__name__)
2719

20+
try:
21+
import gi # https://github.com/AzureAD/microsoft-authentication-extensions-for-python/wiki/Encryption-on-Linux
22+
except ImportError:
23+
logger.exception(
24+
"""Runtime dependency of PyGObject is missing.
25+
Depends on your Linux distro, you could install it system-wide by something like:
26+
sudo apt install python3-gi python3-gi-cairo gir1.2-secret-1
27+
If necessary, please refer to PyGObject's doc:
28+
https://pygobject.readthedocs.io/en/latest/getting_started.html
29+
""")
30+
raise
31+
32+
try:
33+
# pylint: disable=no-name-in-module
34+
gi.require_version("Secret", "1") # Would require a package gir1.2-secret-1
35+
# pylint: disable=wrong-import-position
36+
from gi.repository import Secret # Would require a package gir1.2-secret-1
37+
except (ValueError, ImportError):
38+
logger.exception(
39+
"""Require a package "gir1.2-secret-1" which could be installed by:
40+
sudo apt install gir1.2-secret-1
41+
""")
42+
raise
43+
2844
class LibSecretAgent(object):
2945
"""A loader/saver built on top of low-level libsecret"""
3046
# Inspired by https://developer.gnome.org/libsecret/unstable/py-examples.html
@@ -111,9 +127,12 @@ def trial_run():
111127
assert agent.load() == payload # This line is probably not reachable
112128
agent.clear()
113129
except (gi.repository.GLib.Error, AssertionError):
114-
message = (
115-
"libsecret did not perform properly. Please refer to "
116-
"https://github.com/AzureAD/microsoft-authentication-extensions-for-python/wiki/Encryption-on-Linux") # pylint: disable=line-too-long
130+
message = """libsecret did not perform properly.
131+
* If you encountered error "Remote error from secret service:
132+
org.freedesktop.DBus.Error.ServiceUnknown",
133+
you may need to install gnome-keyring package.
134+
* Headless mode (such as in an ssh session) is not supported.
135+
"""
117136
logger.exception(message) # This log contains trace stack for debugging
118137
logger.warning(message) # This is visible by default
119138
raise

sample/persistence_sample.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ def build_persistence(location, fallback_to_plaintext=False):
2727
except: # pylint: disable=bare-except
2828
if not fallback_to_plaintext:
2929
raise
30-
logging.exception("Encryption unavailable. Opting in to plain text.")
30+
logging.warning("Encryption unavailable. Opting in to plain text.")
3131
return FilePersistence(location)
3232

33-
persistence = build_persistence("storage.bin")
33+
persistence = build_persistence("storage.bin", fallback_to_plaintext=False)
3434
print("Is this persistence encrypted?", persistence.is_encrypted)
3535

3636
data = { # It can be anything, here we demonstrate an arbitrary json object

setup.py

+11-2
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,28 @@
88
io.open('msal_extensions/__init__.py', encoding='utf_8_sig').read()
99
).group(1)
1010

11+
try:
12+
long_description = open('README.md').read()
13+
except OSError:
14+
long_description = "README.md is not accessible on TRAVIS CI's Python 3.5"
15+
1116
setup(
1217
name='msal-extensions',
1318
version=__version__,
1419
packages=find_packages(),
20+
long_description=long_description,
21+
long_description_content_type="text/markdown",
1522
classifiers=[
1623
'Development Status :: 2 - Pre-Alpha',
1724
],
1825
package_data={'': ['LICENSE']},
1926
install_requires=[
2027
'msal>=0.4.1,<2.0.0',
21-
'portalocker~=1.6',
28+
"portalocker~=1.6;platform_system=='Windows'",
29+
"portalocker~=1.0;platform_system!='Windows'",
2230
"pathlib2;python_version<'3.0'",
23-
"pygobject>=3,<4;platform_system=='Linux'",
31+
## We choose to NOT define a hard dependency on this.
32+
# "pygobject>=3,<4;platform_system=='Linux'",
2433
],
2534
tests_require=['pytest'],
2635
)

0 commit comments

Comments
 (0)