Skip to content

Commit

Permalink
Merge branch 'main' into drop-php80
Browse files Browse the repository at this point in the history
  • Loading branch information
bshaffer authored Aug 27, 2024
2 parents c8cbdf6 + e10dc3f commit 2c04e76
Show file tree
Hide file tree
Showing 40 changed files with 2,314 additions and 161 deletions.
11 changes: 0 additions & 11 deletions .github/actions/docs/entrypoint.sh

This file was deleted.

27 changes: 0 additions & 27 deletions .github/actions/docs/sami.php

This file was deleted.

1 change: 1 addition & 0 deletions .github/release-please.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
releaseType: simple
handleGHRelease: true
primaryBranch: main
versionFile: VERSION
42 changes: 14 additions & 28 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,23 @@
name: Generate Documentation
on:
push:
branches:
- main
tags:
- "*"
workflow_dispatch:
inputs:
tag:
description: 'Tag to release'
pull_request:

permissions:
contents: write

jobs:
docs:
name: "Generate Project Documentation"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
- name: Install Dependencies
uses: nick-invision/retry@v3
with:
timeout_minutes: 10
max_attempts: 3
command: composer config repositories.sami vcs https://${{ secrets.GITHUB_TOKEN }}@github.com/jdpedrie/sami.git && composer require sami/sami:v4.2 && git reset --hard HEAD
- name: Generate Documentation
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
run: .github/actions/docs/entrypoint.sh
- name: Deploy 🚀
uses: JamesIves/github-pages-deploy-action@releases/v3
with:
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
BRANCH: gh-pages
FOLDER: .docs
name: "Generate and Deploy Documentation"
uses: GoogleCloudPlatform/php-tools/.github/workflows/doctum.yml@main
with:
title: "Google Auth Library PHP Reference Documentation"
default_version: ${{ inputs.tag || github.head_ref || github.ref_name }}
dry_run: ${{ github.event_name == 'pull_request' }}

39 changes: 12 additions & 27 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,30 @@ permissions:
contents: read
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
php: [ "8.1", "8.2", "8.3" ]
name: PHP ${{matrix.php }} Unit Test
os: [ ubuntu-latest ]
include:
- os: windows-latest
php: "8.1"
runs-on: ${{ matrix.os }}
name: PHP ${{ matrix.php }} Unit Test ${{ matrix.os == 'windows-latest' && 'on Windows' || '' }}
steps:
- uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: ${{ matrix.os == 'windows-latest' && 'gmp, php_com_dotnet' || '' }}
- name: Install Dependencies
uses: nick-invision/retry@v3
with:
timeout_minutes: 10
max_attempts: 3
command: composer install
- name: Run Script
run: vendor/bin/phpunit
run: vendor/bin/phpunit ${{ matrix.os == 'windows-latest' && '--filter GCECredentialsTest' || '' }}
test_lowest:
runs-on: ubuntu-latest
name: Test Prefer Lowest
Expand All @@ -46,31 +51,11 @@ jobs:
run: vendor/bin/phpunit

style:
runs-on: ubuntu-latest
name: PHP Style Check
steps:
- uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
- name: Run Script
run: |
composer install
composer global require friendsofphp/php-cs-fixer:^3.0
~/.composer/vendor/bin/php-cs-fixer fix --dry-run --diff
uses: GoogleCloudPlatform/php-tools/.github/workflows/code-standards.yml@main

staticanalysis:
runs-on: ubuntu-latest
name: PHPStan Static Analysis
steps:
- uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
- name: Run Script
run: |
composer install
composer global require phpstan/phpstan:^1.8
~/.composer/vendor/bin/phpstan analyse
uses: GoogleCloudPlatform/php-tools/.github/workflows/static-analysis.yml@main
with:
autoload-file: tests/phpstan-autoload.php
25 changes: 0 additions & 25 deletions .php-cs-fixer.dist.php

This file was deleted.

36 changes: 36 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,42 @@

* [feat]: add support for Firebase v6.0 (#391)

## [1.42.0](https://github.com/googleapis/google-auth-library-php/compare/v1.41.0...v1.42.0) (2024-08-26)


### Features

* Add a file system cache class ([#571](https://github.com/googleapis/google-auth-library-php/issues/571)) ([8555cb0](https://github.com/googleapis/google-auth-library-php/commit/8555cb063caa5571f80d9605969411b894ee6eb0))
* Private key getters on service account credentials (https://github.com/googleapis/google-auth-library-php/pull/557) ([d2fa07b](https://github.com/googleapis/google-auth-library-php/commit/d2fa07b8a8edfa65c1bd732dac794c070e3451bc))

## [1.41.0](https://github.com/googleapis/google-auth-library-php/compare/v1.40.0...v1.41.0) (2024-07-10)


### Features

* Change getCacheKey implementation for more unique keys ([#560](https://github.com/googleapis/google-auth-library-php/issues/560)) ([a35c4db](https://github.com/googleapis/google-auth-library-php/commit/a35c4dbb52e01faedacd09d23634939ced4a8a63))

## [1.40.0](https://github.com/googleapis/google-auth-library-php/compare/v1.39.0...v1.40.0) (2024-05-31)


### Features

* Add windows residency check ([#553](https://github.com/googleapis/google-auth-library-php/issues/553)) ([ec13a53](https://github.com/googleapis/google-auth-library-php/commit/ec13a53ddd625265b7a596817eb052c693ab89e2))

## [1.39.0](https://github.com/googleapis/google-auth-library-php/compare/v1.38.0...v1.39.0) (2024-05-02)


### Features

* Enable auth observability metrics ([#509](https://github.com/googleapis/google-auth-library-php/issues/509)) ([6495f31](https://github.com/googleapis/google-auth-library-php/commit/6495f31061d2d51a173a968dbe65db8dfc6ac3cc))

## [1.38.0](https://github.com/googleapis/google-auth-library-php/compare/v1.37.1...v1.38.0) (2024-04-24)


### Features

* Add ExecutableSource credentials ([#525](https://github.com/googleapis/google-auth-library-php/issues/525)) ([d98900d](https://github.com/googleapis/google-auth-library-php/commit/d98900d47bb5d6eeeaf64fc2a6a8dbde5797f338))

## [1.37.1](https://github.com/googleapis/google-auth-library-php/compare/v1.37.0...v1.37.1) (2024-03-07)


Expand Down
52 changes: 52 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,58 @@ $auth->verify($idToken, [
[google-id-tokens]: https://developers.google.com/identity/sign-in/web/backend-auth
[iap-id-tokens]: https://cloud.google.com/iap/docs/signed-headers-howto

## Caching
Caching is enabled by passing a PSR-6 `CacheItemPoolInterface`
instance to the constructor when instantiating the credentials.

We offer some caching classes out of the box under the `Google\Auth\Cache` namespace.

```php
use Google\Auth\ApplicationDefaultCredentials;
use Google\Auth\Cache\MemoryCacheItemPool;

// Cache Instance
$memoryCache = new MemoryCacheItemPool;

// Get the credentials
// From here, the credentials will cache the access token
$middleware = ApplicationDefaultCredentials::getCredentials($scope, cache: $memoryCache);
```

### FileSystemCacheItemPool Cache
The `FileSystemCacheItemPool` class is a `PSR-6` compliant cache that stores its
serialized objects on disk, caching data between processes and making it possible
to use data between different requests.

```php
use Google\Auth\Cache\FileSystemCacheItemPool;
use Google\Auth\ApplicationDefaultCredentials;

// Create a Cache pool instance
$cache = new FileSystemCacheItemPool(__DIR__ . '/cache');

// Pass your Cache to the Auth Library
$credentials = ApplicationDefaultCredentials::getCredentials($scope, cache: $cache);

// This token will be cached and be able to be used for the next request
$token = $credentials->fetchAuthToken();
```

### Integrating with a third party cache
You can use a third party that follows the `PSR-6` interface of your choice.

```php
// run "composer require symfony/cache"
use Google\Auth\ApplicationDefaultCredentials;
use Symfony\Component\Cache\Adapter\FilesystemAdapter;

// Create the cache instance
$filesystemCache = new FilesystemAdapter();

// Create Get the credentials
$credentials = ApplicationDefaultCredentials::getCredentials($targetAudience, cache: $filesystemCache);
```

## License

This library is licensed under Apache 2.0. Full license text is
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.37.1
1.42.0
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"sebastian/comparator": ">=1.2.3",
"phpseclib/phpseclib": "^3.0.35",
"kelvinmo/simplejwt": "0.7.1",
"webmozart/assert": "^1.11"
"webmozart/assert": "^1.11",
"symfony/process": "^6.0||^7.0"
},
"suggest": {
"phpseclib/phpseclib": "May be used in place of OpenSSL for signing strings or for token management. Please require version ^2."
Expand Down
Loading

0 comments on commit 2c04e76

Please sign in to comment.