AngellusMortis / django_microsoft_auth

Simple app to enable Microsoft Account, Office 365 and Xbox Live authentcation as a Django authentcation backend.
MIT License
137 stars 84 forks source link

Auth not working on newly deployed machines #442

Open LarryMartell opened 3 years ago

LarryMartell commented 3 years ago

I have an app using this package and it's deployed on many EC2 instances at AWS, all working fine, all running:

buster/sid
Ubuntu 18.04.5 LTS (Bionic Beaver)

Starting yesterday any new systems we deploy the auth is failing. We get back Failed to authenticate you for an unknown reason. Please try again later. We can see in the azure logs that the login was successful. The application code is the same, and we have the same version of every python package installed, but for some reason on newly built boxes it is failing but older ones it is succeeding. I did notice that for some OS packages the versions are slightly different. Could there be a dependency on one of those? Any suggestions on how to debug this?

Below are the package diffs - the higher version numbers are from the system that does not work:

13c13
< apport/bionic-updates,now 2.20.9-0ubuntu7.21 all [installed,automatic]
---
> apport/bionic-security,now 2.20.9-0ubuntu7.20 all [installed,upgradable to: 2.20.9-0ubuntu7.21]
19c19
< aspnetcore-runtime-2.1/bionic,now 2.1.24-1 amd64 [installed]
---
> aspnetcore-runtime-2.1/bionic,now 2.1.23-1 amd64 [installed,upgradable to: 2.1.24-1]
49c49
< chef/now 16.9.29-1 amd64 [installed,local]
---
> chef/now 16.6.14-1 amd64 [installed,local]
51c51
< cloud-init/bionic-updates,now 20.4.1-0ubuntu1~18.04.1 all [installed]
---
> cloud-init/now 20.3-2-g371b392c-0ubuntu1~18.04.1 all [installed,upgradable to: 20.4.1-0ubuntu1~18.04.1]
86,87c86,87
< dotnet-host/bionic,now 5.0.2-1 amd64 [installed,automatic]
< dotnet-hostfxr-2.1/bionic,now 2.1.24-1 amd64 [installed,automatic]
---
> dotnet-host/bionic,now 5.0.0-1 amd64 [installed,upgradable to: 5.0.2-1]
> dotnet-hostfxr-2.1/bionic,now 2.1.23-1 amd64 [installed,upgradable to: 2.1.24-1]
89c89
< dotnet-runtime-2.1/bionic,now 2.1.24-1 amd64 [installed,automatic]
---
> dotnet-runtime-2.1/bionic,now 2.1.23-1 amd64 [installed,upgradable to: 2.1.24-1]
91c91
< dotnet-runtime-deps-2.1/bionic,now 2.1.24-1 amd64 [installed,automatic]
---
> dotnet-runtime-deps-2.1/bionic,now 2.1.23-1 amd64 [installed,upgradable to: 2.1.24-1]
93c93
< dotnet-sdk-2.1/bionic,now 2.1.812-1 amd64 [installed]
---
> dotnet-sdk-2.1/bionic,now 2.1.811-1 amd64 [installed,upgradable to: 2.1.812-1]
100c100
< ec2-hibinit-agent/bionic-updates,now 1.0.0-0ubuntu4~18.04.5 all [installed]
---
> ec2-hibinit-agent/now 1.0.0-0ubuntu4~18.04.4 all [installed,upgradable to: 1.0.0-0ubuntu4~18.04.5]
149c149
< grub-common/bionic-updates,now 2.02-2ubuntu8.21 amd64 [installed,automatic]
---
> grub-common/now 2.02-2ubuntu8.18 amd64 [installed,upgradable to: 2.02-2ubuntu8.21]
151,153c151,153
< grub-pc/bionic-updates,now 2.02-2ubuntu8.21 amd64 [installed,automatic]
< grub-pc-bin/bionic-updates,now 2.02-2ubuntu8.21 amd64 [installed,automatic]
< grub2-common/bionic-updates,now 2.02-2ubuntu8.21 amd64 [installed,automatic]
---
> grub-pc/now 2.02-2ubuntu8.18 amd64 [installed,upgradable to: 2.02-2ubuntu8.21]
> grub-pc-bin/now 2.02-2ubuntu8.18 amd64 [installed,upgradable to: 2.02-2ubuntu8.21]
> grub2-common/now 2.02-2ubuntu8.18 amd64 [installed,upgradable to: 2.02-2ubuntu8.21]
237,240c237,240
< libc-bin/bionic-updates,now 2.27-3ubuntu1.4 amd64 [installed,automatic]
< libc-dev-bin/bionic-updates,now 2.27-3ubuntu1.4 amd64 [installed,automatic]
< libc6/bionic-updates,now 2.27-3ubuntu1.4 amd64 [installed,automatic]
< libc6-dev/bionic-updates,now 2.27-3ubuntu1.4 amd64 [installed,automatic]
---
> libc-bin/bionic-security,now 2.27-3ubuntu1.2 amd64 [installed,upgradable to: 2.27-3ubuntu1.4]
> libc-dev-bin/now 2.27-3ubuntu1.3 amd64 [installed,upgradable to: 2.27-3ubuntu1.4]
> libc6/now 2.27-3ubuntu1.3 amd64 [installed,upgradable to: 2.27-3ubuntu1.4]
> libc6-dev/now 2.27-3ubuntu1.3 amd64 [installed,upgradable to: 2.27-3ubuntu1.4]
291c291
< libevdev2/bionic-updates,now 1.5.8+dfsg-1ubuntu0.1 amd64 [installed,automatic]
---
> libevdev2/bionic,now 1.5.8+dfsg-1 amd64 [installed,upgradable to: 1.5.8+dfsg-1ubuntu0.1]
370,371c370,371
< libinput-bin/bionic-updates,now 1.10.4-1ubuntu0.18.04.2 amd64 [installed,automatic]
< libinput10/bionic-updates,now 1.10.4-1ubuntu0.18.04.2 amd64 [installed,automatic]
---
> libinput-bin/now 1.10.4-1ubuntu0.18.04.1 amd64 [installed,upgradable to: 1.10.4-1ubuntu0.18.04.2]
> libinput10/now 1.10.4-1ubuntu0.18.04.1 amd64 [installed,upgradable to: 1.10.4-1ubuntu0.18.04.2]
461c461
< libnss-systemd/bionic-updates,now 237-3ubuntu10.44 amd64 [installed,automatic]
---
> libnss-systemd/now 237-3ubuntu10.42 amd64 [installed,upgradable to: 237-3ubuntu10.44]
477c477
< libpam-systemd/bionic-updates,now 237-3ubuntu10.44 amd64 [installed,automatic]
---
> libpam-systemd/now 237-3ubuntu10.42 amd64 [installed,upgradable to: 237-3ubuntu10.44]
563c563
< libsystemd0/bionic-updates,now 237-3ubuntu10.44 amd64 [installed,automatic]
---
> libsystemd0/now 237-3ubuntu10.42 amd64 [installed,upgradable to: 237-3ubuntu10.44]
580c580
< libudev1/bionic-updates,now 237-3ubuntu10.44 amd64 [installed,automatic]
---
> libudev1/now 237-3ubuntu10.42 amd64 [installed,upgradable to: 237-3ubuntu10.44]
674c674,678
< linux-aws-5.4-headers-5.4.0-1035/bionic-updates,bionic-security,now 5.4.0-1035.37~18.04.1 all [installed]
---
> linux-aws-5.4-headers-5.4.0-1029/bionic-updates,bionic-security,now 5.4.0-1029.30~18.04.1 all [installed]
> linux-aws-5.4-headers-5.4.0-1030/now 5.4.0-1030.31~18.04.1 all [installed,local]
> linux-aws-5.4-headers-5.4.0-1032/bionic-updates,bionic-security,now 5.4.0-1032.33~18.04.1 all [installed,auto-removable]
> linux-aws-5.4-headers-5.4.0-1034/bionic-updates,bionic-security,now 5.4.0-1034.35~18.04.1 all [installed,automatic]
> linux-aws-5.4-headers-5.4.0-1035/bionic-updates,bionic-security,now 5.4.0-1035.37~18.04.1 all [installed,automatic]
677,679c681,685
< linux-generic-hwe-18.04/bionic-updates,now 5.4.0.64.72~18.04.59 amd64 [installed,automatic]
< linux-headers-5.4.0-1035-aws/bionic-updates,bionic-security,now 5.4.0-1035.37~18.04.1 amd64 [installed]
< linux-headers-5.4.0-64-generic/bionic-updates,now 5.4.0-64.72~18.04.1 amd64 [installed,automatic]
---
> linux-generic-hwe-18.04/bionic-security,now 5.4.0.62.70~18.04.57 amd64 [installed,upgradable to: 5.4.0.64.72~18.04.59]
> linux-headers-5.4.0-1029-aws/bionic-updates,bionic-security,now 5.4.0-1029.30~18.04.1 amd64 [installed]
> linux-headers-5.4.0-1034-aws/bionic-updates,bionic-security,now 5.4.0-1034.35~18.04.1 amd64 [installed,automatic]
> linux-headers-5.4.0-1035-aws/bionic-updates,bionic-security,now 5.4.0-1035.37~18.04.1 amd64 [installed,automatic]
> linux-headers-5.4.0-62-generic/bionic-updates,bionic-security,now 5.4.0-62.70~18.04.1 amd64 [installed,automatic]
681,684c687,697
< linux-headers-generic-hwe-18.04/bionic-updates,now 5.4.0.64.72~18.04.59 amd64 [installed,automatic]
< linux-hwe-5.4-headers-5.4.0-64/bionic-updates,now 5.4.0-64.72~18.04.1 all [installed,automatic]
< linux-image-5.4.0-1035-aws/bionic-updates,bionic-security,now 5.4.0-1035.37~18.04.1 amd64 [installed]
< linux-image-5.4.0-64-generic/bionic-updates,now 5.4.0-64.72~18.04.1 amd64 [installed,automatic]
---
> linux-headers-generic-hwe-18.04/bionic-security,now 5.4.0.62.70~18.04.57 amd64 [installed,upgradable to: 5.4.0.64.72~18.04.59]
> linux-hwe-5.4-headers-5.4.0-53/bionic-updates,bionic-security,now 5.4.0-53.59~18.04.1 all [installed,auto-removable]
> linux-hwe-5.4-headers-5.4.0-56/now 5.4.0-56.62~18.04.1 all [installed,local]
> linux-hwe-5.4-headers-5.4.0-58/bionic-updates,bionic-security,now 5.4.0-58.64~18.04.1 all [installed,auto-removable]
> linux-hwe-5.4-headers-5.4.0-59/bionic-updates,bionic-security,now 5.4.0-59.65~18.04.1 all [installed,auto-removable]
> linux-hwe-5.4-headers-5.4.0-60/bionic-updates,bionic-security,now 5.4.0-60.67~18.04.1 all [installed,auto-removable]
> linux-hwe-5.4-headers-5.4.0-62/bionic-updates,bionic-security,now 5.4.0-62.70~18.04.1 all [installed,automatic]
> linux-image-5.4.0-1029-aws/bionic-updates,bionic-security,now 5.4.0-1029.30~18.04.1 amd64 [installed]
> linux-image-5.4.0-1034-aws/bionic-updates,bionic-security,now 5.4.0-1034.35~18.04.1 amd64 [installed,automatic]
> linux-image-5.4.0-1035-aws/bionic-updates,bionic-security,now 5.4.0-1035.37~18.04.1 amd64 [installed,automatic]
> linux-image-5.4.0-62-generic/bionic-updates,bionic-security,now 5.4.0-62.70~18.04.1 amd64 [installed,automatic]
686,691c699,706
< linux-image-generic-hwe-18.04/bionic-updates,now 5.4.0.64.72~18.04.59 amd64 [installed,automatic]
< linux-libc-dev/bionic-updates,now 4.15.0-134.138 amd64 [installed,automatic]
< linux-modules-5.4.0-1035-aws/bionic-updates,bionic-security,now 5.4.0-1035.37~18.04.1 amd64 [installed]
< linux-modules-5.4.0-64-generic/bionic-updates,now 5.4.0-64.72~18.04.1 amd64 [installed,automatic]
< linux-modules-extra-5.4.0-64-generic/bionic-updates,now 5.4.0-64.72~18.04.1 amd64 [installed,automatic]
< locales/bionic-updates,now 2.27-3ubuntu1.4 all [installed,automatic]
---
> linux-image-generic-hwe-18.04/bionic-security,now 5.4.0.62.70~18.04.57 amd64 [installed,upgradable to: 5.4.0.64.72~18.04.59]
> linux-libc-dev/bionic-security,now 4.15.0-132.136 amd64 [installed,upgradable to: 4.15.0-134.138]
> linux-modules-5.4.0-1029-aws/bionic-updates,bionic-security,now 5.4.0-1029.30~18.04.1 amd64 [installed]
> linux-modules-5.4.0-1034-aws/bionic-updates,bionic-security,now 5.4.0-1034.35~18.04.1 amd64 [installed,automatic]
> linux-modules-5.4.0-1035-aws/bionic-updates,bionic-security,now 5.4.0-1035.37~18.04.1 amd64 [installed,automatic]
> linux-modules-5.4.0-62-generic/bionic-updates,bionic-security,now 5.4.0-62.70~18.04.1 amd64 [installed,automatic]
> linux-modules-extra-5.4.0-62-generic/bionic-updates,bionic-security,now 5.4.0-62.70~18.04.1 amd64 [installed,automatic]
> locales/bionic-security,now 2.27-3ubuntu1.2 all [installed,upgradable to: 2.27-3ubuntu1.4]
717c732
< multiarch-support/bionic-updates,now 2.27-3ubuntu1.4 amd64 [installed,automatic]
---
> multiarch-support/bionic-security,now 2.27-3ubuntu1.2 amd64 [installed,upgradable to: 2.27-3ubuntu1.4]
737c752
< nodejs/unknown,now 12.20.1-1nodesource1 amd64 [installed]
---
> nodejs/now 12.19.0-1nodesource1 amd64 [installed,upgradable to: 12.20.1-1nodesource1]
768c783
< powershell/bionic,now 7.1.1-1.ubuntu.18.04 amd64 [installed]
---
> powershell/bionic,now 7.1.0-1.ubuntu.18.04 amd64 [installed,upgradable to: 7.1.1-1.ubuntu.18.04]
780c795
< python3-apport/bionic-updates,now 2.20.9-0ubuntu7.21 all [installed,automatic]
---
> python3-apport/bionic-security,now 2.20.9-0ubuntu7.20 all [installed,upgradable to: 2.20.9-0ubuntu7.21]
803c818
< python3-distupgrade/bionic-updates,now 1:18.04.42 all [installed,automatic]
---
> python3-distupgrade/now 1:18.04.40 all [installed,upgradable to: 1:18.04.42]
832c847
< python3-problem-report/bionic-updates,now 2.20.9-0ubuntu7.21 all [installed,automatic]
---
> python3-problem-report/bionic-security,now 2.20.9-0ubuntu7.20 all [installed,upgradable to: 2.20.9-0ubuntu7.21]
871c886
< snapd/bionic-updates,now 2.48+18.04 amd64 [installed,automatic]
---
> snapd/now 2.47.1+18.04 amd64 [installed,upgradable to: 2.48+18.04]
873c888
< sosreport/bionic-updates,now 3.9.1-1ubuntu0.18.04.3 amd64 [installed,automatic]
---
> sosreport/now 3.9.1-1ubuntu0.18.04.2 amd64 [installed,upgradable to: 3.9.1-1ubuntu0.18.04.3]
879,880c894,895
< systemd/bionic-updates,now 237-3ubuntu10.44 amd64 [installed,automatic]
< systemd-sysv/bionic-updates,now 237-3ubuntu10.44 amd64 [installed,automatic]
---
> systemd/now 237-3ubuntu10.42 amd64 [installed,upgradable to: 237-3ubuntu10.44]
> systemd-sysv/now 237-3ubuntu10.42 amd64 [installed,upgradable to: 237-3ubuntu10.44]
889c904
< tentacle/stretch,now 6.0.390 amd64 [installed]
---
> tentacle/stretch,now 6.0.135 amd64 [installed,upgradable to: 6.0.390]
903c918
< ubuntu-release-upgrader-core/bionic-updates,now 1:18.04.42 all [installed,automatic]
---
> ubuntu-release-upgrader-core/now 1:18.04.40 all [installed,upgradable to: 1:18.04.42]
907c922
< udev/bionic-updates,now 237-3ubuntu10.44 amd64 [installed,automatic]
---
> udev/now 237-3ubuntu10.42 amd64 [installed,upgradable to: 237-3ubuntu10.44]
915c930
< update-notifier-common/bionic-updates,now 3.192.1.9 all [installed,automatic]
---
> update-notifier-common/now 3.192.1.7 all [installed,upgradable to: 3.192.1.9]
930c945
< wpasupplicant/bionic-updates,now 2:2.6-15ubuntu2.6 amd64 [installed,automatic]
---
> wpasupplicant/bionic-security,now 2:2.6-15ubuntu2.5 amd64 [installed,upgradable to: 2:2.6-15ubuntu2.6]
boterfly commented 3 years ago

I faced the same problem. I tried to install it on another server, use different proxy servers and nothing did help.

boterfly commented 3 years ago

I tried to install it from the source and it works! If install by pip it still gets the error.

Andrey-Omelyanuk commented 3 years ago

@boterfly what version of PyJWT do you have?

Andrey-Omelyanuk commented 3 years ago

I had the same problem, I and Larry found that

https://github.com/AngellusMortis/django_microsoft_auth/blob/2.4.0/reqs/requirements.in I added pyjwt==1.7.1 into my requirements.txt and it fix the problem.

boterfly commented 3 years ago

@boterfly what version of PyJWT do you have?

pip show PyJWT

Name: PyJWT Version: 2.0.1 Summary: JSON Web Token implementation in Python Home-page: https://github.com/jpadilla/pyjwt Author: Jose Padilla Author-email: hello@jpadilla.com License: MIT Location: /usr/local/lib/python3.7/site-packages/PyJWT-2.0.1-py3.7.egg Requires: Required-by: django-microsoft-auth

boterfly commented 3 years ago

But I noticed, that in requirment.txt there is no pyjwt, so next time I will try to add it. I think when you install django microsoft auth by pip, it doesn't install all requirements, but when you install from the source it does.

AngellusMortis commented 3 years ago

pyjwt is right here in the requirements: https://github.com/AngellusMortis/django_microsoft_auth/blob/master/requirements.txt#L16

Also the requirements.txt is only for testing and development. If you are installing on a production machine, the setup.py (and by extension the requirements.in file) are using which does not have a specific version of pyjwt pinned. If you are using the requirements.txt for a production environment, stop.

boterfly commented 3 years ago

Ok, thanks!

andrewbird2 commented 3 years ago

I found that downgrading pyjwt from 2.0.1 to 1.7.1 fixed this for me.