Skip to content

Commit

Permalink
Api and CSRF server side protection
Browse files Browse the repository at this point in the history
  • Loading branch information
kotsis committed Apr 6, 2018
1 parent a585536 commit d1a1ef1
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions api/index.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
session_start();

require 'vendor/autoload.php';

Expand All @@ -9,5 +10,23 @@
return $response->getBody()->write("Hello, " . $args['name']);
});

$app->get('/isLoggedIn', function ($request, $response, $args) {
if(isset($_SESSION['loggedin']) && $_SESSION['loggedin']===TRUE)
return 'yes'; //return $response->getBody()->write("He");

//return $response->getBody()->write("He");
return 'no';
});

$app->post('/login', function(){
//XSRF-TOKEN cookie create and send back ...
//Note that from now on, server-side we must check the user sends the appropriate
//value in X-XSRF-TOKEN html header ...
});

$app->get('/logout', function(){
//to-do
});

$app->run();

0 comments on commit d1a1ef1

Please sign in to comment.