diff --git a/Dockerfile b/Dockerfile index c2c4d343f..e395ce7cf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -28,6 +28,7 @@ ENV RELEASE ${RELEASE} RUN mkdir /app COPY pyproject.toml /app/pyproject.toml +COPY poetry.lock /app/poetry.lock WORKDIR /app RUN pip install poetry diff --git a/lego/apps/external_sync/utils/gsuite.py b/lego/apps/external_sync/utils/gsuite.py index e9d9a37e9..9fdb4d8a8 100644 --- a/lego/apps/external_sync/utils/gsuite.py +++ b/lego/apps/external_sync/utils/gsuite.py @@ -1,10 +1,9 @@ from django.conf import settings from django.core.exceptions import ImproperlyConfigured +from google.oauth2 import service_account from googleapiclient.discovery import build from googleapiclient.errors import HttpError -from httplib2 import Http -from oauth2client.service_account import ServiceAccountCredentials scopes = [ "https://www.googleapis.com/auth/admin.directory.user", @@ -24,7 +23,7 @@ def __init__(self): self.client = build( "admin", "directory_v1", - http=credentials.authorize(Http()), + credentials=credentials, cache_discovery=False, ) @@ -35,10 +34,11 @@ def get_credentials(self): if settings.GSUITE_CREDENTIALS is None: raise ImproperlyConfigured("Missing GSuite credentials") - credentials = ServiceAccountCredentials.from_json_keyfile_dict( - settings.GSUITE_CREDENTIALS, scopes + return service_account.Credentials.from_service_account_info( + settings.GSUITE_CREDENTIALS, + scopes=scopes, + subject=settings.GSUITE_DELEGATED_ACCOUNT, ) - return credentials.create_delegated(settings.GSUITE_DELEGATED_ACCOUNT) def get_user(self, user_key): return self.client.users().get(userKey=user_key).execute() diff --git a/poetry.lock b/poetry.lock index 8669bb169..80e17c698 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.8.5 and should not be changed by hand. [[package]] name = "aiosmtpd" @@ -1768,61 +1768,60 @@ grpcio-gcp = ["grpcio-gcp (>=0.2.2,<1.0dev)"] [[package]] name = "google-api-python-client" -version = "2.96.0" +version = "2.155.0" description = "Google API Client Library for Python" optional = false python-versions = ">=3.7" files = [ - {file = "google-api-python-client-2.96.0.tar.gz", hash = "sha256:f712373d03d338af57b9f5fe98c91f4b5baaa8765469b015bc623c4681c5bd51"}, - {file = "google_api_python_client-2.96.0-py2.py3-none-any.whl", hash = "sha256:38c2b61b10d15bb41ec8f89303e3837ec2d2c3e4e38de5800c05ee322492f937"}, + {file = "google_api_python_client-2.155.0-py2.py3-none-any.whl", hash = "sha256:83fe9b5aa4160899079d7c93a37be306546a17e6686e2549bcc9584f1a229747"}, + {file = "google_api_python_client-2.155.0.tar.gz", hash = "sha256:25529f89f0d13abcf3c05c089c423fb2858ac16e0b3727543393468d0d7af67c"}, ] [package.dependencies] google-api-core = ">=1.31.5,<2.0.dev0 || >2.3.0,<3.0.0.dev0" -google-auth = ">=1.19.0,<3.0.0.dev0" -google-auth-httplib2 = ">=0.1.0" -httplib2 = ">=0.15.0,<1.dev0" +google-auth = ">=1.32.0,<2.24.0 || >2.24.0,<2.25.0 || >2.25.0,<3.0.0.dev0" +google-auth-httplib2 = ">=0.2.0,<1.0.0" +httplib2 = ">=0.19.0,<1.dev0" uritemplate = ">=3.0.1,<5" [[package]] name = "google-auth" -version = "2.17.3" +version = "2.37.0" description = "Google Authentication Library" optional = false -python-versions = ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*" +python-versions = ">=3.7" files = [ - {file = "google-auth-2.17.3.tar.gz", hash = "sha256:ce311e2bc58b130fddf316df57c9b3943c2a7b4f6ec31de9663a9333e4064efc"}, - {file = "google_auth-2.17.3-py2.py3-none-any.whl", hash = "sha256:f586b274d3eb7bd932ea424b1c702a30e0393a2e2bc4ca3eae8263ffd8be229f"}, + {file = "google_auth-2.37.0-py2.py3-none-any.whl", hash = "sha256:42664f18290a6be591be5329a96fe30184be1a1badb7292a7f686a9659de9ca0"}, + {file = "google_auth-2.37.0.tar.gz", hash = "sha256:0054623abf1f9c83492c63d3f47e77f0a544caa3d40b2d98e099a611c2dd5d00"}, ] [package.dependencies] cachetools = ">=2.0.0,<6.0" pyasn1-modules = ">=0.2.1" -rsa = {version = ">=3.1.4,<5", markers = "python_version >= \"3.6\""} -six = ">=1.9.0" +rsa = ">=3.1.4,<5" [package.extras] -aiohttp = ["aiohttp (>=3.6.2,<4.0.0dev)", "requests (>=2.20.0,<3.0.0dev)"] -enterprise-cert = ["cryptography (==36.0.2)", "pyopenssl (==22.0.0)"] +aiohttp = ["aiohttp (>=3.6.2,<4.0.0.dev0)", "requests (>=2.20.0,<3.0.0.dev0)"] +enterprise-cert = ["cryptography", "pyopenssl"] +pyjwt = ["cryptography (>=38.0.3)", "pyjwt (>=2.0)"] pyopenssl = ["cryptography (>=38.0.3)", "pyopenssl (>=20.0.0)"] reauth = ["pyu2f (>=0.1.5)"] -requests = ["requests (>=2.20.0,<3.0.0dev)"] +requests = ["requests (>=2.20.0,<3.0.0.dev0)"] [[package]] name = "google-auth-httplib2" -version = "0.1.0" +version = "0.2.0" description = "Google Authentication Library: httplib2 transport" optional = false python-versions = "*" files = [ - {file = "google-auth-httplib2-0.1.0.tar.gz", hash = "sha256:a07c39fd632becacd3f07718dfd6021bf396978f03ad3ce4321d060015cc30ac"}, - {file = "google_auth_httplib2-0.1.0-py2.py3-none-any.whl", hash = "sha256:31e49c36c6b5643b57e82617cb3e021e3e1d2df9da63af67252c02fa9c1f4a10"}, + {file = "google-auth-httplib2-0.2.0.tar.gz", hash = "sha256:38aa7badf48f974f1eb9861794e9c0cb2a0511a4ec0679b1f886d108f5640e05"}, + {file = "google_auth_httplib2-0.2.0-py2.py3-none-any.whl", hash = "sha256:b65a0a2123300dd71281a7bf6e64d65a0759287df52729bdd1ae2e47dc311a3d"}, ] [package.dependencies] google-auth = "*" -httplib2 = ">=0.15.0" -six = "*" +httplib2 = ">=0.19.0" [[package]] name = "googleapis-common-protos" @@ -2849,24 +2848,6 @@ files = [ {file = "numpy-2.1.2.tar.gz", hash = "sha256:13532a088217fa624c99b843eeb54640de23b3414b14aa66d023805eb731066c"}, ] -[[package]] -name = "oauth2client" -version = "4.1.3" -description = "OAuth 2.0 client library" -optional = false -python-versions = "*" -files = [ - {file = "oauth2client-4.1.3-py2.py3-none-any.whl", hash = "sha256:b8a81cc5d60e2d364f0b1b98f958dbd472887acaf1a5b05e21c28c31a2d6d3ac"}, - {file = "oauth2client-4.1.3.tar.gz", hash = "sha256:d486741e451287f69568a4d26d70d9acd73a2bbfa275746c535b4209891cccc6"}, -] - -[package.dependencies] -httplib2 = ">=0.9.1" -pyasn1 = ">=0.1.7" -pyasn1-modules = ">=0.0.5" -rsa = ">=3.1.4" -six = ">=1.6.1" - [[package]] name = "oauthlib" version = "3.2.2" @@ -4498,4 +4479,4 @@ test = ["pytest"] [metadata] lock-version = "2.0" python-versions = "^3.11" -content-hash = "e8cb76e041ea2fe656f2d3ad07b46fa75fcba8b06572d175d976bd701f78e273" +content-hash = "edaaf4ff6a07def7252265d20e554ed8db3d00ebe1098ea8fd7698530b21a5fe" diff --git a/pyproject.toml b/pyproject.toml index dfec9d9c9..085aee65b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,8 +24,8 @@ beautifulsoup4 = "4.12.2" bleach = "5.0.1" requests = "2.32.2" ldap3 = "2.9.1" -google-api-python-client = "2.96.0" -oauth2client = "4.1.3" +google-api-python-client = "^2.155.0" +google-auth = "^2.37.0" libthumbor = "2.0.2" django-health-check = "3.17.0" djangorestframework = "3.14.0"