diff --git a/flexiapi/.env.example b/flexiapi/.env.example index e0aee00..3046e3c 100644 --- a/flexiapi/.env.example +++ b/flexiapi/.env.example @@ -34,3 +34,6 @@ OVH_APP_KEY= OVH_APP_SECRET= OVH_APP_ENDPOINT=ovh-eu OVH_APP_CONSUMER_KEY= + +NOCAPTCHA_SECRET=secret-key +NOCAPTCHA_SITEKEY=site-key \ No newline at end of file diff --git a/flexiapi/README.md b/flexiapi/README.md index feebabc..e17e9ee 100644 --- a/flexiapi/README.md +++ b/flexiapi/README.md @@ -19,6 +19,27 @@ You can also run the test suit using `phpunit`. To know more about the web server configuration part, you can directly [visit the official Laravel installation documentation](https://laravel.com/docs/6.x). +### Configure the .env file + +Complete all the other variables in the `.env` file: +- The OVH SMS connector +- SMTP configuration +- App name, SIP domain… + +### SELinux + +If you are running on a CentOS/RedHat machine, please ensure that SELinux is correctly configured. + +Allow the webserver user to write in the `storage/` directory: + + chcon -R -t httpd_sys_rw_content_t storage/ + +If your external database is locate on a remote machine, you should also allow your webserver user to connect to remote hosts: + + semanage port -a -t http_port_t -p tcp 3306 // Open remote connections on the MySQL port for example + setsebool httpd_can_network_connect 1 // Allow remote network connected + setsebool httpd_can_network_connect_db 1 // Allow remote database connection + ### CRON job The DIGEST authentication method is saving some temporary information (nonces) in the database. diff --git a/flexiapi/app/Account.php b/flexiapi/app/Account.php index e90d06e..1a731c0 100644 --- a/flexiapi/app/Account.php +++ b/flexiapi/app/Account.php @@ -27,6 +27,7 @@ class Account extends Authenticatable protected $connection = 'external'; protected $with = ['passwords']; protected $dates = ['creation_time']; + public $timestamps = false; public function passwords() { diff --git a/flexiapi/app/Http/Controllers/AccountController.php b/flexiapi/app/Http/Controllers/AccountController.php index 5ca79d3..5857500 100644 --- a/flexiapi/app/Http/Controllers/AccountController.php +++ b/flexiapi/app/Http/Controllers/AccountController.php @@ -42,6 +42,7 @@ class AccountController extends Controller $request->validate([ 'username' => 'required|unique:external.accounts,username|min:6', 'phone' => 'required_without:email|nullable|unique:external.aliases,alias|unique:external.accounts,username|starts_with:+|phone:AUTO', + 'g-recaptcha-response' => 'required|captcha', 'email' => 'required_without:phone|nullable|email|confirmed' ]); diff --git a/flexiapi/composer.json b/flexiapi/composer.json index a760434..e7df8d5 100644 --- a/flexiapi/composer.json +++ b/flexiapi/composer.json @@ -9,6 +9,7 @@ "license": "MIT", "require": { "php": "^7.2", + "anhskohbo/no-captcha": "^3.2", "fideloper/proxy": "^4.0", "laravel/framework": "^6.2", "laravel/tinker": "^2.0", diff --git a/flexiapi/composer.lock b/flexiapi/composer.lock index 40380bb..3f2b1d1 100644 --- a/flexiapi/composer.lock +++ b/flexiapi/composer.lock @@ -4,8 +4,68 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "06757402a3ada8adde19707d8311f9f1", + "content-hash": "0e10a50683c7b16da67dfd0aa79d09c7", "packages": [ + { + "name": "anhskohbo/no-captcha", + "version": "3.2.0", + "source": { + "type": "git", + "url": "https://github.com/anhskohbo/no-captcha.git", + "reference": "c14dd67024f30fd28f38ac9faa44cc47e1d4bddf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/anhskohbo/no-captcha/zipball/c14dd67024f30fd28f38ac9faa44cc47e1d4bddf", + "reference": "c14dd67024f30fd28f38ac9faa44cc47e1d4bddf", + "shasum": "" + }, + "require": { + "guzzlehttp/guzzle": "^6.2", + "illuminate/support": "^5.0|^6.0|^7.0", + "php": ">=5.5.5" + }, + "require-dev": { + "phpunit/phpunit": "~4.8" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "Anhskohbo\\NoCaptcha\\NoCaptchaServiceProvider" + ], + "aliases": { + "NoCaptcha": "Anhskohbo\\NoCaptcha\\Facades\\NoCaptcha" + } + } + }, + "autoload": { + "psr-4": { + "Anhskohbo\\NoCaptcha\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "anhskohbo", + "email": "anhskohbo@gmail.com" + } + ], + "description": "No CAPTCHA reCAPTCHA For Laravel.", + "keywords": [ + "captcha", + "laravel", + "laravel4", + "laravel5", + "laravel6", + "no-captcha", + "recaptcha" + ], + "time": "2020-03-04T03:27:38+00:00" + }, { "name": "dnoegel/php-xdg-base-dir", "version": "v0.1.1", diff --git a/flexiapi/resources/lang/en/validation.php b/flexiapi/resources/lang/en/validation.php index 429f8a2..9579e3f 100644 --- a/flexiapi/resources/lang/en/validation.php +++ b/flexiapi/resources/lang/en/validation.php @@ -135,6 +135,10 @@ return [ 'attribute-name' => [ 'rule-name' => 'custom-message', ], + 'g-recaptcha-response' => [ + 'required' => 'Please verify that you are not a robot.', + 'captcha' => 'Captcha error! try again later or contact site admin.', + ], ], /* diff --git a/flexiapi/resources/views/account/register.blade.php b/flexiapi/resources/views/account/register.blade.php index 6bcdcb5..8eafa68 100644 --- a/flexiapi/resources/views/account/register.blade.php +++ b/flexiapi/resources/views/account/register.blade.php @@ -32,6 +32,11 @@ {!! Form::text('phone', old('phone'), ['class' => 'form-control', 'placeholder' => '+123456789']) !!} +
+ {!! NoCaptcha::renderJs() !!} + {!! NoCaptcha::display() !!} +
+ {!! Form::submit('Register', ['class' => 'btn btn-primary float-right']) !!} {!! Form::close() !!} diff --git a/flexiapi/resources/views/layouts/account.blade.php b/flexiapi/resources/views/layouts/account.blade.php index b21e785..628cd85 100644 --- a/flexiapi/resources/views/layouts/account.blade.php +++ b/flexiapi/resources/views/layouts/account.blade.php @@ -8,11 +8,13 @@ {{ config('app.name') }} - + @if (Auth::check()) + + @endif