View index.php
<?php | |
require realpath(dirname(__FILE__)) .'/../src/bootstrap.php'; | |
header("Access-Control-Allow-Origin: *"); | |
header('Access-Control-Allow-Methods: GET, POST'); | |
header("Access-Control-Allow-Headers: DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range"); | |
switch (true) { | |
case '/api/query' === $_SERVER['REQUEST_URI'] && $_SERVER['REQUEST_METHOD'] === 'POST': |
View default.conf
server { | |
listen 443 ssl; | |
server_name pgn-chess-data.local; | |
ssl_certificate /etc/nginx/ssl/pgn-chess-data.local.crt; | |
ssl_certificate_key /etc/nginx/ssl/pgn-chess-data.local.key; | |
ssl_ciphers EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH; | |
ssl_protocols TLSv1.1 TLSv1.2; | |
root /usr/share/nginx/pgn-chess-data/public; |
View Session.js
import Cookies from 'js-cookie'; | |
const name = 'session'; | |
export default class Session { | |
static get() { | |
if (Cookies.get(name)) { | |
return JSON.parse(Cookies.get(name)); | |
} | |
return { |
View AuthController.php
<?php | |
namespace App\Http\Controllers; | |
use Illuminate\Http\Request; | |
class AuthController extends Controller | |
{ | |
const COOKIE_ACCESS_TOKEN = 'access_token'; | |
const COOKIE_SESSION = 'session'; |
View StoreRestaurant.php
<?php | |
namespace App\Http\Requests; | |
class StoreRestaurant extends AbstractAuthorizedFormRequest | |
{ | |
/** | |
* Get the validation rules that apply to the request. | |
* | |
* @return array |
View api.php
<?php | |
use Illuminate\Http\Request; | |
Route::post('/auth/login', 'AuthController@login'); | |
Route::post('/auth/logout', 'AuthController@logout')->middleware('jwt.authorizer'); | |
Route::get('restaurants', 'RestaurantController@index')->middleware('jwt.authorizer', 'acl'); | |
Route::get('restaurants/{restaurant}', 'RestaurantController@show')->middleware('jwt.authorizer', 'acl'); | |
Route::post('restaurants', 'RestaurantController@store')->middleware('jwt.authorizer', 'acl'); |
View Kernel.php
<?php | |
// ... | |
/** | |
* The application's route middleware. | |
* | |
* These middleware may be assigned to groups or used individually. | |
* | |
* @var array | |
*/ |
View Acl.php
<?php | |
namespace App\Http\Middleware; | |
use Closure; | |
class Acl | |
{ | |
/** | |
* Handle an incoming request. |
View gist:530e8f4f74c78d68a5e6c57df7cdc988
mysql> select * from acls; | |
+----+-----------------------------+-------------+---------------------+---------------------+ | |
| id | resource | role | created_at | updated_at | | |
+----+-----------------------------+-------------+---------------------+---------------------+ | |
| 1 | ReviewController@store | ROLE_BASIC | 2019-11-04 21:53:18 | 2019-11-04 21:53:18 | | |
| 2 | RestaurantController@index | ROLE_EDITOR | 2019-11-04 21:53:18 | 2019-11-04 21:53:18 | | |
| 3 | RestaurantController@show | ROLE_EDITOR | 2019-11-04 21:53:18 | 2019-11-04 21:53:18 | | |
| 4 | RestaurantController@update | ROLE_EDITOR | 2019-11-04 21:53:18 | 2019-11-04 21:53:18 | | |
| 5 | RestaurantController@delete | ROLE_EDITOR | 2019-11-04 21:53:18 | 2019-11-04 21:53:18 | | |
| 6 | ReviewController@delete | ROLE_EDITOR | 2019-11-04 21:53:18 | 2019-11-04 21:53:18 | |
NewerOlder