1234567891011121314151617181920212223242526272829303132333435 |
- <?php
-
- require_once('vendor/autoload.php');
-
- use Macaroons\Macaroon;
- use Macaroons\Verifier;
-
- if(!isset($_COOKIE['das-macaroon'])) {
- echo "Not logged in";
- exit();
- }
-
- $serialised = $_COOKIE['das-macaroon'];
-
- $m = Macaroon::deserialize($serialised);
- $v = new Verifier();
-
-
- $v->setCallbacks([
- function($a) {
- return !strcmp($a, "status = teacher");
- }
- ]);
-
- try {
- $bool = $v->verify($m, 'pocsecret');
- } catch(Exception $e) {
- $bool = false;
- }
-
- if($bool) {
- echo "Access granted.\n<br />Welcome ".$m->getIdentifier()."!";
- } else {
- echo "Access denied. Service is restricted to teachers.";
- }
|