[PATCH 0/2] gnu: Add python-msal and oauth2ms.

  • Done
  • quality assurance status badge
Details
2 participants
  • John Kehayias
  • Ludovic Courtès
Owner
unassigned
Submitted by
John Kehayias
Severity
normal

Debbugs page

John Kehayias wrote 3 years ago
(name . Guix-patches)(address . guix-patches@gnu.org)
p-Wza1MknYRefoD6SE9qJq0ASdnGySKFjvnzIc3LGoQMoB4yspPjtKFwHsjFB-G95s31BrYON1XqaOhgikNywQQW0c_koHHJh3QNbevhpeM=@protonmail.com
Hello Guix,

Here are two straight forward patches to add python-msal and oauth2ms. Short commentary:

1. python-msal: a package for Microsoft authentication tokens. Tests were disabled because most/all needed network access, and could only disable some of these tests with an environment variable. I did use the GitHub source since it includes tests, in case this can be better worked around in the future, or if using the source directly.

2. oauth2ms: a python script to use msal in order to have usable tokens, like needing oauth2 tokens for getting/sending mail with multi-factor authentication required email services. I copied the readme and steps.org which have documentation for setting this up to the appropriate doc folder. There is no release or version tag and the script needed to be wrapped.

As a final note, I've used this to send mail through my university email server that uses Microsoft Office 365 with multi-factor authentication (so you can't use your password or an app password). oauth2ms provides instructions for doing this in emacs, which I used for mu4e. And if you can't create the needed keys in Azure (as I couldn't) you can use Thunderbird's https://hg.mozilla.org/comm-central/file/tip/mailnews/base/src/OAuth2Providers.jsm#l127along with your providers "tenet id" which I could find by logging on to Azure even without permissions to create an app.

Hope someone else finds this useful!
John
John Kehayias wrote 3 years ago
[PATCH 1/2] gnu: Add python-msal.
(name . 56404@debbugs.gnu.org)(address . 56404@debbugs.gnu.org)
Jotl7VlAaZD5lu0DdGaBF03oHYPAiTDBr07o8gbXLYbzu49uo2ezz_NStqOmtrZ8LVlOB5rcuscXVkv9EusS_o4MZkun6l-srnpBw3RWVCA=@protonmail.com
Empty Message
From 4667c19525d5a2e602e13fde46120d4dcac0d6b9 Mon Sep 17 00:00:00 2001
From: John Kehayias <john.kehayias@protonmail.com>
Date: Tue, 5 Jul 2022 13:12:43 -0400
Subject: [PATCH 1/2] gnu: Add python-msal.

* gnu/packages/python-web.scm (python-msal): New variable.
---
gnu/packages/python-web.scm | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)

Toggle diff (45 lines)
diff --git a/gnu/packages/python-web.scm b/gnu/packages/python-web.scm
index 6f951595c8..a2dcf49569 100644
--- a/gnu/packages/python-web.scm
+++ b/gnu/packages/python-web.scm
@@ -2954,6 +2954,38 @@ (define-public python-requests-ftp
adapter for use with the Requests library.")
(license license:asl2.0)))
+(define-public python-msal
+ (package
+ (name "python-msal")
+ (version "1.18.0")
+ (home-page
+ "https://github.com/AzureAD/microsoft-authentication-library-for-python")
+ (source (origin
+ (method git-fetch)
+ ;; Pypi does not have tests.
+ (uri (git-reference (url home-page) (commit version)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "02d9vlvp08q1yffgn7a0y19451py1jly67q5ld6m2d9xidbrvac1"))))
+ (build-system python-build-system)
+ (arguments
+ ;; Tests (all?) rely on network access and only some can be disabled by
+ ;; setting the environment variable TRAVIS_TAG.
+ (list #:tests? #f))
+ (native-inputs (list python-mock))
+ (propagated-inputs (list python-cryptography python-pyjwt python-requests))
+ (synopsis "Microsoft Authentication Library (MSAL) for Python")
+ (description
+ "The Microsoft Authentication Library for Python enables applications to
+integrate with the Microsoft identity platform. It allows you to sign in
+users or apps with Microsoft identities (Azure AD, Microsoft Accounts and
+Azure AD B2C accounts) and obtain tokens to call Microsoft APIs such as
+Microsoft Graph or your own APIs registered with the Microsoft identity
+platform. It is built using industry standard OAuth2 and OpenID Connect
+protocols.")
+ (license license:expat)))
+
(define-public python-oauthlib
(package
(name "python-oauthlib")
--
2.36.1
John Kehayias wrote 3 years ago
[PATCH 2/2] gnu: Add oauth2ms.
(name . 56404@debbugs.gnu.org)(address . 56404@debbugs.gnu.org)
oqDaRG8_DEMeotoMdymsVnd4dG1mDKtMWt3z3zY8SIVUg_EHtQL5rVMKnzz4LryWWZy4qXwMpGJo_PXLPcef3wUZxirT-BzEJdq5NQqyzkE=@protonmail.com
Empty Message
From 316c05e7519c0d9fc3ccefbb89dbfcc19104d3c1 Mon Sep 17 00:00:00 2001
From: John Kehayias <john.kehayias@protonmail.com>
Date: Tue, 5 Jul 2022 13:13:07 -0400
Subject: [PATCH 2/2] gnu: Add oauth2ms.

* gnu/packages/python-web.scm (oauth2ms): New variable.
---
gnu/packages/python-web.scm | 41 +++++++++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)

Toggle diff (71 lines)
diff --git a/gnu/packages/python-web.scm b/gnu/packages/python-web.scm
index a2dcf49569..834b40fc58 100644
--- a/gnu/packages/python-web.scm
+++ b/gnu/packages/python-web.scm
@@ -73,16 +73,20 @@ (define-module (gnu packages python-web)
#:use-module (guix packages)
#:use-module (guix download)
#:use-module (guix git-download)
+ #:use-module (guix build-system copy)
#:use-module (guix build-system python)
#:use-module (guix gexp)
#:use-module (guix utils)
#:use-module (gnu packages)
#:use-module (gnu packages base)
+ #:use-module (gnu packages bash)
#:use-module (gnu packages check)
#:use-module (gnu packages compression)
#:use-module (gnu packages curl)
#:use-module (gnu packages databases)
#:use-module (gnu packages django)
+ #:use-module (gnu packages freedesktop)
+ #:use-module (gnu packages gnupg)
#:use-module (gnu packages graphviz)
#:use-module (gnu packages groff)
#:use-module (gnu packages libevent)
@@ -2986,6 +2990,43 @@ (define-public python-msal
protocols.")
(license license:expat)))
+(define-public oauth2ms
+ (let ((commit "a1ef0cabfdea57e9309095954b90134604e21c08") (revision "0"))
+ (package
+ (name "oauth2ms")
+ (version (git-version "0.0.0" revision commit))
+ (source (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/harishkrupo/oauth2ms")
+ (commit commit)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "0dqi6n4npdrvb42r672n4sl1jl8z5lsk554fwiiihpj0faa9dx64"))))
+ (build-system copy-build-system)
+ (arguments
+ (list #:install-plan #~`(("oauth2ms" "bin/oauth2ms")
+ ("."
+ #$(string-append "share/doc/" name "-" version "/")
+ #:include-regexp ("\\.org$")))
+ #:phases #~(modify-phases %standard-phases
+ (add-after 'install 'wrap-pythonpath
+ (lambda* (#:key inputs outputs #:allow-other-keys)
+ (let ((path (getenv "GUIX_PYTHONPATH")))
+ (wrap-program (string-append #$output
+ "/bin/oauth2ms")
+ `("GUIX_PYTHONPATH" ":" prefix
+ (,path)))))))))
+ (inputs (list bash-minimal python python-gnupg python-msal python-pyxdg))
+ (home-page "https://github.com/harishkrupo/oauth2ms")
+ (synopsis "XOAUTH2 compatible Microsoft Office 365 token fetcher")
+ (description
+ "Oauth2ms can be used to fetch OAuth 2.0 tokens from the Microsoft Identity
+endpoint. Additionally, it can encode the token in the XOAUTH2 format to be
+used as authentication in IMAP mail servers.")
+ (license license:asl2.0))))
+
(define-public python-oauthlib
(package
(name "python-oauthlib")
--
2.36.1
Ludovic Courtès wrote 3 years ago
Re: bug#56404: [PATCH 0/2] gnu: Add python-msal and oauth2ms.
(name . John Kehayias)(address . john.kehayias@protonmail.com)(address . 56404-done@debbugs.gnu.org)
87wncb34tk.fsf@gnu.org
Hello John,

John Kehayias <john.kehayias@protonmail.com> skribis:

Toggle quote (2 lines)
> Here are two straight forward patches to add python-msal and oauth2ms.

Applied, thanks!

Ludo’.
Closed
?
Your comment

This issue is archived.

To comment on this conversation send an email to 56404@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 56404
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch
You may also tag this issue. See list of standard tags. For example, to set the confirmed and easy tags
mumi command -t +confirmed -t +easy
Or, remove the moreinfo tag and set the help tag
mumi command -t -moreinfo -t +help