Added Load/Save API for page bodies

This commit is contained in:
Torsten 2020-01-28 10:15:49 +01:00
parent 98fc0ef0f8
commit 29058b37d0
16 changed files with 910 additions and 35 deletions

View file

@ -25,10 +25,12 @@
<excludeFolder url="file://$MODULE_DIR$/vendor/laravel/framework" />
<excludeFolder url="file://$MODULE_DIR$/vendor/laravel/tinker" />
<excludeFolder url="file://$MODULE_DIR$/vendor/laravel/ui" />
<excludeFolder url="file://$MODULE_DIR$/vendor/lcobucci/jwt" />
<excludeFolder url="file://$MODULE_DIR$/vendor/league/flysystem" />
<excludeFolder url="file://$MODULE_DIR$/vendor/mockery/mockery" />
<excludeFolder url="file://$MODULE_DIR$/vendor/monolog/monolog" />
<excludeFolder url="file://$MODULE_DIR$/vendor/myclabs/deep-copy" />
<excludeFolder url="file://$MODULE_DIR$/vendor/namshi/jose" />
<excludeFolder url="file://$MODULE_DIR$/vendor/nesbot/carbon" />
<excludeFolder url="file://$MODULE_DIR$/vendor/nikic/php-parser" />
<excludeFolder url="file://$MODULE_DIR$/vendor/nunomaduro/collision" />
@ -79,8 +81,10 @@
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-iconv" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-intl-idn" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-mbstring" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-php56" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-php72" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-php73" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-util" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/process" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/routing" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/service-contracts" />
@ -89,6 +93,7 @@
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/var-dumper" />
<excludeFolder url="file://$MODULE_DIR$/vendor/theseer/tokenizer" />
<excludeFolder url="file://$MODULE_DIR$/vendor/tijsverkoyen/css-to-inline-styles" />
<excludeFolder url="file://$MODULE_DIR$/vendor/tymon/jwt-auth" />
<excludeFolder url="file://$MODULE_DIR$/vendor/vlucas/phpdotenv" />
<excludeFolder url="file://$MODULE_DIR$/vendor/webmozart/assert" />
</content>

View file

@ -88,12 +88,17 @@
<path value="$PROJECT_DIR$/vendor/sebastian/version" />
<path value="$PROJECT_DIR$/vendor/symfony/event-dispatcher-contracts" />
<path value="$PROJECT_DIR$/vendor/doctrine/inflector" />
<path value="$PROJECT_DIR$/vendor/lcobucci/jwt" />
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-php56" />
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-util" />
<path value="$PROJECT_DIR$/vendor/tymon/jwt-auth" />
<path value="$PROJECT_DIR$/vendor/namshi/jose" />
</include_path>
</component>
<component name="PhpProjectSharedConfiguration" php_language_level="7.2" />
<component name="PhpUnit">
<phpunit_settings>
<PhpUnitSettings load_method="CUSTOM_LOADER" configuration_file_path="$PROJECT_DIR$/phpunit.xml" custom_loader_path="$PROJECT_DIR$/vendor/autoload.php" use_configuration_file="true" />
<PhpUnitSettings configuration_file_path="$PROJECT_DIR$/phpunit.xml" custom_loader_path="$PROJECT_DIR$/vendor/autoload.php" use_configuration_file="true" />
</phpunit_settings>
</component>
</project>

View file

@ -2,15 +2,22 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="eed7de89-f054-487c-bf59-36356758942b" name="Default Changelist" comment="">
<change afterPath="$PROJECT_DIR$/public/js/Icon.js" afterDir="false" />
<change afterPath="$PROJECT_DIR$/resources/js/views/EditPage.vue" afterDir="false" />
<change afterPath="$PROJECT_DIR$/app/Http/Controllers/PageController.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/app/Pagecontents.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/config/jwt.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/database/migrations/2020_01_28_072844_create_pagecontents_table.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/motorradig.iml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/motorradig.iml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/php.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/php.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/package-lock.json" beforeDir="false" afterPath="$PROJECT_DIR$/package-lock.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/package.json" beforeDir="false" afterPath="$PROJECT_DIR$/package.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/Http/Middleware/Authenticate.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/Http/Middleware/Authenticate.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/User.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/User.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/composer.json" beforeDir="false" afterPath="$PROJECT_DIR$/composer.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/composer.lock" beforeDir="false" afterPath="$PROJECT_DIR$/composer.lock" afterDir="false" />
<change beforePath="$PROJECT_DIR$/config/auth.php" beforeDir="false" afterPath="$PROJECT_DIR$/config/auth.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/public/js/app.js" beforeDir="false" afterPath="$PROJECT_DIR$/public/js/app.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/resources/js/app.js" beforeDir="false" afterPath="$PROJECT_DIR$/resources/js/app.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/resources/js/routes.js" beforeDir="false" afterPath="$PROJECT_DIR$/resources/js/routes.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/resources/js/views/Main.vue" beforeDir="false" afterPath="$PROJECT_DIR$/resources/js/views/Main.vue" afterDir="false" />
<change beforePath="$PROJECT_DIR$/resources/js/views/auth/Login.vue" beforeDir="false" afterPath="$PROJECT_DIR$/resources/js/views/auth/Login.vue" afterDir="false" />
<change beforePath="$PROJECT_DIR$/routes/api.php" beforeDir="false" afterPath="$PROJECT_DIR$/routes/api.php" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -124,6 +131,11 @@
<path value="$PROJECT_DIR$/vendor/sebastian/version" />
<path value="$PROJECT_DIR$/vendor/symfony/event-dispatcher-contracts" />
<path value="$PROJECT_DIR$/vendor/doctrine/inflector" />
<path value="$PROJECT_DIR$/vendor/lcobucci/jwt" />
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-php56" />
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-util" />
<path value="$PROJECT_DIR$/vendor/tymon/jwt-auth" />
<path value="$PROJECT_DIR$/vendor/namshi/jose" />
</include_path>
</component>
<component name="ProjectId" id="1SsafifEzlSTXL72mt36RI9ZBHK" />
@ -220,7 +232,8 @@
<workItem from="1575965115540" duration="593000" />
<workItem from="1575966299565" duration="383000" />
<workItem from="1579075615585" duration="8354000" />
<workItem from="1579595422946" duration="14949000" />
<workItem from="1579595422946" duration="16270000" />
<workItem from="1579800919877" duration="4693000" />
</task>
<servers />
</component>
@ -252,9 +265,9 @@
<screen x="1280" y="23" width="1920" height="1057" />
</state>
<state x="1903" y="197" width="673" height="708" key="find.popup/0.23.1280.777/1280.23.1920.1057@1280.23.1920.1057" timestamp="1579597123793" />
<state x="1905" y="258" width="670" height="676" key="search.everywhere.popup" timestamp="1579787265055">
<state x="1905" y="258" width="670" height="676" key="search.everywhere.popup" timestamp="1580196905378">
<screen x="1280" y="23" width="1920" height="1057" />
</state>
<state x="1905" y="258" width="670" height="676" key="search.everywhere.popup/0.23.1280.777/1280.23.1920.1057@1280.23.1920.1057" timestamp="1579787265055" />
<state x="1905" y="258" width="670" height="676" key="search.everywhere.popup/0.23.1280.777/1280.23.1920.1057@1280.23.1920.1057" timestamp="1580196905378" />
</component>
</project>

View file

@ -0,0 +1,53 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Validator;
use App\Pagecontents;
use Log;
class PageController extends Controller
{
public function load_page(Request $request) {
$v = Validator::make($request->all(), [
'page' => 'required',
]);
if ($v->fails()) {
return response()->json([
'status' => 'error',
'errors' => $v->errors()
], 422);
}
$p = Pagecontents::where('page',$request->page)->first();
//Log::info("Returning Body");
//Log::info($p->body);
return response()->json(['body' => $p->body], 200);
}
public function save_page(Request $request) {
$v = Validator::make($request->all(), [
'page' => 'required',
'body' => 'required'
]);
if ($v->fails()) {
return response()->json([
'status' => 'error',
'errors' => $v->errors()
], 422);
}
$p = Pagecontents::where('page',$request->page)->first();
if ($p==null) {
$p = new Pagecontents();
}
$p->page = $request->page;
$p->body = $request->body;
$p->save();
}
}

View file

@ -3,6 +3,7 @@
namespace App\Http\Middleware;
use Illuminate\Auth\Middleware\Authenticate as Middleware;
use Closure;
class Authenticate extends Middleware
{
@ -18,4 +19,27 @@ class Authenticate extends Middleware
return route('login');
}
}
// Override handle method
public function handle($request, Closure $next, ...$guards)
{
if ($this->authenticate($request, $guards) === 'authentication_failed') {
return response()->json(['error'=>'Unauthorized'],400);
}
return $next($request);
}
// Override authentication method
protected function authenticate($request, array $guards)
{
if (empty($guards)) {
$guards = [null];
}
foreach ($guards as $guard) {
if ($this->auth->guard($guard)->check()) {
return $this->auth->shouldUse($guard);
}
}
return 'authentication_failed';
}
}

View file

@ -0,0 +1,10 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Pagecontents extends Model
{
//
}

View file

@ -5,8 +5,9 @@ namespace App;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Tymon\JWTAuth\Contracts\JWTSubject;
class User extends Authenticatable
class User extends Authenticatable implements JWTSubject
{
use Notifiable;
@ -36,4 +37,12 @@ class User extends Authenticatable
protected $casts = [
'email_verified_at' => 'datetime',
];
public function getJWTIdentifier() {
return $this->getKey();
}
public function getJWTCustomClaims() {
return [];
}
}

View file

@ -12,7 +12,8 @@
"fideloper/proxy": "^4.0",
"laravel/framework": "^6.2",
"laravel/tinker": "^1.0",
"laravel/ui": "^1.1"
"laravel/ui": "^1.1",
"tymon/jwt-auth": "dev-develop"
},
"require-dev": {
"facade/ignition": "^1.4",

307
motorradig/composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "1b9e73ad57a9bbfb35d3c7cc0d815d97",
"content-hash": "982e21cc64e27987a84fe2d0caa51fa9",
"packages": [
{
"name": "dnoegel/php-xdg-base-dir",
@ -734,6 +734,61 @@
],
"time": "2019-10-11T12:16:52+00:00"
},
{
"name": "lcobucci/jwt",
"version": "3.3.1",
"source": {
"type": "git",
"url": "https://github.com/lcobucci/jwt.git",
"reference": "a11ec5f4b4d75d1fcd04e133dede4c317aac9e18"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/lcobucci/jwt/zipball/a11ec5f4b4d75d1fcd04e133dede4c317aac9e18",
"reference": "a11ec5f4b4d75d1fcd04e133dede4c317aac9e18",
"shasum": ""
},
"require": {
"ext-mbstring": "*",
"ext-openssl": "*",
"php": "^5.6 || ^7.0"
},
"require-dev": {
"mikey179/vfsstream": "~1.5",
"phpmd/phpmd": "~2.2",
"phpunit/php-invoker": "~1.1",
"phpunit/phpunit": "^5.7 || ^7.3",
"squizlabs/php_codesniffer": "~2.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.1-dev"
}
},
"autoload": {
"psr-4": {
"Lcobucci\\JWT\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Luís Otávio Cobucci Oblonczyk",
"email": "lcobucci@gmail.com",
"role": "Developer"
}
],
"description": "A simple library to work with JSON Web Token and JSON Web Signature",
"keywords": [
"JWS",
"jwt"
],
"time": "2019-05-24T18:30:49+00:00"
},
{
"name": "league/flysystem",
"version": "1.0.57",
@ -899,6 +954,69 @@
],
"time": "2019-08-30T09:56:44+00:00"
},
{
"name": "namshi/jose",
"version": "7.2.3",
"source": {
"type": "git",
"url": "https://github.com/namshi/jose.git",
"reference": "89a24d7eb3040e285dd5925fcad992378b82bcff"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/namshi/jose/zipball/89a24d7eb3040e285dd5925fcad992378b82bcff",
"reference": "89a24d7eb3040e285dd5925fcad992378b82bcff",
"shasum": ""
},
"require": {
"ext-date": "*",
"ext-hash": "*",
"ext-json": "*",
"ext-pcre": "*",
"ext-spl": "*",
"php": ">=5.5",
"symfony/polyfill-php56": "^1.0"
},
"require-dev": {
"phpseclib/phpseclib": "^2.0",
"phpunit/phpunit": "^4.5|^5.0",
"satooshi/php-coveralls": "^1.0"
},
"suggest": {
"ext-openssl": "Allows to use OpenSSL as crypto engine.",
"phpseclib/phpseclib": "Allows to use Phpseclib as crypto engine, use version ^2.0."
},
"type": "library",
"autoload": {
"psr-4": {
"Namshi\\JOSE\\": "src/Namshi/JOSE/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Alessandro Nadalin",
"email": "alessandro.nadalin@gmail.com"
},
{
"name": "Alessandro Cinelli (cirpo)",
"email": "alessandro.cinelli@gmail.com"
}
],
"description": "JSON Object Signing and Encryption library for PHP.",
"keywords": [
"JSON Web Signature",
"JSON Web Token",
"JWS",
"json",
"jwt",
"token"
],
"time": "2016-12-05T07:27:31+00:00"
},
{
"name": "nesbot/carbon",
"version": "2.25.3",
@ -2341,6 +2459,62 @@
],
"time": "2019-08-06T08:03:45+00:00"
},
{
"name": "symfony/polyfill-php56",
"version": "v1.13.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-php56.git",
"reference": "53dd1cdf3cb986893ccf2b96665b25b3abb384f4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-php56/zipball/53dd1cdf3cb986893ccf2b96665b25b3abb384f4",
"reference": "53dd1cdf3cb986893ccf2b96665b25b3abb384f4",
"shasum": ""
},
"require": {
"php": ">=5.3.3",
"symfony/polyfill-util": "~1.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.13-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Polyfill\\Php56\\": ""
},
"files": [
"bootstrap.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony polyfill backporting some PHP 5.6+ features to lower PHP versions",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"polyfill",
"portable",
"shim"
],
"time": "2019-11-27T13:56:44+00:00"
},
{
"name": "symfony/polyfill-php72",
"version": "v1.12.0",
@ -2454,6 +2628,58 @@
],
"time": "2019-08-06T08:03:45+00:00"
},
{
"name": "symfony/polyfill-util",
"version": "v1.13.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-util.git",
"reference": "964a67f293b66b95883a5ed918a65354fcd2258f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-util/zipball/964a67f293b66b95883a5ed918a65354fcd2258f",
"reference": "964a67f293b66b95883a5ed918a65354fcd2258f",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.13-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Polyfill\\Util\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony utilities for portability of PHP codes",
"homepage": "https://symfony.com",
"keywords": [
"compat",
"compatibility",
"polyfill",
"shim"
],
"time": "2019-11-27T13:56:44+00:00"
},
{
"name": "symfony/process",
"version": "v4.3.5",
@ -2895,6 +3121,81 @@
"homepage": "https://github.com/tijsverkoyen/CssToInlineStyles",
"time": "2019-10-24T08:53:34+00:00"
},
{
"name": "tymon/jwt-auth",
"version": "dev-develop",
"source": {
"type": "git",
"url": "https://github.com/tymondesigns/jwt-auth.git",
"reference": "f57a0ff33f20d2a0c3ebc9e13ce8382a83f921a8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/tymondesigns/jwt-auth/zipball/f57a0ff33f20d2a0c3ebc9e13ce8382a83f921a8",
"reference": "f57a0ff33f20d2a0c3ebc9e13ce8382a83f921a8",
"shasum": ""
},
"require": {
"illuminate/auth": "^5.1|^6",
"illuminate/contracts": "^5.1|^6",
"illuminate/http": "^5.1|^6",
"illuminate/support": "^5.1|^6",
"lcobucci/jwt": "^3.2",
"namshi/jose": "^7.0",
"nesbot/carbon": "^1.0|^2.0",
"php": "^5.5.9|^7.0"
},
"require-dev": {
"cartalyst/sentinel": "^2|^3",
"illuminate/console": "^5.1|^6",
"illuminate/database": "^5.1|^6",
"illuminate/routing": "^5.1|^6",
"mockery/mockery": ">=0.9.9",
"phpunit/phpunit": "~4.8|~6.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-develop": "1.0-dev"
},
"laravel": {
"aliases": {
"JWTAuth": "Tymon\\JWTAuth\\Facades\\JWTAuth",
"JWTFactory": "Tymon\\JWTAuth\\Facades\\JWTFactory"
},
"providers": [
"Tymon\\JWTAuth\\Providers\\LaravelServiceProvider"
]
}
},
"autoload": {
"psr-4": {
"Tymon\\JWTAuth\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Sean Tymon",
"email": "tymon148@gmail.com",
"homepage": "https://tymon.xyz",
"role": "Developer"
}
],
"description": "JSON Web Token Authentication for Laravel and Lumen",
"homepage": "https://github.com/tymondesigns/jwt-auth",
"keywords": [
"Authentication",
"JSON Web Token",
"auth",
"jwt",
"laravel"
],
"time": "2020-01-21T13:04:35+00:00"
},
{
"name": "vlucas/phpdotenv",
"version": "v3.6.0",
@ -4940,7 +5241,9 @@
],
"aliases": [],
"minimum-stability": "dev",
"stability-flags": [],
"stability-flags": {
"tymon/jwt-auth": 20
},
"prefer-stable": true,
"prefer-lowest": false,
"platform": {

View file

@ -14,7 +14,7 @@ return [
*/
'defaults' => [
'guard' => 'web',
'guard' => 'api',
'passwords' => 'users',
],
@ -42,9 +42,8 @@ return [
],
'api' => [
'driver' => 'token',
'driver' => 'jwt',
'provider' => 'users',
'hash' => false,
],
],

304
motorradig/config/jwt.php Normal file
View file

@ -0,0 +1,304 @@
<?php
/*
* This file is part of jwt-auth.
*
* (c) Sean Tymon <tymon148@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return [
/*
|--------------------------------------------------------------------------
| JWT Authentication Secret
|--------------------------------------------------------------------------
|
| Don't forget to set this in your .env file, as it will be used to sign
| your tokens. A helper command is provided for this:
| `php artisan jwt:secret`
|
| Note: This will be used for Symmetric algorithms only (HMAC),
| since RSA and ECDSA use a private/public key combo (See below).
|
*/
'secret' => env('JWT_SECRET'),
/*
|--------------------------------------------------------------------------
| JWT Authentication Keys
|--------------------------------------------------------------------------
|
| The algorithm you are using, will determine whether your tokens are
| signed with a random string (defined in `JWT_SECRET`) or using the
| following public & private keys.
|
| Symmetric Algorithms:
| HS256, HS384 & HS512 will use `JWT_SECRET`.
|
| Asymmetric Algorithms:
| RS256, RS384 & RS512 / ES256, ES384 & ES512 will use the keys below.
|
*/
'keys' => [
/*
|--------------------------------------------------------------------------
| Public Key
|--------------------------------------------------------------------------
|
| A path or resource to your public key.
|
| E.g. 'file://path/to/public/key'
|
*/
'public' => env('JWT_PUBLIC_KEY'),
/*
|--------------------------------------------------------------------------
| Private Key
|--------------------------------------------------------------------------
|
| A path or resource to your private key.
|
| E.g. 'file://path/to/private/key'
|
*/
'private' => env('JWT_PRIVATE_KEY'),
/*
|--------------------------------------------------------------------------
| Passphrase
|--------------------------------------------------------------------------
|
| The passphrase for your private key. Can be null if none set.
|
*/
'passphrase' => env('JWT_PASSPHRASE'),
],
/*
|--------------------------------------------------------------------------
| JWT time to live
|--------------------------------------------------------------------------
|
| Specify the length of time (in minutes) that the token will be valid for.
| Defaults to 1 hour.
|
| You can also set this to null, to yield a never expiring token.
| Some people may want this behaviour for e.g. a mobile app.
| This is not particularly recommended, so make sure you have appropriate
| systems in place to revoke the token if necessary.
| Notice: If you set this to null you should remove 'exp' element from 'required_claims' list.
|
*/
'ttl' => env('JWT_TTL', 60),
/*
|--------------------------------------------------------------------------
| Refresh time to live
|--------------------------------------------------------------------------
|
| Specify the length of time (in minutes) that the token can be refreshed
| within. I.E. The user can refresh their token within a 2 week window of
| the original token being created until they must re-authenticate.
| Defaults to 2 weeks.
|
| You can also set this to null, to yield an infinite refresh time.
| Some may want this instead of never expiring tokens for e.g. a mobile app.
| This is not particularly recommended, so make sure you have appropriate
| systems in place to revoke the token if necessary.
|
*/
'refresh_ttl' => env('JWT_REFRESH_TTL', 20160),
/*
|--------------------------------------------------------------------------
| JWT hashing algorithm
|--------------------------------------------------------------------------
|
| Specify the hashing algorithm that will be used to sign the token.
|
| See here: https://github.com/namshi/jose/tree/master/src/Namshi/JOSE/Signer/OpenSSL
| for possible values.
|
*/
'algo' => env('JWT_ALGO', 'HS256'),
/*
|--------------------------------------------------------------------------
| Required Claims
|--------------------------------------------------------------------------
|
| Specify the required claims that must exist in any token.
| A TokenInvalidException will be thrown if any of these claims are not
| present in the payload.
|
*/
'required_claims' => [
'iss',
'iat',
'exp',
'nbf',
'sub',
'jti',
],
/*
|--------------------------------------------------------------------------
| Persistent Claims
|--------------------------------------------------------------------------
|
| Specify the claim keys to be persisted when refreshing a token.
| `sub` and `iat` will automatically be persisted, in
| addition to the these claims.
|
| Note: If a claim does not exist then it will be ignored.
|
*/
'persistent_claims' => [
// 'foo',
// 'bar',
],
/*
|--------------------------------------------------------------------------
| Lock Subject
|--------------------------------------------------------------------------
|
| This will determine whether a `prv` claim is automatically added to
| the token. The purpose of this is to ensure that if you have multiple
| authentication models e.g. `App\User` & `App\OtherPerson`, then we
| should prevent one authentication request from impersonating another,
| if 2 tokens happen to have the same id across the 2 different models.
|
| Under specific circumstances, you may want to disable this behaviour
| e.g. if you only have one authentication model, then you would save
| a little on token size.
|
*/
'lock_subject' => true,
/*
|--------------------------------------------------------------------------
| Leeway
|--------------------------------------------------------------------------
|
| This property gives the jwt timestamp claims some "leeway".
| Meaning that if you have any unavoidable slight clock skew on
| any of your servers then this will afford you some level of cushioning.
|
| This applies to the claims `iat`, `nbf` and `exp`.
|
| Specify in seconds - only if you know you need it.
|
*/
'leeway' => env('JWT_LEEWAY', 0),
/*
|--------------------------------------------------------------------------
| Blacklist Enabled
|--------------------------------------------------------------------------
|
| In order to invalidate tokens, you must have the blacklist enabled.
| If you do not want or need this functionality, then set this to false.
|
*/
'blacklist_enabled' => env('JWT_BLACKLIST_ENABLED', true),
/*
| -------------------------------------------------------------------------
| Blacklist Grace Period
| -------------------------------------------------------------------------
|
| When multiple concurrent requests are made with the same JWT,
| it is possible that some of them fail, due to token regeneration
| on every request.
|
| Set grace period in seconds to prevent parallel request failure.
|
*/
'blacklist_grace_period' => env('JWT_BLACKLIST_GRACE_PERIOD', 0),
/*
|--------------------------------------------------------------------------
| Cookies encryption
|--------------------------------------------------------------------------
|
| By default Laravel encrypt cookies for security reason.
| If you decide to not decrypt cookies, you will have to configure Laravel
| to not encrypt your cookie token by adding its name into the $except
| array available in the middleware "EncryptCookies" provided by Laravel.
| see https://laravel.com/docs/master/responses#cookies-and-encryption
| for details.
|
| Set it to true if you want to decrypt cookies.
|
*/
'decrypt_cookies' => false,
/*
|--------------------------------------------------------------------------
| Providers
|--------------------------------------------------------------------------
|
| Specify the various providers used throughout the package.
|
*/
'providers' => [
/*
|--------------------------------------------------------------------------
| JWT Provider
|--------------------------------------------------------------------------
|
| Specify the provider that is used to create and decode the tokens.
|
*/
'jwt' => Tymon\JWTAuth\Providers\JWT\Lcobucci::class,
/*
|--------------------------------------------------------------------------
| Authentication Provider
|--------------------------------------------------------------------------
|
| Specify the provider that is used to authenticate users.
|
*/
'auth' => Tymon\JWTAuth\Providers\Auth\Illuminate::class,
/*
|--------------------------------------------------------------------------
| Storage Provider
|--------------------------------------------------------------------------
|
| Specify the provider that is used to store tokens in the blacklist.
|
*/
'storage' => Tymon\JWTAuth\Providers\Storage\Illuminate::class,
],
];

View file

@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreatePagecontentsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('pagecontents', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('page')->default('');
$table->string('body')->default('');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('pagecontents');
}
}

View file

@ -1990,6 +1990,11 @@ __webpack_require__.r(__webpack_exports__);
//
//
//
//
//
//
//
//
/* harmony default export */ __webpack_exports__["default"] = ({
data: function data() {
return {
@ -2001,17 +2006,18 @@ __webpack_require__.r(__webpack_exports__);
logout: function logout() {
var _this = this;
console.log("logging out with token " + this.$store.state.user.token); // Empty brackets are an empty object usually containing form data
console.log("logging out with token " + this.$store.state.user_token); // Empty brackets are an empty object usually containing form data
axios.post('http://localhost:8000/api/v1/auth/logout', {}, {
headers: {
'Authorization': 'Bearer ' + this.$store.state.user.token
'Authorization': 'Bearer ' + this.$store.state.user_token
}
}).then(function (res) {
console.log("Logout successful");
_this.$store.state.user.token = null;
_this.$store.state.user_token = null;
_this.$router.go(); //Reload page with updated access-based display
_this.$router.push('/');
})["catch"](function (error) {
console.log("Logout unsuccessful.");
console.log(error);
@ -2019,6 +2025,31 @@ __webpack_require__.r(__webpack_exports__);
},
editPage: function editPage() {
this.$router.push('/edit_page');
},
loadPage: function loadPage() {
axios.post('http://localhost:8000/api/v1/auth/load_page', {
page: 'testpage'
}, {
headers: {
'Authorization': 'Bearer ' + this.$store.state.user_token
}
}).then(function (res) {
console.log("savePage: Loading Testpage");
console.log("Body:");
console.log(res.data.body);
});
},
savePage: function savePage() {
axios.post('http://localhost:8000/api/v1/auth/save_page', {
page: 'testpage',
body: 'testbody'
}, {
headers: {
'Authorization': 'Bearer ' + this.$store.state.user_token
}
}).then(function (res) {
console.log("savePage: Wrote Testpage");
});
}
},
created: function created() {
@ -2117,10 +2148,13 @@ __webpack_require__.r(__webpack_exports__);
}).then(function (res) {
console.log("Login successful. Token=" + res.headers.authorization);
_this.$store.state.user_token = res.headers.authorization;
_this.$store.state.user = res.data.user; //console.log("Storing user data:");
//console.log(res.data.user);
//console.log("Test extraction:");
//console.log(this.$store.state.user.role);
_this.$store.state.user = res.data.user;
console.log("Storing user data:");
console.log(res.data.user);
console.log("Test extraction:");
console.log(_this.$store.state.user.role);
console.log(_this.$store.state.user.token);
console.log(_this.$store.state.user_token);
_this.$router.push('/');
})["catch"](function (error) {
@ -31196,6 +31230,45 @@ var render = function() {
[_vm._v("Impressum")]
),
_vm._v(" "),
_c(
"button",
{
staticClass: "button",
on: {
click: function($event) {
return _vm.savePage()
}
}
},
[_vm._v("Save Page")]
),
_vm._v(" "),
_c(
"button",
{
staticClass: "button",
on: {
click: function($event) {
return _vm.loadPage()
}
}
},
[_vm._v("Load Page")]
),
_vm._v(" "),
_c(
"button",
{
staticClass: "button",
on: {
click: function($event) {
return _vm.logout()
}
}
},
[_vm._v("Logout")]
),
_vm._v(" "),
_c(
"router-link",
{ staticClass: "button", attrs: { to: { name: "Login" } } },

View file

@ -19,10 +19,15 @@
<button class="button" @click="changeMainText('Wetter')" >Wetter</button>
<button class="button" @click="changeMainText('Links')" >Links</button>
<button class="button" @click="changeMainText('Impressum')" >Impressum</button>
<button class="button" @click="savePage()" >Save Page</button>
<button class="button" @click="loadPage()" >Load Page</button>
<button class="button" @click="logout()" >Logout</button>
<router-link class="button" :to="{ name: 'Login' }">Log-In</router-link>
</div>
<p>&nbsp;</p>
@ -75,18 +80,18 @@
methods: {
logout() {
console.log("logging out with token "+this.$store.state.user.token);
console.log("logging out with token "+this.$store.state.user_token);
// Empty brackets are an empty object usually containing form data
axios.post('http://localhost:8000/api/v1/auth/logout',{}, {
headers: {
'Authorization': 'Bearer ' + this.$store.state.user.token
'Authorization': 'Bearer ' + this.$store.state.user_token
}
})
.then(res => {
console.log("Logout successful");
this.$store.state.user.token=null;
this.$router.push('/');
this.$store.state.user_token=null;
this.$router.go();//Reload page with updated access-based display
}
)
.catch(error => {
@ -96,6 +101,38 @@
},
editPage() {
this.$router.push('/edit_page');
},
loadPage() {
axios.post('http://localhost:8000/api/v1/auth/load_page',{
page: 'testpage'
}, {
headers: {
'Authorization': 'Bearer ' + this.$store.state.user_token
}
})
.then(res => {
console.log("savePage: Loading Testpage");
console.log("Body:");
console.log(res.data.body);
}
)
}
,
savePage() {
axios.post('http://localhost:8000/api/v1/auth/save_page',{
page: 'testpage',
body: 'testbody'
}, {
headers: {
'Authorization': 'Bearer ' + this.$store.state.user_token
}
})
.then(res => {
console.log("savePage: Wrote Testpage");
}
)
}
}
,

View file

@ -71,10 +71,13 @@
console.log("Login successful. Token="+res.headers.authorization);
this.$store.state.user_token=res.headers.authorization;
this.$store.state.user=res.data.user;
//console.log("Storing user data:");
//console.log(res.data.user);
//console.log("Test extraction:");
//console.log(this.$store.state.user.role);
console.log("Storing user data:");
console.log(res.data.user);
console.log("Test extraction:");
console.log(this.$store.state.user.role);
console.log(this.$store.state.user.token);
console.log(this.$store.state.user_token);
this.$router.push('/');
}
)

View file

@ -36,8 +36,11 @@ Route::prefix('v1')->group(function () {
// Logout user from application
Route::post('logout', 'AuthController@logout');
//TEST
Route::post('showme', 'UserController@showme');
//Save Page Content
Route::post('save_page', 'PageController@save_page');
//Load Page Content
Route::post('load_page', 'PageController@load_page');
});
});