Commit bc213f6e authored by Mark Tearle's avatar Mark Tearle

Sketch out pseudo code for methods in quovadis

parent e778a0b9
<?php
require __DIR__ . '/vendor/autoload.php';
require_once 'quovadis/quovadis.php';
?>
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
require_once 'config.php';
print "<h1> Hello Cruel World </h1>";
function check_username($username) {
return 1;
}
function check_api_key($api_key) {
// API keys need to be alpha numeric
return 1;
}
function check_challenge($challenge) {
// Challenge needs to be alpha numeric (meet DNS requirements)
return 1;
}
// Instantiate Leaf
$leaf = new Leaf\App;
// Add routes
$leaf->get('/', function () use($leaf) {
// since the response object is directly tied to the leaf instance
$leaf->response()->markup('<h5>My first Leaf app</h5>');
});
$leaf->post('/register', function () use($leaf) {
//
// ### Register User
//
// POST /register
//
// Params:
// * UCC username
//
// Will email to your UCC email address an API key to use with the service
$username = $leaf->request->get('username');
// Check username is valid
if !check_username($username) {
$leaf->response->respond(["message" => $username." not valid"]);
return;
}
// Generate API key
// Email API key
$leaf->response->respond(["message" => $username." has been added and email sent"]);
});
$leaf->post('/update-api-key', function () use($leaf) {
//
// ### Update API key
//
// POST /update-api-key
//
// Params:
// * UCC username
// * Old API key
// * New API key
//
// Will update API key
//
// Will email to your UCC email address noting that the API key has been updated
$username = $leaf->request->get('username');
$api_key = $leaf->request->get('api_key');
$new_api_key = $leaf->request->get('new_api_key');
// Check username is valid
// Check API key
// Encrypt API key
// Stick API key encrypted into the DNS
// Email user to let them know API key has updated
});
$leaf->post('/update-challenge', function () use($leaf) {
//
// ### Update Challenge
//
// POST /update-challenge
//
// Params:
//
// * UCC username
// * API key
// * Challenge Handle
// * Challenge TXT
//
// Will update the DNS TXT record at
//
// <ucc username>-<challenge handle>.quovadis.ucc.asn.au
//
// to the contents of Challenge TXT
//
$username = $leaf->request->get('username');
$api_key = $leaf->request->get('api_key');
$challenge = $leaf->request->get('challenge');
$value = $leaf->request->get('value');
// Check username is valid
// Check API key
// Sanity check challenge text
// Stick challenge value prefixed by username into DNS
});
$leaf->run();
?>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment