Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 39 additions & 17 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,53 @@ commands:
- run: sudo composer self-update
- restore_cache:
keys:
- composer-v1-{{ checksum "composer.json" }}
- composer-v1-
- run: composer install -n --prefer-dist
- composer-v1-{{ .Environment.CIRCLE_JOB }}-{{ checksum "composer.json" }}
- composer-v1-{{ .Environment.CIRCLE_JOB }}
- run: composer update --prefer-dist --no-interaction
- persist_to_workspace:
root: .
paths:
- composer.*
- .snyk
- save_cache:
key: composer-v1-{{ checksum "composer.json" }}
key: composer-v1-{{ .Environment.CIRCLE_JOB }}-{{ checksum "composer.json" }}
paths:
- vendor
run-php-compatibility:
steps:
- run: composer compat
run-static-analysis:
steps:
- run: composer analyze
run-unit-tests:
steps:
- run: composer test
- store_artifacts:
path: build/coverage.xml

jobs:
php_7:
php_7_3:
docker:
- image: circleci/php:7.1
- image: circleci/php:7.3
steps:
- prepare
- run:
name: Check PHP Compatibility
command: composer phpcs
- run:
name: Run Tests
command: composer test
- run-php-compatibility
- run-static-analysis
- run-unit-tests
php_7_4:
docker:
- image: circleci/php:7.4
steps:
- prepare
- run-static-analysis
- run-unit-tests
php_8_0:
docker:
- image: circleci/php:8.0
steps:
- prepare
- run-static-analysis
- run-unit-tests
snyk:
docker:
- image: snyk/snyk-cli:composer
Expand All @@ -47,13 +69,13 @@ jobs:
fi
when: always

#Each workflow represents a Github check
workflows:
snyk:
build-and-test:
jobs:
- php_7
- php_7_3
- php_7_4
- php_8_0
- snyk:
# Must define SNYK_TOKEN env
context: snyk-env
requires:
- php_7
- php_7_3
16 changes: 16 additions & 0 deletions .phpcs-compat.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0"?>
<ruleset name="Auth0-PHP-PHPCompatibility" namespace="Auth0PHP\CS\Standard">
<description>PHPCompatibility check for Auth0 Laravel SDK</description>
<file>./src</file>
<arg name="extensions" value="php"/>
<arg value="sp"/>
<arg name="basepath" value="."/>
<arg name="colors"/>

<!--
PHPCompatibility sniffs to check for PHP cross-version incompatible code.
https://github.com/PHPCompatibility/PHPCompatibility
-->
<config name="testVersion" value="7.3-"/>
<rule ref="PHPCompatibility"/>
</ruleset>
94 changes: 93 additions & 1 deletion .phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,99 @@
PHPCompatibility sniffs to check for PHP cross-version incompatible code.
https://github.com/PHPCompatibility/PHPCompatibility
-->
<config name="testVersion" value="7.1-"/>
<config name="testVersion" value="7.3-"/>
<rule ref="PHPCompatibility"/>

<!--
Generic sniffs
https://github.com/squizlabs/PHP_CodeSniffer/tree/master/src/Standards/Generic/Sniffs
-->
<rule ref="Generic.Arrays">
<exclude name="Generic.Arrays.DisallowShortArraySyntax"/>
</rule>
<rule ref="Generic.Classes.DuplicateClassName"/>
<rule ref="Generic.CodeAnalysis"/>
<rule ref="Generic.Commenting"/>
<rule ref="Generic.ControlStructures">
<exclude name="Generic.ControlStructures.DisallowYodaConditions"/>
</rule>
<rule ref="Generic.Files">
<exclude name="Generic.Files.EndFileNoNewline"/>
<exclude name="Generic.Files.LowercasedFilename"/>
</rule>
<rule ref="Generic.Files.LineLength">
<properties>
<property name="lineLimit" value="120"/>
<property name="absoluteLineLimit" value="120"/>
</properties>
</rule>
<rule ref="Generic.Formatting">
<exclude name="Generic.Formatting.NoSpaceAfterCast"/>
</rule>
<rule ref="Generic.Functions">
<exclude name="Generic.Functions.OpeningFunctionBraceKernighanRitchie"/>
</rule>
<rule ref="Generic.Metrics"/>
<rule ref="Generic.NamingConventions">
<exclude name="Generic.NamingConventions.CamelCapsFunctionName.ScopeNotCamelCaps"/>
</rule>
<rule ref="Generic.PHP">
<exclude name="Generic.PHP.ClosingPHPTag"/>
<exclude name="Generic.PHP.UpperCaseConstant"/>
</rule>
<rule ref="Generic.Strings"/>
<rule ref="Generic.WhiteSpace">
<exclude name="Generic.WhiteSpace.DisallowSpaceIndent"/>
</rule>

<!--
Squiz Labs sniffs
https://github.com/squizlabs/PHP_CodeSniffer/wiki/Customisable-Sniff-Properties
-->
<rule ref="Squiz.Arrays.ArrayBracketSpacing"/>
<rule ref="Squiz.Classes"/>
<rule ref="Squiz.Commenting">
<exclude name="Squiz.Commenting.ClosingDeclarationComment"/>
<exclude name="Squiz.Commenting.ClassComment.TagNotAllowed"/>
<exclude name="Squiz.Commenting.FileComment"/>
<exclude name="Squiz.Commenting.LongConditionClosingComment"/>
<exclude name="Squiz.Commenting.FunctionComment.ScalarTypeHintMissing"/>
<exclude name="Squiz.Commenting.FunctionCommentThrowTag.WrongNumber"/>
</rule>
<rule ref="Squiz.Commenting.FunctionComment">
<exclude-pattern>tests/*\.php</exclude-pattern>
</rule>
<rule ref="Squiz.ControlStructures"/>
<rule ref="Squiz.Functions">
<exclude name="Squiz.Functions.MultiLineFunctionDeclaration.NewlineBeforeOpenBrace"/>
<exclude name="Squiz.ControlStructures.InlineIfDeclaration.NoBrackets"/>
</rule>
<rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing">
<properties>
<property name="equalsSpacing" value="1"/>
</properties>
</rule>
<rule ref="Squiz.Operators">
<exclude name="Squiz.Operators.ComparisonOperatorUsage.NotAllowed"/>
<exclude name="Squiz.Operators.ComparisonOperatorUsage.ImplicitTrue"/>
</rule>
<rule ref="Squiz.PHP">
<exclude name="Squiz.PHP.DisallowComparisonAssignment.AssignedComparison"/>
<exclude name="Squiz.PHP.DisallowInlineIf.Found"/>
<exclude name="Squiz.PHP.DisallowBooleanStatement.Found"/>
</rule>
<rule ref="Squiz.Scope"/>
<rule ref="Squiz.Strings"/>
<rule ref="Squiz.WhiteSpace">
<exclude name="Squiz.WhiteSpace.FunctionClosingBraceSpace"/>
<exclude name="Squiz.WhiteSpace.FunctionSpacing"/>
<exclude name="Squiz.WhiteSpace.ObjectOperatorSpacing"/>
</rule>
<rule ref="Squiz.WhiteSpace.FunctionSpacing">
<properties>
<property name="spacing" value="1"/>
<property name="spacingBeforeFirst" value="0"/>
<property name="spacingAfterLast" value="0"/>
</properties>
</rule>
</ruleset>
20 changes: 11 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
# Laravel Auth0 Plugin

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.

- Master targets compatibility with Laravel 5.7 and above.
- The 3.x branch (not maintained) targets Laravel 5.2 compatibility.
- The 2.x branch (not maintained) targets Laravel 5.0 and 5.1 compatibility.
- If you are working with an older version (Laravel 4.x), use version 1.0.* (not maintained)

[![CircleCI](https://img.shields.io/circleci/project/github/auth0/laravel-auth0/master.svg)](https://circleci.com/gh/auth0/laravel-auth0)
[![Latest Stable Version](https://poser.pugx.org/auth0/login/v/stable)](https://packagist.org/packages/auth0/login)
[![License](https://poser.pugx.org/auth0/login/license)](https://packagist.org/packages/auth0/login)
[![Total Downloads](https://poser.pugx.org/auth0/login/downloads)](https://packagist.org/packages/auth0/login)
[![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)

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.

## Supported Framework Versions

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).

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.

## Documentation

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.
Expand Down Expand Up @@ -50,6 +51,7 @@ You can customize the way you handle the users in your application by creating y
### Using auth guard

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`:

```
'guards' => [
...
Expand All @@ -68,6 +70,7 @@ To protect APIs using an access token generated by Auth0, there is an `auth0` AP
```

Once that has been added, add the guard to the middleware of any API route and check authentication during the request:

```
// get user
auth('auth0')->user();
Expand Down Expand Up @@ -118,5 +121,4 @@ Auth0 helps you to easily:

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


[![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)
[![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)
36 changes: 24 additions & 12 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,37 @@
{
"name": "auth0/login",
"description": "Laravel plugin that helps authenticate with the auth0 service",
"description": "Laravel plugin that helps authenticate with the Auth0 service",
"license": "MIT",
"prefer-stable": true,
"require": {
"php": "^7.1",
"auth0/auth0-php": "^7.2.0",
"illuminate/support": "5.* | ^6.0 | ^7.0 | ^8.0",
"illuminate/contracts": "5.* | ^6.0 | ^7.0 | ^8.0"
"php": "^7.3 | ^8.0",
"ext-json": "*",
"ext-openssl": "*",
"auth0/auth0-php": "^7.6",
"illuminate/support": " ^6.0 | ^7.0 | ^8.0",
"illuminate/contracts": "^6.0 | ^7.0 | ^8.0"
},
"require-dev": {
"phpunit/phpunit": "^7|^8|^9",
"phpunit/phpunit": "^9.3",
"squizlabs/php_codesniffer": "^3.2",
"phpcompatibility/php-compatibility": "^8.1",
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.0",
"orchestra/testbench": "^3.8|^4.0|^5.0"
"dealerdirect/phpcodesniffer-composer-installer": "^0.7",
"orchestra/testbench": "^4.0 | ^5.0",
"nunomaduro/larastan": "^0.6.11"
},
"scripts": {
"test": "SHELL_INTERACTIVE=1 \"vendor/bin/phpunit\" --coverage-text ",
"phpcs": "\"vendor/bin/phpcs\"",
"sniffs": "\"vendor/bin/phpcs\" -e"
"test": "SHELL_INTERACTIVE=1 \"./vendor/bin/phpunit\" --coverage-text ",
"analyze": "@php ./vendor/bin/phpstan analyze",
"compat": "@php ./vendor/bin/phpcs --standard=.phpcs-compat.xml.dist",
"format": "@php ./vendor/bin/phpcbf",
"lint": "@php ./vendor/bin/phpcs",
"sniffs": "@php ./vendor/bin/phpcs -e",
"config-phpcs": "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin::run",
"pre-commit": [
"@analyze",
"@test",
"@format",
"@compat"
]
},
"autoload": {
"classmap": [
Expand Down
8 changes: 8 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
parameters:
checkGenericClassInNonGenericObjectType: false
level: 2
ignoreErrors:
- '#Call to an undefined static method Event::listen#'
- '#Call to static method#'
paths:
- src
5 changes: 3 additions & 2 deletions src/Auth0/Login/Auth0JWTUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@
*/
class Auth0JWTUser implements \Illuminate\Contracts\Auth\Authenticatable
{

private $userInfo;

/**
* Auth0JWTUser constructor.
*
* @param $userInfo
* @param array $userInfo
*/
public function __construct(array $userInfo)
{
Expand Down Expand Up @@ -75,7 +76,7 @@ public function getRememberTokenName()
*/
public function __get($name)
{
if (!array_key_exists($name, $this->userInfo)) {
if (! array_key_exists($name, $this->userInfo)) {
return;
}

Expand Down
Loading