Skip to content

Commit

Permalink
1.0.0 Release (#3)
Browse files Browse the repository at this point in the history
* Extending documentation

* Re-order badges

* Chasing 100% code coverage

* Updated description and keywords

* Added travis-ci config

* Finishing documentation for 1.0.0 release

* Lowercase config

* Users can now publish the packages configuration to their project

* Remove lock file
  • Loading branch information
carbontwelve authored Feb 14, 2018
1 parent d9797b8 commit 70df686
Show file tree
Hide file tree
Showing 9 changed files with 109 additions and 3,545 deletions.
27 changes: 27 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
language: php

sudo: false

matrix:
include:
- php: 7.0
- php: 7.1
- php: nightly
allow_failures:
- php: nightly
fast_finish: true

cache:
directories:
- $HOME/.composer/cache

before_install:
- source .travis/travis.sh
- xdebug-disable
- travis_retry composer self-update

install:
- travis_retry composer install --no-interaction --prefer-dist --no-suggest;

script:
- run-tests
35 changes: 35 additions & 0 deletions .travis/travis.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env bash

# The problem is that we do not want to remove the configuration file, just disable it for a few tasks, then enable it
#
# For reference, see
#
# - https://docs.travis-ci.com/user/languages/php#Disabling-preinstalled-PHP-extensions
# - https://docs.travis-ci.com/user/languages/php#Custom-PHP-configuration
#
# Original Source (this was copied from):
# - https://github.com/codeclimate/php-test-reporter/blob/master/.travis/travis.sh

config="/home/travis/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini"

function xdebug-disable() {
if [[ -f $config ]]; then
mv $config "$config.bak"
fi
}

function xdebug-enable() {
if [[ -f "$config.bak" ]]; then
mv "$config.bak" $config
fi
}

function run-tests() {
if [[ "$WITH_COVERAGE" == "true" ]]; then
xdebug-enable
vendor/bin/phpunit --coverage-clover=$TRAVIS_BUILD_DIR/build/logs/clover.xml
xdebug-disable
else
vendor/bin/phpunit
fi
}
34 changes: 32 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,39 @@
<p align="center"><em>Solid credential validation for Laravel >= 5.5</em></p>

<p align="center">
<a href="https://travis-ci.org/photogabble/laravel-registration-validator"><img src="https://travis-ci.org/photogabble/laravel-registration-validator.svg?branch=master" alt="Build Status">
<a href="https://packagist.org/packages/photogabble/laravel-registration-validator"><img src="https://poser.pugx.org/photogabble/laravel-registration-validator/v/stable.svg" alt="Latest Stable Version"></a>
<a href="LICENSE"><img src="https://poser.pugx.org/photogabble/php-confusable-homoglyphs/license.svg" alt="License"></a>
</p>

> **NOTE** This project is currently a work in progress.
### About this package

This library was written after reading [this article](https://www.b-list.org/weblog/2018/feb/11/usernames/) by James Bennett on registration credential valition that referenced how [Django’s auth system](https://github.com/ubernostrum/django-registration/blob/1d7d0f01a24b916977016c1d66823a5e4a33f2a0/registration/validators.py) validates new users credentials.
> _An all-Latin username containing confusables is probably fine, and an all-Cyrillic username containing confusables is probably fine, but a username containing mostly Latin plus one Cyrillic code point which happens to be confusable with a Latin one… is not._ - [James Bennet](https://www.b-list.org/weblog/2018/feb/11/usernames/)
This package is a Laravel validation wrapper around the [PHP Confusable Homoglyphs library](https://github.com/photogabble/php-confusable-homoglyphs) to provide your application the ability to validate user input as not containing dangerous confusables.

I began writing this package soon after reading the above quote from [this article](https://www.b-list.org/weblog/2018/feb/11/usernames/) by James Bennett on registration credential validation that referenced how [Django’s auth system](https://github.com/ubernostrum/django-registration/blob/1d7d0f01a24b916977016c1d66823a5e4a33f2a0/registration/validators.py) validates new users credentials.

In addition to unicode confusables validation this package also includes a PHP port of the reserved name validation that Django's auth system uses.

This is a PHP7 project built for use with Laravel versions 5.5 and above.

### Install

Install this library with composer: `composer require photogabble/laravel-registration-validator`.

### Usage

This package provides three validators: `not-reserved-name`, `not-confusable-string` and `not-confusable-email`.

#### Not Reserved Name Validator

This validator checks the input to ensure it does not contain any strings listed within config key `registration-validation.reserved_list`. To extend this list use the `php artisan vendor:publish` command to copy this config to your project.

#### Not Confusable String Validator

This validator checks the input using the [PHP Confusable Homoglyphs library](https://github.com/photogabble/php-confusable-homoglyphs) to ensure it does not contain any confusable unicode characters.

#### Not Confusable Email Validator

This validator does not validate that the input is a valid email address, instead it validates that a string containing an `@` does not contain any confusable unicode characters for each part either side of the `@` symbol.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"name": "photogabble/laravel-registration-validator",
"type": "library",
"description": "Laravel validation extensions for validating registration credentials.",
"description": "Solid credential validation for Laravel.",
"keywords": [
"laravel",
"auth",
"validation",
"registration",
"credentials",
"username",
"email"
Expand Down
Loading

0 comments on commit 70df686

Please sign in to comment.