diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..4405a73 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @peterfox diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md new file mode 100644 index 0000000..b4ae1c4 --- /dev/null +++ b/.github/CONTRIBUTING.md @@ -0,0 +1,55 @@ +# Contributing + +Contributions are **welcome** and will be fully **credited**. + +Please read and understand the contribution guide before creating an issue or pull request. + +## Etiquette + +This project is open source, and as such, the maintainers give their free time to build and maintain the source code +held within. They make the code freely available in the hope that it will be of use to other developers. It would be +extremely unfair for them to suffer abuse or anger for their hard work. + +Please be considerate towards maintainers when raising issues or presenting pull requests. Let's show the +world that developers are civilized and selfless people. + +It's the duty of the maintainer to ensure that all submissions to the project are of sufficient +quality to benefit the project. Many developers have different skillsets, strengths, and weaknesses. Respect the maintainer's decision, and do not be upset or abusive if your submission is not used. + +## Viability + +When requesting or submitting new features, first consider whether it might be useful to others. Open +source projects are used by many developers, who may have entirely different needs to your own. Think about +whether or not your feature is likely to be used by other users of the project. + +## Procedure + +Before filing an issue: + +- Attempt to replicate the problem, to ensure that it wasn't a coincidental incident. +- Check to make sure your feature suggestion isn't already present within the project. +- Check the pull requests tab to ensure that the bug doesn't have a fix in progress. +- Check the pull requests tab to ensure that the feature isn't already in progress. + +Before submitting a pull request: + +- Check the codebase to ensure that your feature doesn't already exist. +- Check the pull requests to ensure that another person hasn't already submitted the feature or fix. + +## Requirements + +If the project maintainer has any additional requirements, you will find them listed here. + +- **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](https://pear.php.net/package/PHP_CodeSniffer). + +- **Add tests!** - Your patch won't be accepted if it doesn't have tests. + +- **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date. + +- **Consider our release cycle** - We try to follow [SemVer v2.0.0](https://semver.org/). Randomly breaking public APIs is not an option. + +- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests. + +- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](https://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting. + +**Happy coding**! diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..f93aef3 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1 @@ +github: peterfox \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/bug.yml b/.github/ISSUE_TEMPLATE/bug.yml new file mode 100644 index 0000000..3499a13 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug.yml @@ -0,0 +1,60 @@ +name: Bug Report +description: Report an Issue or Bug with the Package +title: "[Bug]: " +labels: ["bug"] +assignees: + - peterfox +body: + - type: markdown + attributes: + value: | + We're sorry to hear you have a problem. Can you help us solve it by providing the following details. + - type: textarea + id: what-happened + attributes: + label: What happened? + description: What did you expect to happen? + placeholder: I cannot currently do X thing because when I do, it breaks X thing. + validations: + required: true + - type: textarea + id: how-to-reproduce + attributes: + label: How to reproduce the bug + description: How did this occur, please add any config values used and provide a set of reliable steps if possible. + placeholder: When I do X I see Y. + validations: + required: true + - type: input + id: package-version + attributes: + label: Package Version + description: What version of our Package are you running? Please be as specific as possible + placeholder: 2.0.0 + validations: + required: true + - type: input + id: php-version + attributes: + label: PHP Version + description: What version of PHP are you running? Please be as specific as possible + placeholder: 8.1.0 + validations: + required: true + - type: dropdown + id: operating-systems + attributes: + label: Which operating systems does with happen with? + description: You may select more than one. + multiple: true + options: + - macOS + - Windows + - Linux + - type: textarea + id: notes + attributes: + label: Notes + description: Use this field to provide any other notes that you feel might be relevant to the issue. + validations: + required: false diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..853f9ca --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,11 @@ +blank_issues_enabled: false +contact_links: + - name: Ask a question + url: https://github.com/ylsideas/google-cloud-jwt-validator/discussions/new?category=q-a + about: Ask the community for help + - name: Request a feature + url: https://github.com/ylsideas/google-cloud-jwt-validator/discussions/new?category=ideas + about: Share ideas for new features + - name: Report a security issue + url: https://github.com/ylsideas/google-cloud-jwt-validator/security/policy + about: Learn how to notify us for sensitive bugs diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..9a3bb47 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,21 @@ +## Changes In Code + + + +## Issue ticket number / Business Case + + + +## Checklist before requesting a review +- [ ] I have written PHP tests. +- [ ] I have updated the documentation in the readme where needed. +- [ ] I have checked code styles, PHPStan etc. pass. +- [ ] I have provided an issue/business case. diff --git a/.github/SECURITY.md b/.github/SECURITY.md new file mode 100644 index 0000000..e4bfd6f --- /dev/null +++ b/.github/SECURITY.md @@ -0,0 +1,3 @@ +# Security Policy + +If you discover any security related issues, please email peter.fox@ylsideas.co instead of using the issue tracker. diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 0000000..a7c7a6b --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,32 @@ +name: Coverage + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + generate-coverage: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 8.2 + extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, pdo_pgsql + tools: composer:v2 + coverage: pcov + + - uses: ramsey/composer-install@v2 + + - name: Execute tests + run: vendor/bin/pest + + - uses: codecov/codecov-action@v3 + with: + files: ./build/logs/clover.xml diff --git a/.github/workflows/php-cs-fixer.yml b/.github/workflows/php-cs-fixer.yml deleted file mode 100644 index f55d1fa..0000000 --- a/.github/workflows/php-cs-fixer.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: Check & fix styling - -on: [push] - -jobs: - php-cs-fixer: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v2 - with: - ref: ${{ github.head_ref }} - - - name: Run PHP CS Fixer - uses: docker://oskarstark/php-cs-fixer-ga - with: - args: --config=.php_cs.dist.php --allow-risky=yes - - - name: Commit changes - uses: stefanzweifel/git-auto-commit-action@v4 - with: - commit_message: Fix styling diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml index 19d6402..0ea79e8 100644 --- a/.github/workflows/phpstan.yml +++ b/.github/workflows/phpstan.yml @@ -16,7 +16,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.0' + php-version: 8.2 coverage: none - name: Install composer dependencies diff --git a/.github/workflows/pint.yml b/.github/workflows/pint.yml new file mode 100644 index 0000000..e381eee --- /dev/null +++ b/.github/workflows/pint.yml @@ -0,0 +1,24 @@ +name: Fix PHP code style issues + +on: + push: + paths: + - '**.php' + +jobs: + pint: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + ref: ${{ github.head_ref }} + + - name: Fix PHP code style issues + uses: aglipanci/laravel-pint-action@1.0.0 + + - name: Commit changes + uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: Fix PHP styling diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 4e9908f..1211712 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -11,12 +11,9 @@ jobs: strategy: fail-fast: false matrix: - os: [ ubuntu-latest, windows-latest ] - php: [ 8.1, 8.0, 7.4 ] + os: [ ubuntu-latest ] + php: [ 8.2, 8.1 ] stability: [ prefer-lowest, prefer-stable ] - exclude: - - php: 8.1 - stability: prefer-lowest name: P${{ matrix.php }} - ${{ matrix.stability }} - ${{ matrix.os }} diff --git a/.php_cs.dist.php b/.php_cs.dist.php deleted file mode 100644 index 7ee4ffa..0000000 --- a/.php_cs.dist.php +++ /dev/null @@ -1,39 +0,0 @@ -in([ - __DIR__ . '/src', - __DIR__ . '/tests', - ]) - ->name('*.php') - ->ignoreDotFiles(true) - ->ignoreVCS(true); - -return (new PhpCsFixer\Config()) - ->setRules([ - '@PSR12' => true, - 'array_syntax' => ['syntax' => 'short'], - 'ordered_imports' => ['sort_algorithm' => 'alpha'], - 'no_unused_imports' => true, - 'not_operator_with_successor_space' => true, - 'trailing_comma_in_multiline' => true, - 'phpdoc_scalar' => true, - 'unary_operator_spaces' => true, - 'binary_operator_spaces' => true, - 'blank_line_before_statement' => [ - 'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'], - ], - 'phpdoc_single_line_var_spacing' => true, - 'phpdoc_var_without_name' => true, - 'class_attributes_separation' => [ - 'elements' => [ - 'method' => 'one', - ], - ], - 'method_argument_space' => [ - 'on_multiline' => 'ensure_fully_multiline', - 'keep_multiple_spaces_after_comma' => true, - ], - 'single_trait_insert_per_statement' => true, - ]) - ->setFinder($finder); diff --git a/LICENSE.md b/LICENSE.md index dfc4a49..bacfaf4 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) Trade Cover Exchange +Copyright (c) YLS Ideas Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 130ecc6..6c17f87 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ # Google Cloud JWT Authentication -[![Latest Version on Packagist](https://img.shields.io/packagist/v/tradecoverexchange/google-cloud-jwt-validator.svg?style=flat-square)](https://packagist.org/packages/tradecoverexchange/google-cloud-jwt-validator) -[![GitHub Tests Action Status](https://img.shields.io/github/workflow/status/tradecoverexchange/google-cloud-jwt-validator/run-tests?label=tests)](https://github.com/tradecoverexchange/google-cloud-jwt-validator/actions?query=workflow%3Arun-tests+branch%3Amain) -[![GitHub Code Style Action Status](https://img.shields.io/github/workflow/status/tradecoverexchange/google-cloud-jwt-validator/Check%20&%20fix%20styling?label=code%20style)](https://github.com/tradecoverexchange/google-cloud-jwt-validator/actions?query=workflow%3A"Check+%26+fix+styling"+branch%3Amain) -[![Total Downloads](https://img.shields.io/packagist/dt/tradecoverexchange/google-cloud-jwt-validator.svg?style=flat-square)](https://packagist.org/packages/tradecoverexchange/google-cloud-jwt-validator) +[![Latest Version on Packagist](https://img.shields.io/packagist/v/ylsideas/google-cloud-jwt-validator.svg?style=flat-square)](https://packagist.org/packages/ylsideas/google-cloud-jwt-validator) +[![GitHub Tests Action Status](https://img.shields.io/github/workflow/status/ylsideas/google-cloud-jwt-validator/run-tests?label=tests)](https://github.com/ylsideas/google-cloud-jwt-validator/actions?query=workflow%3Arun-tests+branch%3Amain) +[![GitHub Code Style Action Status](https://img.shields.io/github/workflow/status/ylsideas/google-cloud-jwt-validator/Check%20&%20fix%20styling?label=code%20style)](https://github.com/ylsideas/google-cloud-jwt-validator/actions?query=workflow%3A"Check+%26+fix+styling"+branch%3Amain) +[![Total Downloads](https://img.shields.io/packagist/dt/ylsideas/google-cloud-jwt-validator.svg?style=flat-square)](https://packagist.org/packages/ylsideas/google-cloud-jwt-validator) A package for validating the authenticity of incoming Google Cloud requests such as those used by @@ -14,7 +14,7 @@ Google Cloud Tasks or Google Cloud Scheduler. Laravel supported. You can install the package via composer: ```bash -composer require tradecoverexchange/google-cloud-jwt-validator +composer require ylsideas/google-cloud-jwt-validator ``` ## Usage @@ -27,7 +27,7 @@ without a valid JWT authentication token. Route::get('/') ->middleware( - \TradeCoverExchange\GoogleJwtVerifier\Laravel\AuthenticateByOidc::middleware('server_account_email@google.com') + \YlsIdeas\GoogleJwtVerifier\Laravel\AuthenticateByOidc::middleware('server_account_email@google.com') ); ``` diff --git a/composer.json b/composer.json index 35d5c10..f4bebb8 100644 --- a/composer.json +++ b/composer.json @@ -1,12 +1,12 @@ { - "name": "tradecoverexchange/google-cloud-jwt-validator", + "name": "ylsideas/google-cloud-jwt-validator", "description": "A package for validating Google Cloud's JWT provided by webhooks", "keywords": [ "trade cover exchange", "json web token", "google cloud" ], - "homepage": "https://github.com/tradecoverexchange/google-cloud-jwt-validator", + "homepage": "https://github.com/ylsideas/google-cloud-jwt-validator", "license": "MIT", "authors": [ { @@ -23,12 +23,12 @@ } ], "require": { - "php": "^8.0|^7.4", - "firebase/php-jwt": "^6.0|^5.2" + "php": "^8.1", + "firebase/php-jwt": "^6.0" }, "require-dev": { "kevinrob/guzzle-cache-middleware": "^3.3", - "orchestra/testbench": "^7.0|^6.24.1|^5.20.0", + "orchestra/testbench": "^8.0|^7.0", "nunomaduro/collision": "^6.0|^5.0", "pestphp/pest": "^1.21", "pestphp/pest-plugin-laravel": "^1.1", @@ -37,27 +37,29 @@ "phpstan/phpstan-deprecation-rules": "^1.0", "phpstan/phpstan-phpunit": "^1.0", "phpunit/phpunit": "^9.5.13|^8.3", - "spatie/laravel-ray": "^1.26" + "spatie/laravel-ray": "^1.26", + "laravel/pint": "^1.2" }, "autoload": { "psr-4": { - "TradeCoverExchange\\GoogleJwtVerifier\\": "src" + "YlsIdeas\\GoogleJwtVerifier\\": "src" } }, "autoload-dev": { "psr-4": { - "TradeCoverExchange\\GoogleJwtVerifier\\Tests\\": "tests" + "YlsIdeas\\GoogleJwtVerifier\\Tests\\": "tests" } }, "extra": { "laravel": { "providers": [ - "TradeCoverExchange\\GoogleJwtVerifier\\Laravel\\GoogleJwtValidatorServiceProvider" + "YlsIdeas\\GoogleJwtVerifier\\Laravel\\GoogleJwtValidatorServiceProvider" ] } }, "scripts": { "analyse": "vendor/bin/phpstan analyse", + "lint": "vendor/bin/pint", "test": "vendor/bin/pest", "test-coverage": "vendor/bin/pest coverage" }, diff --git a/pint.json b/pint.json new file mode 100644 index 0000000..c220366 --- /dev/null +++ b/pint.json @@ -0,0 +1,45 @@ +{ + "preset": "psr12", + "exclude": [ + "bin" + ], + "rules": { + "array_syntax": { + "syntax": "short" + }, + "ordered_imports": { + "sort_algorithm": "alpha" + }, + "no_unused_imports": true, + "not_operator_with_successor_space": true, + "trailing_comma_in_multiline": true, + "phpdoc_scalar": true, + "unary_operator_spaces": true, + "binary_operator_spaces": true, + "blank_line_before_statement": { + "statements": [ + "break", + "continue", + "declare", + "return", + "throw", + "try" + ] + }, + "phpdoc_single_line_var_spacing": true, + "phpdoc_var_without_name": true, + "class_attributes_separation": { + "elements": { + "method": "one" + } + }, + "method_argument_space": { + "on_multiline": "ensure_fully_multiline", + "keep_multiple_spaces_after_comma": true + }, + "single_trait_insert_per_statement": true, + "php_unit_method_casing": { + "case": "snake_case" + } + } +} diff --git a/src/Exceptions/FailedToDecodeException.php b/src/Exceptions/FailedToDecodeException.php index c0fd416..06be320 100644 --- a/src/Exceptions/FailedToDecodeException.php +++ b/src/Exceptions/FailedToDecodeException.php @@ -1,6 +1,6 @@ withoutExceptionHandling(); @@ -35,7 +35,7 @@ public function testValidatesVerifiableTokens() ->assertSuccessful(); } - public function testMiddlewareBlocksUnauthorisedRequests() + public function test_middleware_blocks_unauthorised_requests() { $this->mock(OidcVerifier::class, function (MockInterface $mock) { $mock->shouldReceive('verify') @@ -49,7 +49,7 @@ public function testMiddlewareBlocksUnauthorisedRequests() ->assertUnauthorized(); } - public function testMiddlewareBlocksRequests() + public function test_middleware_blocks_requests() { $this->mock(OidcVerifier::class, function (MockInterface $mock) { $mock->shouldReceive('verify') diff --git a/tests/Laravel/ServiceProviderTest.php b/tests/Laravel/ServiceProviderTest.php index 811ad8a..6202b68 100644 --- a/tests/Laravel/ServiceProviderTest.php +++ b/tests/Laravel/ServiceProviderTest.php @@ -1,15 +1,15 @@ app->make(JwkFetcher::class);