diff --git a/app/Extensions/Auth0/Laravel/UserRepository.php b/app/Extensions/Auth0/Laravel/UserRepository.php new file mode 100644 index 000000000..2f7635900 --- /dev/null +++ b/app/Extensions/Auth0/Laravel/UserRepository.php @@ -0,0 +1,40 @@ +where('email', $user['email'])->first(); + if (is_null($match)) { + $match = User::query()->forceCreate([ + 'uuid' => Uuid::uuid4()->toString(), + 'email' => $user['email'], + 'username' => 'auth0.' . $user['nickname'], + 'name_first' => 'Auth0', + 'name_last' => 'User', + 'password' => password_hash(Str::random(32), PASSWORD_DEFAULT), + ]); + } + + return $match; + } + + public function fromAccessToken(array $user): ?\Illuminate\Contracts\Auth\Authenticatable + { + dd('from token', $user); + } +} diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index cf7b4a8d3..badd59c96 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -2,9 +2,9 @@ namespace Pterodactyl\Http; -use Illuminate\Http\Middleware\TrustProxies; use Pterodactyl\Models\ApiKey; use Illuminate\Auth\Middleware\Authorize; +use Illuminate\Http\Middleware\TrustProxies; use Illuminate\Auth\Middleware\Authenticate; use Pterodactyl\Http\Middleware\TrimStrings; use Illuminate\Session\Middleware\StartSession; @@ -60,7 +60,7 @@ class Kernel extends HttpKernel 'web' => [ AddQueuedCookiesToResponse::class, StartSession::class, - AuthenticateSession::class, + // AuthenticateSession::class, ShareErrorsFromSession::class, VerifyCsrfToken::class, SubstituteBindings::class, @@ -82,7 +82,7 @@ class Kernel extends HttpKernel HandleStatelessRequest::class, IsValidJson::class, StartSession::class, - AuthenticateSession::class, + 'auth0.authenticate', SubstituteClientApiBindings::class, 'api..key:' . ApiKey::TYPE_ACCOUNT, AuthenticateIPAccess::class, diff --git a/app/Models/User.php b/app/Models/User.php index 6cdc414f2..50aafd30e 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -11,6 +11,7 @@ use Illuminate\Database\Eloquent\Builder; use Illuminate\Auth\Passwords\CanResetPassword; use Pterodactyl\Traits\Helpers\AvailableLanguages; use Illuminate\Foundation\Auth\Access\Authorizable; +use Auth0\Laravel\Contract\Model\Stateful\User as StatefulUser; use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract; use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract; use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract; @@ -42,7 +43,8 @@ use Pterodactyl\Notifications\SendPasswordReset as ResetPasswordNotification; class User extends Model implements AuthenticatableContract, AuthorizableContract, - CanResetPasswordContract + CanResetPasswordContract, + StatefulUser { use Authenticatable; use Authorizable; diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php index 2dedacb4a..1806368e3 100644 --- a/app/Providers/RouteServiceProvider.php +++ b/app/Providers/RouteServiceProvider.php @@ -27,19 +27,19 @@ class RouteServiceProvider extends ServiceProvider $this->configureRateLimiting(); $this->routes(function () { - Route::middleware(['web', 'auth', 'csrf']) + Route::middleware(['auth0.authenticate', 'web']) ->namespace("$this->namespace\\Base") ->group(base_path('routes/base.php')); - Route::middleware(['web', 'auth', 'admin', 'csrf'])->prefix('/admin') + Route::middleware(['auth0.authenticate', 'web', 'admin'])->prefix('/admin') ->namespace("$this->namespace\\Admin") ->group(base_path('routes/admin.php')); - Route::middleware(['web', 'csrf'])->prefix('/auth') + Route::middleware(['web'])->prefix('/auth') ->namespace("$this->namespace\\Auth") ->group(base_path('routes/auth.php')); - Route::middleware(['web', 'csrf', 'auth', 'server', 'node.maintenance']) + Route::middleware(['auth0.authenticate', 'web', 'csrf', 'server', 'node.maintenance']) ->prefix('/api/server/{server}') ->namespace("$this->namespace\\Server") ->group(base_path('routes/server.php')); diff --git a/composer.json b/composer.json index fa5db6eb0..b8c92e0c4 100644 --- a/composer.json +++ b/composer.json @@ -17,6 +17,7 @@ "ext-pdo": "*", "ext-pdo_mysql": "*", "ext-zip": "*", + "auth0/login": "^7.0", "aws/aws-sdk-php": "^3.171", "doctrine/dbal": "~2.13.9", "guzzlehttp/guzzle": "~7.4.2", diff --git a/composer.lock b/composer.lock index 8fecedfe9..60f1a1bb7 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,199 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "966e12710f76fb744c32e90103b9f823", + "content-hash": "60871d97425bf6a386bd84c246856f8c", "packages": [ + { + "name": "auth0/auth0-php", + "version": "8.2.0", + "source": { + "type": "git", + "url": "https://github.com/auth0/auth0-PHP.git", + "reference": "610873fcc14c03b92b1e71c167aeb2428919c904" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/auth0/auth0-PHP/zipball/610873fcc14c03b92b1e71c167aeb2428919c904", + "reference": "610873fcc14c03b92b1e71c167aeb2428919c904", + "shasum": "" + }, + "require": { + "ext-filter": "*", + "ext-json": "*", + "ext-mbstring": "*", + "ext-openssl": "*", + "php": "^7.4 || ^8.0, <8.2", + "php-http/discovery": "^1.0", + "php-http/httplug": "^2.2", + "php-http/multipart-stream-builder": "^1.1", + "psr/cache": "^1.0 || ^2.0 || ^3.0", + "psr/event-dispatcher": "^1.0", + "psr/http-client-implementation": "^1.0", + "psr/http-factory-implementation": "^1.0", + "psr/http-message-implementation": "^1.0" + }, + "require-dev": { + "ergebnis/phpstan-rules": "^0.15", + "firebase/php-jwt": "^6.0", + "hyperf/event": "^2.2", + "mockery/mockery": "^1.4", + "nunomaduro/phpinsights": "^2.0", + "nyholm/psr7": "^1.4", + "pestphp/pest": "^1.18", + "pestphp/pest-plugin-parallel": "^0.2 || ^1.0", + "php-http/mock-client": "^1.4", + "phpstan/phpstan": "^0.12", + "phpstan/phpstan-strict-rules": "^0.12", + "symfony/cache": "^4.4 || ^5.2", + "thecodingmachine/phpstan-strict-rules": "^0.12", + "vimeo/psalm": "^4.10" + }, + "type": "library", + "autoload": { + "psr-4": { + "Auth0\\SDK\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Auth0", + "email": "support@auth0.com", + "homepage": "https://auth0.com/" + } + ], + "description": "Auth0 PHP SDK. Straight-forward and tested methods for accessing Auth0 Authentication and Management API endpoints.", + "homepage": "https://github.com/auth0/auth0-PHP", + "keywords": [ + "Authentication", + "JSON Web Token", + "JWK", + "OpenId", + "api", + "auth", + "auth0", + "authorization", + "json web key", + "jwt", + "login", + "oauth", + "protect", + "secure" + ], + "support": { + "issues": "https://github.com/auth0/auth0-PHP/issues", + "source": "https://github.com/auth0/auth0-PHP/tree/8.2.0" + }, + "time": "2022-04-26T13:11:00+00:00" + }, + { + "name": "auth0/login", + "version": "7.0.0", + "source": { + "type": "git", + "url": "https://github.com/auth0/laravel-auth0.git", + "reference": "06238bdfa0bdf165b02cb8433a6d3c8e23cfc9ec" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/auth0/laravel-auth0/zipball/06238bdfa0bdf165b02cb8433a6d3c8e23cfc9ec", + "reference": "06238bdfa0bdf165b02cb8433a6d3c8e23cfc9ec", + "shasum": "" + }, + "require": { + "auth0/auth0-php": "^8.0", + "ext-filter": "*", + "ext-json": "*", + "ext-mbstring": "*", + "ext-openssl": "*", + "illuminate/contracts": "^8.0 || ^9.0", + "illuminate/http": "^8.0 || ^9.0", + "illuminate/support": " ^8.0 || ^9.0", + "php": "^7.4 || ^8.0", + "spatie/laravel-package-tools": "^1.9" + }, + "require-dev": { + "ergebnis/phpstan-rules": "^1.0", + "laravel/laravel": "^8.4.4 || ^9.0", + "nunomaduro/larastan": "^1.0", + "nunomaduro/phpinsights": "^2.0", + "nyholm/psr7": "^1.4", + "orchestra/testbench": "6.0", + "pestphp/pest": "^1.21", + "pestphp/pest-plugin-laravel": "^1.2", + "phpstan/phpstan-strict-rules": "^1.1", + "phpunit/phpunit": "^9.5", + "rector/rector": "^0.12.16", + "thecodingmachine/phpstan-strict-rules": "^1.0", + "wikimedia/composer-merge-plugin": "^2.0" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "Auth0\\Laravel\\ServiceProvider" + ], + "aliases": { + "Auth0": "Auth0\\Laravel\\Facade\\Auth0" + } + }, + "merge-plugin": { + "include": [ + "composer.local.json" + ], + "recurse": true, + "replace": true, + "ignore-duplicates": false, + "merge-dev": true, + "merge-extra": false, + "merge-extra-deep": false, + "merge-scripts": false + } + }, + "autoload": { + "psr-4": { + "Auth0\\Laravel\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Auth0", + "email": "support@auth0.com", + "homepage": "https://auth0.com/" + } + ], + "description": "Auth0 Laravel SDK. Straight-forward and tested methods for implementing authentication, and accessing Auth0's Management API endpoints.", + "homepage": "https://github.com/auth0/laravel-auth0", + "keywords": [ + "Authentication", + "JSON Web Token", + "JWK", + "OpenId", + "api", + "auth", + "auth0", + "authorization", + "json web key", + "jwt", + "laravel", + "login", + "oauth", + "protect", + "secure" + ], + "support": { + "issues": "https://github.com/auth0/laravel-auth0/issues", + "source": "https://github.com/auth0/laravel-auth0/tree/7.0.0" + }, + "time": "2022-03-21T23:00:50+00:00" + }, { "name": "aws/aws-crt-php", "version": "v1.0.2", @@ -3195,6 +3386,309 @@ }, "time": "2020-10-15T08:29:30+00:00" }, + { + "name": "php-http/discovery", + "version": "1.14.1", + "source": { + "type": "git", + "url": "https://github.com/php-http/discovery.git", + "reference": "de90ab2b41d7d61609f504e031339776bc8c7223" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/discovery/zipball/de90ab2b41d7d61609f504e031339776bc8c7223", + "reference": "de90ab2b41d7d61609f504e031339776bc8c7223", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0" + }, + "conflict": { + "nyholm/psr7": "<1.0" + }, + "require-dev": { + "graham-campbell/phpspec-skip-example-extension": "^5.0", + "php-http/httplug": "^1.0 || ^2.0", + "php-http/message-factory": "^1.0", + "phpspec/phpspec": "^5.1 || ^6.1", + "puli/composer-plugin": "1.0.0-beta10" + }, + "suggest": { + "php-http/message": "Allow to use Guzzle, Diactoros or Slim Framework factories" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.9-dev" + } + }, + "autoload": { + "psr-4": { + "Http\\Discovery\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com" + } + ], + "description": "Finds installed HTTPlug implementations and PSR-7 message factories", + "homepage": "http://php-http.org", + "keywords": [ + "adapter", + "client", + "discovery", + "factory", + "http", + "message", + "psr7" + ], + "support": { + "issues": "https://github.com/php-http/discovery/issues", + "source": "https://github.com/php-http/discovery/tree/1.14.1" + }, + "time": "2021-09-18T07:57:46+00:00" + }, + { + "name": "php-http/httplug", + "version": "2.3.0", + "source": { + "type": "git", + "url": "https://github.com/php-http/httplug.git", + "reference": "f640739f80dfa1152533976e3c112477f69274eb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/httplug/zipball/f640739f80dfa1152533976e3c112477f69274eb", + "reference": "f640739f80dfa1152533976e3c112477f69274eb", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0", + "php-http/promise": "^1.1", + "psr/http-client": "^1.0", + "psr/http-message": "^1.0" + }, + "require-dev": { + "friends-of-phpspec/phpspec-code-coverage": "^4.1", + "phpspec/phpspec": "^5.1 || ^6.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.x-dev" + } + }, + "autoload": { + "psr-4": { + "Http\\Client\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Eric GELOEN", + "email": "geloen.eric@gmail.com" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://sagikazarmark.hu" + } + ], + "description": "HTTPlug, the HTTP client abstraction for PHP", + "homepage": "http://httplug.io", + "keywords": [ + "client", + "http" + ], + "support": { + "issues": "https://github.com/php-http/httplug/issues", + "source": "https://github.com/php-http/httplug/tree/2.3.0" + }, + "time": "2022-02-21T09:52:22+00:00" + }, + { + "name": "php-http/message-factory", + "version": "v1.0.2", + "source": { + "type": "git", + "url": "https://github.com/php-http/message-factory.git", + "reference": "a478cb11f66a6ac48d8954216cfed9aa06a501a1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/message-factory/zipball/a478cb11f66a6ac48d8954216cfed9aa06a501a1", + "reference": "a478cb11f66a6ac48d8954216cfed9aa06a501a1", + "shasum": "" + }, + "require": { + "php": ">=5.4", + "psr/http-message": "^1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "psr-4": { + "Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com" + } + ], + "description": "Factory interfaces for PSR-7 HTTP Message", + "homepage": "http://php-http.org", + "keywords": [ + "factory", + "http", + "message", + "stream", + "uri" + ], + "support": { + "issues": "https://github.com/php-http/message-factory/issues", + "source": "https://github.com/php-http/message-factory/tree/master" + }, + "time": "2015-12-19T14:08:53+00:00" + }, + { + "name": "php-http/multipart-stream-builder", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/php-http/multipart-stream-builder.git", + "reference": "11c1d31f72e01c738bbce9e27649a7cca829c30e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/multipart-stream-builder/zipball/11c1d31f72e01c738bbce9e27649a7cca829c30e", + "reference": "11c1d31f72e01c738bbce9e27649a7cca829c30e", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0", + "php-http/discovery": "^1.7", + "php-http/message-factory": "^1.0.2", + "psr/http-factory": "^1.0", + "psr/http-message": "^1.0" + }, + "require-dev": { + "nyholm/psr7": "^1.0", + "php-http/message": "^1.5", + "phpunit/phpunit": "^7.5.15 || ^8.5 || ^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Http\\Message\\MultipartStream\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com" + } + ], + "description": "A builder class that help you create a multipart stream", + "homepage": "http://php-http.org", + "keywords": [ + "factory", + "http", + "message", + "multipart stream", + "stream" + ], + "support": { + "issues": "https://github.com/php-http/multipart-stream-builder/issues", + "source": "https://github.com/php-http/multipart-stream-builder/tree/1.2.0" + }, + "time": "2021-05-21T08:32:01+00:00" + }, + { + "name": "php-http/promise", + "version": "1.1.0", + "source": { + "type": "git", + "url": "https://github.com/php-http/promise.git", + "reference": "4c4c1f9b7289a2ec57cde7f1e9762a5789506f88" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/promise/zipball/4c4c1f9b7289a2ec57cde7f1e9762a5789506f88", + "reference": "4c4c1f9b7289a2ec57cde7f1e9762a5789506f88", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0" + }, + "require-dev": { + "friends-of-phpspec/phpspec-code-coverage": "^4.3.2", + "phpspec/phpspec": "^5.1.2 || ^6.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1-dev" + } + }, + "autoload": { + "psr-4": { + "Http\\Promise\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Joel Wurtz", + "email": "joel.wurtz@gmail.com" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com" + } + ], + "description": "Promise used for asynchronous HTTP requests", + "homepage": "http://httplug.io", + "keywords": [ + "promise" + ], + "support": { + "issues": "https://github.com/php-http/promise/issues", + "source": "https://github.com/php-http/promise/tree/1.1.0" + }, + "time": "2020-07-07T09:29:14+00:00" + }, { "name": "phpoption/phpoption", "version": "1.8.1", @@ -4363,6 +4857,65 @@ ], "time": "2020-11-12T18:46:53+00:00" }, + { + "name": "spatie/laravel-package-tools", + "version": "1.11.3", + "source": { + "type": "git", + "url": "https://github.com/spatie/laravel-package-tools.git", + "reference": "baeb3df0ebb3a541394fdaf8cbe6115bf4034a59" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/spatie/laravel-package-tools/zipball/baeb3df0ebb3a541394fdaf8cbe6115bf4034a59", + "reference": "baeb3df0ebb3a541394fdaf8cbe6115bf4034a59", + "shasum": "" + }, + "require": { + "illuminate/contracts": "^7.0|^8.0|^9.0", + "php": "^7.4|^8.0" + }, + "require-dev": { + "mockery/mockery": "^1.4", + "orchestra/testbench": "^5.0|^6.23|^7.0", + "phpunit/phpunit": "^9.4", + "spatie/test-time": "^1.2" + }, + "type": "library", + "autoload": { + "psr-4": { + "Spatie\\LaravelPackageTools\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Freek Van der Herten", + "email": "freek@spatie.be", + "role": "Developer" + } + ], + "description": "Tools for creating Laravel packages", + "homepage": "https://github.com/spatie/laravel-package-tools", + "keywords": [ + "laravel-package-tools", + "spatie" + ], + "support": { + "issues": "https://github.com/spatie/laravel-package-tools/issues", + "source": "https://github.com/spatie/laravel-package-tools/tree/1.11.3" + }, + "funding": [ + { + "url": "https://github.com/spatie", + "type": "github" + } + ], + "time": "2022-03-15T20:01:36+00:00" + }, { "name": "spatie/laravel-query-builder", "version": "3.6.2", diff --git a/config/auth.php b/config/auth.php index 02f4807e4..eca82ce6c 100644 --- a/config/auth.php +++ b/config/auth.php @@ -28,7 +28,7 @@ return [ */ 'defaults' => [ - 'guard' => 'web', + 'guard' => env('APP_AUTH_GUARD', 'web'), 'passwords' => 'users', ], @@ -59,6 +59,11 @@ return [ 'driver' => 'token', 'provider' => 'users', ], + + 'auth0' => [ + 'driver' => 'auth0', + 'provider' => 'auth0', + ], ], /* @@ -83,6 +88,12 @@ return [ 'driver' => 'eloquent', 'model' => Pterodactyl\Models\User::class, ], + + 'auth0' => [ + 'driver' => 'auth0', + // 'repository' => Auth0\Laravel\Auth\User\Repository::class, + 'repository' => Pterodactyl\Extensions\Auth0\Laravel\UserRepository::class, + ], ], /* diff --git a/config/auth0.php b/config/auth0.php new file mode 100644 index 000000000..69ed87aed --- /dev/null +++ b/config/auth0.php @@ -0,0 +1,59 @@ + env('AUTH0_STRATEGY', 'webapp'), + + // Auth0 domain for your tenant, found in your Auth0 Application settings. + 'domain' => env('AUTH0_DOMAIN'), + + // If you have configured Auth0 to use a custom domain, configure it here. + 'customDomain' => env('AUTH0_CUSTOM_DOMAIN'), + + // Client ID, found in the Auth0 Application settings. + 'clientId' => env('AUTH0_CLIENT_ID'), + + // Authentication callback URI, as defined in your Auth0 Application settings. + 'redirectUri' => env('AUTH0_REDIRECT_URI', env('APP_URL') . '/callback'), + + // Client Secret, found in the Auth0 Application settings. + 'clientSecret' => env('AUTH0_CLIENT_SECRET'), + + // One or more API identifiers, found in your Auth0 API settings. The SDK uses the first value for building links. If provided, at least one of these values must match the 'aud' claim to validate an ID Token successfully. + 'audience' => \Auth0\Laravel\Configuration::stringToArrayOrNull(env('AUTH0_AUDIENCE')), + + // One or more scopes to request for Tokens. See https://auth0.com/docs/scopes + 'scope' => \Auth0\Laravel\Configuration::stringToArrayOrNull(env('AUTH0_SCOPE')), + + // One or more Organization IDs, found in your Auth0 Organization settings. The SDK uses the first value for building links. If provided, at least one of these values must match the 'org_id' claim to validate an ID Token successfully. + 'organization' => \Auth0\Laravel\Configuration::stringToArrayOrNull(env('AUTH0_ORGANIZATION')), + + // The secret used to derive an encryption key for the user identity in a session cookie and to sign the transient cookies used by the login callback. + 'cookieSecret' => env('AUTH0_COOKIE_SECRET', env('APP_KEY')), + + // How long, in seconds, before cookies expire. If set to 0 the cookie will expire at the end of the session (when the browser closes). + 'cookieExpires' => env('COOKIE_EXPIRES', 0), + + // Cookie domain, for example 'www.example.com', for use with PHP sessions and SDK cookies. Defaults to value of HTTP_HOST server environment information. + // Note: To make cookies visible on all subdomains then the domain must be prefixed with a dot like '.example.com'. + 'cookieDomain' => env('AUTH0_COOKIE_DOMAIN'), + + // Specifies path on the domain where the cookies will work. Defaults to '/'. Use a single slash ('/') for all paths on the domain. + 'cookiePath' => env('AUTH0_COOKIE_PATH'), + + // Defaults to false. Specifies whether cookies should ONLY be sent over secure connections. + 'cookieSecure' => \Auth0\Laravel\Configuration::stringToBoolOrNull(env('AUTH0_COOKIE_SECURE'), false), + + // Named routes within your Laravel application that the SDK may call during stateful requests for redirections. + 'routes' => [ + 'home' => env('AUTH0_ROUTE_HOME', '/'), + 'login' => env('AUTH0_ROUTE_LOGIN', '/auth/providers/auth0/login') + ] +]; diff --git a/resources/scripts/components/NavigationBar.tsx b/resources/scripts/components/NavigationBar.tsx index 9500d215d..282e53517 100644 --- a/resources/scripts/components/NavigationBar.tsx +++ b/resources/scripts/components/NavigationBar.tsx @@ -1,4 +1,5 @@ import * as React from 'react'; +import { useState } from 'react'; import { Link, NavLink } from 'react-router-dom'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { faCogs, faLayerGroup, faSignOutAlt, faUserCircle } from '@fortawesome/free-solid-svg-icons'; @@ -7,20 +8,18 @@ import { ApplicationStore } from '@/state'; import SearchContainer from '@/components/dashboard/search/SearchContainer'; import tw, { theme } from 'twin.macro'; import styled from 'styled-components/macro'; -import http from '@/api/http'; import SpinnerOverlay from '@/components/elements/SpinnerOverlay'; -import { useState } from 'react'; const Navigation = styled.div` ${tw`w-full bg-neutral-900 shadow-md overflow-x-auto`}; - + & > div { ${tw`mx-auto w-full flex items-center`}; } - + & #logo { ${tw`flex-1`}; - + & > a { ${tw`text-2xl font-header px-4 no-underline text-neutral-200 hover:text-neutral-100 transition-colors duration-150`}; } @@ -29,14 +28,14 @@ const Navigation = styled.div` const RightNavigation = styled.div` ${tw`flex h-full items-center justify-center`}; - + & > a, & > button, & > .navigation-link { ${tw`flex items-center h-full no-underline text-neutral-300 px-6 cursor-pointer transition-all duration-150`}; - + &:active, &:hover { ${tw`text-neutral-100 bg-black`}; } - + &:active, &:hover, &.active { box-shadow: inset 0 -2px ${theme`colors.cyan.700`.toString()}; } @@ -50,10 +49,13 @@ export default () => { const onTriggerLogout = () => { setIsLoggingOut(true); - http.post('/auth/logout').finally(() => { - // @ts-ignore - window.location = '/'; - }); + + // @ts-ignore + window.location = '/auth/providers/auth0/logout'; + // http.get('/auth/providers/auth0/logout').finally(() => { + // // @ts-ignore + // window.location = '/'; + // }); }; return ( diff --git a/routes/auth.php b/routes/auth.php index 0acd9fded..1e1eebced 100644 --- a/routes/auth.php +++ b/routes/auth.php @@ -36,6 +36,12 @@ Route::group(['middleware' => 'guest'], function () { // is created). Route::post('/password/reset', 'ResetPasswordController')->name('auth.reset-password'); + Route::namespace("\\Auth0\\Laravel\\Http\\Controller\\Stateful")->prefix('/providers/auth0')->group(function () { + Route::get('/login', 'Login')->name('auth.providers.auth0-login'); + Route::get('/logout', 'Logout')->name('auth.providers.auth0-logout'); + Route::get('/callback', 'Callback')->name('auth.providers.auth0-callback'); + }); + // Catch any other combinations of routes and pass them off to the Vuejs component. Route::fallback('LoginController@index'); }); @@ -48,4 +54,7 @@ Route::group(['middleware' => 'guest'], function () { | Endpoint: /auth | */ -Route::post('/logout', 'LoginController@logout')->name('auth.logout')->middleware('auth', 'csrf'); +Route::namespace("\\Auth0\\Laravel\\Http\\Controller\\Stateful")->group(function () { + Route::get('/logout', 'Logout'); +}); +//Route::post('/logout', 'LoginController@logout')->name('auth.logout')->middleware('auth', 'csrf');