Skip to content

Commit 0cc3517

Browse files
author
Evan Sims
authored
Merge pull request #200 from auth0/update-php8
Introduce support for PHP 8.0
2 parents b80b879 + f463d01 commit 0cc3517

16 files changed

+295
-137
lines changed

.circleci/config.yml

Lines changed: 39 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,53 @@ commands:
77
- run: sudo composer self-update
88
- restore_cache:
99
keys:
10-
- composer-v1-{{ checksum "composer.json" }}
11-
- composer-v1-
12-
- run: composer install -n --prefer-dist
10+
- composer-v1-{{ .Environment.CIRCLE_JOB }}-{{ checksum "composer.json" }}
11+
- composer-v1-{{ .Environment.CIRCLE_JOB }}
12+
- run: composer update --prefer-dist --no-interaction
1313
- persist_to_workspace:
1414
root: .
1515
paths:
1616
- composer.*
1717
- .snyk
1818
- save_cache:
19-
key: composer-v1-{{ checksum "composer.json" }}
19+
key: composer-v1-{{ .Environment.CIRCLE_JOB }}-{{ checksum "composer.json" }}
2020
paths:
2121
- vendor
22+
run-php-compatibility:
23+
steps:
24+
- run: composer compat
25+
run-static-analysis:
26+
steps:
27+
- run: composer analyze
28+
run-unit-tests:
29+
steps:
30+
- run: composer test
31+
- store_artifacts:
32+
path: build/coverage.xml
2233

2334
jobs:
24-
php_7:
35+
php_7_3:
2536
docker:
26-
- image: circleci/php:7.1
37+
- image: circleci/php:7.3
2738
steps:
2839
- prepare
29-
- run:
30-
name: Check PHP Compatibility
31-
command: composer phpcs
32-
- run:
33-
name: Run Tests
34-
command: composer test
40+
- run-php-compatibility
41+
- run-static-analysis
42+
- run-unit-tests
43+
php_7_4:
44+
docker:
45+
- image: circleci/php:7.4
46+
steps:
47+
- prepare
48+
- run-static-analysis
49+
- run-unit-tests
50+
php_8_0:
51+
docker:
52+
- image: circleci/php:8.0
53+
steps:
54+
- prepare
55+
- run-static-analysis
56+
- run-unit-tests
3557
snyk:
3658
docker:
3759
- image: snyk/snyk-cli:composer
@@ -47,13 +69,13 @@ jobs:
4769
fi
4870
when: always
4971

50-
#Each workflow represents a Github check
5172
workflows:
52-
snyk:
73+
build-and-test:
5374
jobs:
54-
- php_7
75+
- php_7_3
76+
- php_7_4
77+
- php_8_0
5578
- snyk:
56-
# Must define SNYK_TOKEN env
5779
context: snyk-env
5880
requires:
59-
- php_7
81+
- php_7_3

.phpcs-compat.xml.dist

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="Auth0-PHP-PHPCompatibility" namespace="Auth0PHP\CS\Standard">
3+
<description>PHPCompatibility check for Auth0 Laravel SDK</description>
4+
<file>./src</file>
5+
<arg name="extensions" value="php"/>
6+
<arg value="sp"/>
7+
<arg name="basepath" value="."/>
8+
<arg name="colors"/>
9+
10+
<!--
11+
PHPCompatibility sniffs to check for PHP cross-version incompatible code.
12+
https://github.com/PHPCompatibility/PHPCompatibility
13+
-->
14+
<config name="testVersion" value="7.3-"/>
15+
<rule ref="PHPCompatibility"/>
16+
</ruleset>

.phpcs.xml.dist

Lines changed: 93 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,99 @@
2020
PHPCompatibility sniffs to check for PHP cross-version incompatible code.
2121
https://github.com/PHPCompatibility/PHPCompatibility
2222
-->
23-
<config name="testVersion" value="7.1-"/>
23+
<config name="testVersion" value="7.3-"/>
2424
<rule ref="PHPCompatibility"/>
2525

26+
<!--
27+
Generic sniffs
28+
https://github.com/squizlabs/PHP_CodeSniffer/tree/master/src/Standards/Generic/Sniffs
29+
-->
30+
<rule ref="Generic.Arrays">
31+
<exclude name="Generic.Arrays.DisallowShortArraySyntax"/>
32+
</rule>
33+
<rule ref="Generic.Classes.DuplicateClassName"/>
34+
<rule ref="Generic.CodeAnalysis"/>
35+
<rule ref="Generic.Commenting"/>
36+
<rule ref="Generic.ControlStructures">
37+
<exclude name="Generic.ControlStructures.DisallowYodaConditions"/>
38+
</rule>
39+
<rule ref="Generic.Files">
40+
<exclude name="Generic.Files.EndFileNoNewline"/>
41+
<exclude name="Generic.Files.LowercasedFilename"/>
42+
</rule>
43+
<rule ref="Generic.Files.LineLength">
44+
<properties>
45+
<property name="lineLimit" value="120"/>
46+
<property name="absoluteLineLimit" value="120"/>
47+
</properties>
48+
</rule>
49+
<rule ref="Generic.Formatting">
50+
<exclude name="Generic.Formatting.NoSpaceAfterCast"/>
51+
</rule>
52+
<rule ref="Generic.Functions">
53+
<exclude name="Generic.Functions.OpeningFunctionBraceKernighanRitchie"/>
54+
</rule>
55+
<rule ref="Generic.Metrics"/>
56+
<rule ref="Generic.NamingConventions">
57+
<exclude name="Generic.NamingConventions.CamelCapsFunctionName.ScopeNotCamelCaps"/>
58+
</rule>
59+
<rule ref="Generic.PHP">
60+
<exclude name="Generic.PHP.ClosingPHPTag"/>
61+
<exclude name="Generic.PHP.UpperCaseConstant"/>
62+
</rule>
63+
<rule ref="Generic.Strings"/>
64+
<rule ref="Generic.WhiteSpace">
65+
<exclude name="Generic.WhiteSpace.DisallowSpaceIndent"/>
66+
</rule>
67+
68+
<!--
69+
Squiz Labs sniffs
70+
https://github.com/squizlabs/PHP_CodeSniffer/wiki/Customisable-Sniff-Properties
71+
-->
72+
<rule ref="Squiz.Arrays.ArrayBracketSpacing"/>
73+
<rule ref="Squiz.Classes"/>
74+
<rule ref="Squiz.Commenting">
75+
<exclude name="Squiz.Commenting.ClosingDeclarationComment"/>
76+
<exclude name="Squiz.Commenting.ClassComment.TagNotAllowed"/>
77+
<exclude name="Squiz.Commenting.FileComment"/>
78+
<exclude name="Squiz.Commenting.LongConditionClosingComment"/>
79+
<exclude name="Squiz.Commenting.FunctionComment.ScalarTypeHintMissing"/>
80+
<exclude name="Squiz.Commenting.FunctionCommentThrowTag.WrongNumber"/>
81+
</rule>
82+
<rule ref="Squiz.Commenting.FunctionComment">
83+
<exclude-pattern>tests/*\.php</exclude-pattern>
84+
</rule>
85+
<rule ref="Squiz.ControlStructures"/>
86+
<rule ref="Squiz.Functions">
87+
<exclude name="Squiz.Functions.MultiLineFunctionDeclaration.NewlineBeforeOpenBrace"/>
88+
<exclude name="Squiz.ControlStructures.InlineIfDeclaration.NoBrackets"/>
89+
</rule>
90+
<rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing">
91+
<properties>
92+
<property name="equalsSpacing" value="1"/>
93+
</properties>
94+
</rule>
95+
<rule ref="Squiz.Operators">
96+
<exclude name="Squiz.Operators.ComparisonOperatorUsage.NotAllowed"/>
97+
<exclude name="Squiz.Operators.ComparisonOperatorUsage.ImplicitTrue"/>
98+
</rule>
99+
<rule ref="Squiz.PHP">
100+
<exclude name="Squiz.PHP.DisallowComparisonAssignment.AssignedComparison"/>
101+
<exclude name="Squiz.PHP.DisallowInlineIf.Found"/>
102+
<exclude name="Squiz.PHP.DisallowBooleanStatement.Found"/>
103+
</rule>
104+
<rule ref="Squiz.Scope"/>
105+
<rule ref="Squiz.Strings"/>
106+
<rule ref="Squiz.WhiteSpace">
107+
<exclude name="Squiz.WhiteSpace.FunctionClosingBraceSpace"/>
108+
<exclude name="Squiz.WhiteSpace.FunctionSpacing"/>
109+
<exclude name="Squiz.WhiteSpace.ObjectOperatorSpacing"/>
110+
</rule>
111+
<rule ref="Squiz.WhiteSpace.FunctionSpacing">
112+
<properties>
113+
<property name="spacing" value="1"/>
114+
<property name="spacingBeforeFirst" value="0"/>
115+
<property name="spacingAfterLast" value="0"/>
116+
</properties>
117+
</rule>
26118
</ruleset>

README.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
# Laravel Auth0 Plugin
22

3-
This plugin helps you integrate your [Laravel](https://laravel.com/) WebApp with [Auth0](https://auth0.com/) to achieve Single Sign On with a few simple steps.
4-
5-
- Master targets compatibility with Laravel 5.7 and above.
6-
- The 3.x branch (not maintained) targets Laravel 5.2 compatibility.
7-
- The 2.x branch (not maintained) targets Laravel 5.0 and 5.1 compatibility.
8-
- If you are working with an older version (Laravel 4.x), use version 1.0.* (not maintained)
9-
103
[![CircleCI](https://img.shields.io/circleci/project/github/auth0/laravel-auth0/master.svg)](https://circleci.com/gh/auth0/laravel-auth0)
114
[![Latest Stable Version](https://poser.pugx.org/auth0/login/v/stable)](https://packagist.org/packages/auth0/login)
125
[![License](https://poser.pugx.org/auth0/login/license)](https://packagist.org/packages/auth0/login)
136
[![Total Downloads](https://poser.pugx.org/auth0/login/downloads)](https://packagist.org/packages/auth0/login)
147
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fauth0%2Flaravel-auth0.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fauth0%2Flaravel-auth0?ref=badge_shield)
158

9+
This plugin helps you integrate your [Laravel](https://laravel.com/) WebApp with [Auth0](https://auth0.com/) to achieve Single Sign On with a few simple steps.
10+
11+
## Supported Framework Versions
12+
13+
Our plugin maintains support for [all actively supported versions](https://laravel.com/docs/8.x/releases#support-policy) of the Laravel framework, including [6.X (LTS)](https://laravel.com/docs/8.x/releases), [7.X](https://laravel.com/docs/7.x/releases) and [8.X](https://laravel.com/docs/8.x/releases).
14+
15+
Past releases of our plugin may potentially run on earlier, now unsupported versions of the Laravel framework, but these releases are not maintained. The final release of our plugin to support the Laravel 5.X series was 6.1.0.
16+
1617
## Documentation
1718

1819
Please see the [Laravel webapp quickstart](https://auth0.com/docs/quickstart/webapp/laravel) for a complete guide on how to install this in an existing project or to download a pre-configured sample project. Additional documentation on specific scenarios is below.
@@ -50,6 +51,7 @@ You can customize the way you handle the users in your application by creating y
5051
### Using auth guard
5152

5253
To protect APIs using an access token generated by Auth0, there is an `auth0` API guard provided ([Laravel documentation on guards](https://laravel.com/docs/7.x/authentication#adding-custom-guards)). To use this guard, add it to `config/auth.php` with the driver `auth0`:
54+
5355
```
5456
'guards' => [
5557
...
@@ -68,6 +70,7 @@ To protect APIs using an access token generated by Auth0, there is an `auth0` AP
6870
```
6971

7072
Once that has been added, add the guard to the middleware of any API route and check authentication during the request:
73+
7174
```
7275
// get user
7376
auth('auth0')->user();
@@ -118,5 +121,4 @@ Auth0 helps you to easily:
118121

119122
The Auth0 Laravel Login plugin is licensed under MIT - [LICENSE](LICENSE.txt)
120123

121-
122-
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fauth0%2Flaravel-auth0.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Fauth0%2Flaravel-auth0?ref=badge_large)
124+
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fauth0%2Flaravel-auth0.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Fauth0%2Flaravel-auth0?ref=badge_large)

composer.json

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,37 @@
11
{
22
"name": "auth0/login",
3-
"description": "Laravel plugin that helps authenticate with the auth0 service",
3+
"description": "Laravel plugin that helps authenticate with the Auth0 service",
44
"license": "MIT",
5-
"prefer-stable": true,
65
"require": {
7-
"php": "^7.1",
8-
"auth0/auth0-php": "^7.2.0",
9-
"illuminate/support": "5.* | ^6.0 | ^7.0 | ^8.0",
10-
"illuminate/contracts": "5.* | ^6.0 | ^7.0 | ^8.0"
6+
"php": "^7.3 | ^8.0",
7+
"ext-json": "*",
8+
"ext-openssl": "*",
9+
"auth0/auth0-php": "^7.6",
10+
"illuminate/support": " ^6.0 | ^7.0 | ^8.0",
11+
"illuminate/contracts": "^6.0 | ^7.0 | ^8.0"
1112
},
1213
"require-dev": {
13-
"phpunit/phpunit": "^7|^8|^9",
14+
"phpunit/phpunit": "^9.3",
1415
"squizlabs/php_codesniffer": "^3.2",
1516
"phpcompatibility/php-compatibility": "^8.1",
16-
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.0",
17-
"orchestra/testbench": "^3.8|^4.0|^5.0"
17+
"dealerdirect/phpcodesniffer-composer-installer": "^0.7",
18+
"orchestra/testbench": "^4.0 | ^5.0",
19+
"nunomaduro/larastan": "^0.6.11"
1820
},
1921
"scripts": {
20-
"test": "SHELL_INTERACTIVE=1 \"vendor/bin/phpunit\" --coverage-text ",
21-
"phpcs": "\"vendor/bin/phpcs\"",
22-
"sniffs": "\"vendor/bin/phpcs\" -e"
22+
"test": "SHELL_INTERACTIVE=1 \"./vendor/bin/phpunit\" --coverage-text ",
23+
"analyze": "@php ./vendor/bin/phpstan analyze",
24+
"compat": "@php ./vendor/bin/phpcs --standard=.phpcs-compat.xml.dist",
25+
"format": "@php ./vendor/bin/phpcbf",
26+
"lint": "@php ./vendor/bin/phpcs",
27+
"sniffs": "@php ./vendor/bin/phpcs -e",
28+
"config-phpcs": "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin::run",
29+
"pre-commit": [
30+
"@analyze",
31+
"@test",
32+
"@format",
33+
"@compat"
34+
]
2335
},
2436
"autoload": {
2537
"classmap": [

phpstan.neon

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
parameters:
2+
checkGenericClassInNonGenericObjectType: false
3+
level: 2
4+
ignoreErrors:
5+
- '#Call to an undefined static method Event::listen#'
6+
- '#Call to static method#'
7+
paths:
8+
- src

src/Auth0/Login/Auth0JWTUser.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@
88
*/
99
class Auth0JWTUser implements \Illuminate\Contracts\Auth\Authenticatable
1010
{
11+
1112
private $userInfo;
1213

1314
/**
1415
* Auth0JWTUser constructor.
1516
*
16-
* @param $userInfo
17+
* @param array $userInfo
1718
*/
1819
public function __construct(array $userInfo)
1920
{
@@ -75,7 +76,7 @@ public function getRememberTokenName()
7576
*/
7677
public function __get($name)
7778
{
78-
if (!array_key_exists($name, $this->userInfo)) {
79+
if (! array_key_exists($name, $this->userInfo)) {
7980
return;
8081
}
8182

0 commit comments

Comments
 (0)