Commit bc148fc5 authored by Mark Tearle's avatar Mark Tearle

Check username, generate intial API key

parent bc213f6e
......@@ -4,8 +4,54 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "ad1bbaa996814e3c04b3cb0d08ab93a8",
"content-hash": "e36674be36327a3c6f04da0a6c8fba14",
"packages": [
{
"name": "brick/math",
"version": "0.9.1",
"source": {
"type": "git",
"url": "https://github.com/brick/math.git",
"reference": "283a40c901101e66de7061bd359252c013dcc43c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/brick/math/zipball/283a40c901101e66de7061bd359252c013dcc43c",
"reference": "283a40c901101e66de7061bd359252c013dcc43c",
"shasum": ""
},
"require": {
"ext-json": "*",
"php": "^7.1|^8.0"
},
"require-dev": {
"php-coveralls/php-coveralls": "^2.2",
"phpunit/phpunit": "^7.5.15|^8.5",
"vimeo/psalm": "^3.5"
},
"type": "library",
"autoload": {
"psr-4": {
"Brick\\Math\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "Arbitrary-precision arithmetic library",
"keywords": [
"Arbitrary-precision",
"BigInteger",
"BigRational",
"arithmetic",
"bigdecimal",
"bignum",
"brick",
"math"
],
"time": "2020-08-18T23:57:15+00:00"
},
{
"name": "doctrine/inflector",
"version": "2.0.3",
......@@ -834,6 +880,150 @@
],
"time": "2017-10-23T01:57:42+00:00"
},
{
"name": "ramsey/collection",
"version": "1.1.1",
"source": {
"type": "git",
"url": "https://github.com/ramsey/collection.git",
"reference": "24d93aefb2cd786b7edd9f45b554aea20b28b9b1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/ramsey/collection/zipball/24d93aefb2cd786b7edd9f45b554aea20b28b9b1",
"reference": "24d93aefb2cd786b7edd9f45b554aea20b28b9b1",
"shasum": ""
},
"require": {
"php": "^7.2 || ^8"
},
"require-dev": {
"captainhook/captainhook": "^5.3",
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.0",
"ergebnis/composer-normalize": "^2.6",
"fzaninotto/faker": "^1.5",
"hamcrest/hamcrest-php": "^2",
"jangregor/phpstan-prophecy": "^0.6",
"mockery/mockery": "^1.3",
"phpstan/extension-installer": "^1",
"phpstan/phpstan": "^0.12.32",
"phpstan/phpstan-mockery": "^0.12.5",
"phpstan/phpstan-phpunit": "^0.12.11",
"phpunit/phpunit": "^8.5",
"psy/psysh": "^0.10.4",
"slevomat/coding-standard": "^6.3",
"squizlabs/php_codesniffer": "^3.5",
"vimeo/psalm": "^3.12.2"
},
"type": "library",
"autoload": {
"psr-4": {
"Ramsey\\Collection\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Ben Ramsey",
"email": "[email protected]",
"homepage": "https://benramsey.com"
}
],
"description": "A PHP 7.2+ library for representing and manipulating collections.",
"keywords": [
"array",
"collection",
"hash",
"map",
"queue",
"set"
],
"time": "2020-09-10T20:58:17+00:00"
},
{
"name": "ramsey/uuid",
"version": "4.1.1",
"source": {
"type": "git",
"url": "https://github.com/ramsey/uuid.git",
"reference": "cd4032040a750077205918c86049aa0f43d22947"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/ramsey/uuid/zipball/cd4032040a750077205918c86049aa0f43d22947",
"reference": "cd4032040a750077205918c86049aa0f43d22947",
"shasum": ""
},
"require": {
"brick/math": "^0.8 || ^0.9",
"ext-json": "*",
"php": "^7.2 || ^8",
"ramsey/collection": "^1.0",
"symfony/polyfill-ctype": "^1.8"
},
"replace": {
"rhumsaa/uuid": "self.version"
},
"require-dev": {
"codeception/aspect-mock": "^3",
"dealerdirect/phpcodesniffer-composer-installer": "^0.6.2 || ^0.7.0",
"doctrine/annotations": "^1.8",
"goaop/framework": "^2",
"mockery/mockery": "^1.3",
"moontoast/math": "^1.1",
"paragonie/random-lib": "^2",
"php-mock/php-mock-mockery": "^1.3",
"php-mock/php-mock-phpunit": "^2.5",
"php-parallel-lint/php-parallel-lint": "^1.1",
"phpbench/phpbench": "^0.17.1",
"phpstan/extension-installer": "^1.0",
"phpstan/phpstan": "^0.12",
"phpstan/phpstan-mockery": "^0.12",
"phpstan/phpstan-phpunit": "^0.12",
"phpunit/phpunit": "^8.5",
"psy/psysh": "^0.10.0",
"slevomat/coding-standard": "^6.0",
"squizlabs/php_codesniffer": "^3.5",
"vimeo/psalm": "3.9.4"
},
"suggest": {
"ext-bcmath": "Enables faster math with arbitrary-precision integers using BCMath.",
"ext-ctype": "Enables faster processing of character classification using ctype functions.",
"ext-gmp": "Enables faster math with arbitrary-precision integers using GMP.",
"ext-uuid": "Enables the use of PeclUuidTimeGenerator and PeclUuidRandomGenerator.",
"paragonie/random-lib": "Provides RandomLib for use with the RandomLibAdapter",
"ramsey/uuid-doctrine": "Allows the use of Ramsey\\Uuid\\Uuid as Doctrine field type."
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.x-dev"
}
},
"autoload": {
"psr-4": {
"Ramsey\\Uuid\\": "src/"
},
"files": [
"src/functions.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "A PHP library for generating and working with universally unique identifiers (UUIDs).",
"homepage": "https://github.com/ramsey/uuid",
"keywords": [
"guid",
"identifier",
"uuid"
],
"time": "2020-08-18T17:17:46+00:00"
},
{
"name": "symfony/debug",
"version": "v4.4.18",
......@@ -930,6 +1120,68 @@
"homepage": "https://symfony.com",
"time": "2020-12-08T16:59:59+00:00"
},
{
"name": "symfony/polyfill-ctype",
"version": "v1.22.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-ctype.git",
"reference": "c6c942b1ac76c82448322025e084cadc56048b4e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/c6c942b1ac76c82448322025e084cadc56048b4e",
"reference": "c6c942b1ac76c82448322025e084cadc56048b4e",
"shasum": ""
},
"require": {
"php": ">=7.1"
},
"suggest": {
"ext-ctype": "For best performance"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "1.22-dev"
},
"thanks": {
"name": "symfony/polyfill",
"url": "https://github.com/symfony/polyfill"
}
},
"autoload": {
"psr-4": {
"Symfony\\Polyfill\\Ctype\\": ""
},
"files": [
"bootstrap.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Gert de Pagter",
"email": "[email protected]"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony polyfill for ctype functions",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"ctype",
"polyfill",
"portable"
],
"time": "2021-01-07T16:49:33+00:00"
},
{
"name": "symfony/polyfill-mbstring",
"version": "v1.22.0",
......
......@@ -5,9 +5,12 @@ ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
require_once 'config.php';
use Ramsey\Uuid\Uuid;
function check_username($username) {
return 1;
// returns true if we get some info about the username
return is_array(posix_getpwnam($username));
}
function check_api_key($api_key) {
......@@ -42,12 +45,15 @@ $leaf->post('/register', function () use($leaf) {
$username = $leaf->request->get('username');
// Check username is valid
if !check_username($username) {
if ( !check_username($username) ) {
$leaf->response->respond(["message" => $username." not valid"]);
return;
}
// Generate API key
$api_key = Uuid::uuid4()->toString();
// Stick API key encrypted into the DNS
// Email API key
......
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