From c52b003677e1565422452e78dd9c9337718eeb92 Mon Sep 17 00:00:00 2001 From: Schparky <3172830+Schparky@users.noreply.github.com> Date: Tue, 1 Jun 2021 10:13:11 -0600 Subject: [PATCH 1/3] search by user ID first in Google adapter --- CHANGELOG.md | 1 + .../components/passwordStore/Google.php | 20 +++++++++---------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 640be138..cf36c46c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] +- Reverse the order of searching for a Google user, now use ID first ## [5.5.0] ### Added diff --git a/application/common/components/passwordStore/Google.php b/application/common/components/passwordStore/Google.php index 0fcb4774..55c0cec8 100644 --- a/application/common/components/passwordStore/Google.php +++ b/application/common/components/passwordStore/Google.php @@ -170,20 +170,20 @@ public function getMeta($employeeId): UserPasswordMeta * Employee ID. * * @param string $employeeId The Employee ID of the desired user. - * @return Google_Service_Directory_User|null The user record from Google. + * @return Google_Service_Directory_User The user record from Google. * @throws UserNotFoundException if email not defined or user not found in Google */ - protected function getUser(string $employeeId): ?Google_Service_Directory_User + protected function getUser(string $employeeId): Google_Service_Directory_User { - $email = $this->getEmailFromLocalStore($employeeId); - $user = $this->getUserByEmail($email); - - if ($user === null) { - return $this->getUserByEmployeeId($employeeId); - } + try { + $user = $this->getUserByEmployeeId($employeeId); + } catch (UserNotFoundException $e) { + $email = $this->getEmailFromLocalStore($employeeId); - if (! self::hasCorrectEmployeeId($user, $employeeId)) { - return null; + $user = $this->getUserByEmail($email); + if (! self::hasCorrectEmployeeId($user, $employeeId)) { + throw new UserNotFoundException(); + } } return $user; From 991bafe25d39e66639da3c1d9f7e0f43151e8390 Mon Sep 17 00:00:00 2001 From: Schparky <3172830+Schparky@users.noreply.github.com> Date: Tue, 1 Jun 2021 12:21:51 -0600 Subject: [PATCH 2/3] revert back to PHP 7.2 --- Dockerfile | 52 ++++++----------------------------- application/run-tests.sh | 4 +-- application/run.sh | 4 +-- dockerbuild/10-enable-env.ini | 5 ---- 4 files changed, 11 insertions(+), 54 deletions(-) delete mode 100644 dockerbuild/10-enable-env.ini diff --git a/Dockerfile b/Dockerfile index ff44e3df..d2e28d95 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,53 +1,18 @@ -FROM silintl/php7-apache:7.4.19 -LABEL maintainer="Phillip Shipley " +FROM silintl/php7:7.2 +MAINTAINER Phillip Shipley -RUN apt-get update -y && \ - apt-get install -y \ -# Needed to install s3cmd - python-pip \ -# Needed to build php extensions - libfreetype6-dev \ - libgmp-dev \ - libjpeg62-turbo-dev \ - libldap2-dev \ - libpng-dev \ - libonig-dev \ - libxml2-dev \ - libzip-dev \ - libcurl4-openssl-dev \ -# Clean up to reduce docker image size - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* - -RUN curl https://raw.githubusercontent.com/silinternational/runny/0.2/runny -o /usr/local/bin/runny -RUN chmod a+x /usr/local/bin/runny - -# Install and enable, see the README on the docker hub for the image -RUN pecl install memcache-4.0.5.2 && docker-php-ext-enable memcache -RUN docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu/ && \ - docker-php-ext-install gmp ldap zip +ENV REFRESHED_AT 2020-04-07 -# Copy in vhost configuration -COPY dockerbuild/vhost.conf /etc/apache2/sites-enabled/ +RUN apt-get update -y && \ + apt-get install -y php-memcache && \ + apt-get clean -# Ensure the DocumentRoot folder exists RUN mkdir -p /data -# Validate apache configuration -RUN ["apache2ctl", "configtest"] - -# Copy in any additional PHP ini files -COPY dockerbuild/*.ini "$PHP_INI_DIR/conf.d/" - -# get s3cmd and s3-expand -RUN pip install s3cmd +# get s3-expand RUN curl https://raw.githubusercontent.com/silinternational/s3-expand/1.5/s3-expand -o /usr/local/bin/s3-expand RUN chmod a+x /usr/local/bin/s3-expand -# Clean up all the build stuff we don't need -RUN apt purge -y dpkg-dev cpp-8 gcc-8 python2-dev python2.7-dev && \ - apt autoremove -y - WORKDIR /data # Install/cleanup composer dependencies @@ -64,6 +29,8 @@ RUN chown -R www-data:www-data \ frontend/runtime/ \ frontend/web/assets/ +COPY dockerbuild/vhost.conf /etc/apache2/sites-enabled/ + # ErrorLog inside a VirtualHost block is ineffective for unknown reasons RUN sed -i -E 's@ErrorLog .*@ErrorLog /proc/self/fd/2@i' /etc/apache2/apache2.conf @@ -71,5 +38,4 @@ RUN touch /etc/default/locale EXPOSE 80 ENTRYPOINT ["/usr/local/bin/s3-expand"] - CMD ["/data/run.sh"] diff --git a/application/run-tests.sh b/application/run-tests.sh index 3565de62..5e260368 100755 --- a/application/run-tests.sh +++ b/application/run-tests.sh @@ -12,9 +12,7 @@ mkdir -p /data/runtime/mail whenavail ${MYSQL_HOST} 3306 100 /data/yii migrate --interactive=0 # Install and enable xdebug for code coverage -apt-get update && apt-get install -y build-essential -pecl install xdebug -docker-php-ext-enable xdebug +apt-get install -y php-xdebug # Run codeception tests whenavail broker 80 100 echo "broker ready, running unit tests..." diff --git a/application/run.sh b/application/run.sh index 12d01833..bf8658a9 100755 --- a/application/run.sh +++ b/application/run.sh @@ -13,9 +13,7 @@ runny /data/yii migrate --interactive=0 if [[ $APP_ENV == "dev" ]]; then export XDEBUG_CONFIG="remote_enable=1 remote_host="$REMOTE_DEBUG_IP - apt-get update && apt-get install -y build-essential - pecl install xdebug - docker-php-ext-enable xdebug + apt-get install php-xdebug fi apache2ctl -k start -D FOREGROUND diff --git a/dockerbuild/10-enable-env.ini b/dockerbuild/10-enable-env.ini deleted file mode 100644 index f6409dfd..00000000 --- a/dockerbuild/10-enable-env.ini +++ /dev/null @@ -1,5 +0,0 @@ -; Populate the $_ENV superglobal, since PhpEnv uses that to get an array of -; values from the environment variables based on an env. var name prefix. -; Without $_ENV, we have no way to see what all env. vars are defined (and thus -; no way to find all the ones that start with the given prefix). -variables_order = "EGPCS" From fee66af5ea15d89c52e35dc42c5b1b671f4d2265 Mon Sep 17 00:00:00 2001 From: Schparky <3172830+Schparky@users.noreply.github.com> Date: Tue, 1 Jun 2021 12:34:52 -0600 Subject: [PATCH 3/3] update CHANGELOG --- CHANGELOG.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cf36c46c..17fcae7c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,11 +5,17 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] + +## [5.5.1] +### Changed - Reverse the order of searching for a Google user, now use ID first +- Downgraded PHP back to 7.2 ## [5.5.0] ### Added - In Google adapter, search by email as well as by external ID +### Changed +- Upgraded PHP to 7.4 ## [5.4.0] ### Added @@ -147,7 +153,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Added - Initial version of Password Manager Backend. -[Unreleased]: https://github.com/silinternational/idp-pw-api/compare/5.5.0...HEAD +[Unreleased]: https://github.com/silinternational/idp-pw-api/compare/5.5.1...HEAD +[5.5.1]: https://github.com/silinternational/idp-pw-api/compare/5.5.0...5.5.1 [5.5.0]: https://github.com/silinternational/idp-pw-api/compare/5.4.0...5.5.0 [5.4.0]: https://github.com/silinternational/idp-pw-api/compare/5.3.4...5.4.0 [5.3.4]: https://github.com/silinternational/idp-pw-api/compare/5.3.3...5.3.4