Skip to content

Commit

Permalink
Merge pull request #21 from VirgilSecurity/develop
Browse files Browse the repository at this point in the history
Add recovery feature to the samples (v2.2.0)
  • Loading branch information
PetrenkoAnton authored Jul 4, 2019
2 parents fcf6eab + 8e1ee8f commit 3f7cf02
Show file tree
Hide file tree
Showing 23 changed files with 1,069 additions and 2,096 deletions.
52 changes: 17 additions & 35 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,43 +3,25 @@ matrix:
include:
- os: linux
compiler: gcc
env: PHPUNIT_VERSION=7.5.1 PHP_VERSION=7.2
sudo: required
dist: trusty
dist: xenial
before_install:
- openssl aes-256-cbc -K $encrypted_464d35101f45_key -iv $encrypted_464d35101f45_iv -in .env.enc -out .env -d
- date -u
- uname -a
- if [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then lscpu; fi
- openssl aes-256-cbc -K $encrypted_464d35101f45_key -iv $encrypted_464d35101f45_iv -in .env.enc -out .env -d
install:
# Use clean dependencies installation to avoid versions collision.
- export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
- echo "Install PHP version ${PHP_VERSION} ..."
- travis_retry sudo apt-add-repository -y ppa:ondrej/php
- travis_retry sudo apt-get -qq update
- travis_retry sudo apt-get install -y -qq php${PHP_VERSION}
- travis_retry sudo apt-get install -y -qq php${PHP_VERSION}-cli
- travis_retry sudo apt-get install -y -qq php${PHP_VERSION}-dev
- travis_retry sudo apt-get install -y -qq php${PHP_VERSION}-mbstring
- travis_retry sudo apt-get install -y -qq php${PHP_VERSION}-curl
- travis_retry sudo apt-get install -y -qq php${PHP_VERSION}-xml
- echo "Install PHPUnit version ${PHPUNIT_VERSION} ..."
- travis_retry wget https://phar.phpunit.de/phpunit-${PHPUNIT_VERSION}.phar
- chmod +x phpunit-${PHPUNIT_VERSION}.phar
- sudo mv phpunit-${PHPUNIT_VERSION}.phar /usr/bin/phpunit
- echo "Install composer globally"
- curl -sS https://getcomposer.org/installer -o composer-setup.php
- sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
- php --version
- php -i
- phpunit --version
- php-config --extension-dir
- composer --version
- export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
- travis_retry sudo apt-get install software-properties-common
- travis_retry sudo add-apt-repository -y ppa:ondrej/php
- travis_retry sudo apt-get update
- travis_retry sudo apt install -y php7.2 php7.2-dev php7.2-cli
php7.2-mbstring php7.2-curl php7.2-xml php7.2-intl
- travis_retry wget https://phar.phpunit.de/phpunit-7.5.1.phar
- chmod +x phpunit-7.5.1.phar
- sudo mv phpunit-7.5.1.phar /usr/bin/phpunit
- curl -sS https://getcomposer.org/installer -o composer-setup.php
- sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
before_script:
- sudo cp $TRAVIS_BUILD_DIR/_travis/vsce_phe_php.so /usr/lib/php/20170718
- cd /usr/lib/php/20170718
- ls -a
- sudo sh -c "echo 'extension=vsce_phe_php.so' >> /etc/php/7.2/cli/php.ini"
- cd $TRAVIS_BUILD_DIR
- composer install
- sudo cp $TRAVIS_BUILD_DIR/_travis/vsce_phe_php.so /usr/lib/php/20170718
- sudo sh -c "echo 'extension=vsce_phe_php.so' >> /etc/php/7.2/cli/php.ini"
- composer install
script: phpunit --configuration phpunit.xml

52 changes: 23 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ The PureKit is provided as a package named `virgil/purekit`. The package is dist

### Install PureKit Package

- **Step #1.** Add the [vsce_phe_php extension](https://github.com/VirgilSecurity/virgil-purekit-php/releases) into your server before using the PureKit. Read more [here](#add-the-vsce_phe_php-extension).
- **Step #1.** Add the [crypto extensions](https://github.com/VirgilSecurity/virgil-purekit-php/releases) into your
server before using the PureKit. Read more [here](#add-the-crypto-extensions-into-your-server-before-using-the-purekit).

- **Step #2.** Install PureKit library with the following code:
```bash
Expand Down Expand Up @@ -277,53 +278,46 @@ UPDATE_TOKEN= //must be empty
## Additional information
### Add the vsce_phe_php extension
### Add the crypto extensions into your server before using the PureKit
- [Download](https://github.com/VirgilSecurity/virgil-purekit-php/releases), unzip and execute on your server
[virgil-test.php](/_help/virgil-test.php) file.
- [Download](https://github.com/VirgilSecurity/virgil-purekit-php/releases) *virgil-test.zip*, unzip it and execute on your server [virgil-test.php](/_help/virgil-test.php) file.
- [Download](https://github.com/VirgilSecurity/virgil-purekit-php/releases) and unzip *vsce_phe_php* extension
according to your server operating system.
- [Download](https://github.com/VirgilSecurity/virgil-purekit-php/releases) and unzip *%YOUR_OS%_extensions.zip* archive according to your server operating system and PHP version.
- Make sure you have access to edit the php.ini file. For example, use *root*
- Make sure you have access to edit the php.ini file (for example, use *root* for the Linux/Darwin or run *cmd* under administrator for the Windows).
- Copy extension files to the extensions directory.
- For Linux/Darwin:
```
$ sudo su
$ path="%PATH_TO_EXTENSIONS_DIR%" && cp vsce_phe_php.so $path && cp virgil_crypto_php.so $path
```
- Add the *extension=vsce_phe_php* string in to the php.ini file
- For Windows:
```
$ echo "extension=vsce_phe_php” >> (PATH_TO_PHP.INI)
$ set path=%PATH_TO_EXTENSIONS_DIR% && copy vsce_phe_php.dll %path% && copy virgil_crypto_php.dll %path%
```
- Copy extension file to the extensions directory.
- For the Linux/Darwin:
```
$ cp vsce_phe_php.so (PATH_TO_EXTENSION_DIR)
```
- Or for the Windows:
- Add the extensions into the php.ini file
```
$ cp vsce_phe_php.dll (PATH_TO_EXTENSION_DIR)
$ echo -e "extension=vsce_phe_php\nextension=virgil_crypto_php” >> %PATH_TO_PHP.INI%
```
- Then, restart your server or php-fpm service!
- Restart your server or php-fpm service
#### Installation example
#### Extensions installation example
Our web stack is: *Linux, nginx, php7.2-fpm*
- Execute the [virgil-test.php](/_help/virgil-test.php) to find out your path to php.ini file and path to the extension directory:
<p><img src="https://raw.githubusercontent.com/VirgilSecurity/virgil-purekit-php/master/_help/s-1.png"
- Execute the [virgil-test.php](/_help/virgil-test.php) to find your path to the extensions directory and path to the php.ini file:
<p><img src="https://raw.githubusercontent.com/VirgilSecurity/virgil-pure-wordpress/master/_help/s-1.png"
width="60%"></p>
- Then, go to the command line interface (CLI) to specify the paths from the previous step:
<p><img src="https://raw.githubusercontent.com/VirgilSecurity/virgil-purekit-php/master/_help/s-2.png"
- Then, go to the command line interface (CLI) to specify the paths you identified in the previous step:
<p><img src="https://raw.githubusercontent.com/VirgilSecurity/virgil-pure-wordpress/master/_help/s-2.png"
width="60%"></p>
- Reload the page in your browser to see that extension is loaded (`IS_EXTENSION_LOADED => TRUE`):
<p><img src="https://raw.githubusercontent.com/VirgilSecurity/virgil-purekit-php/master/_help/s-3.png"
- Reload the page in your browser to see that the extension is loaded (`IS_VSCE_PHE_PHP_EXTENSION_LOADED => true` and
`IS_VIRGIL_CRYPTO_PHP_EXTENSION_LOADED => true`):
<p><img src="https://raw.githubusercontent.com/VirgilSecurity/virgil-pure-wordpress/master/_help/s-3.png"
width="60%"></p>
## Docs
* [Virgil Dashboard](https://dashboard.virgilsecurity.com)
* [The PHE WhitePaper](https://virgilsecurity.com/wp-content/uploads/2018/11/PHE-Whitepaper-2018.pdf) - foundation principles of the protocol
Expand Down
Binary file modified _help/s-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified _help/s-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified _help/s-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 8 additions & 5 deletions _help/virgil-test.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
<?php

$extension = 'vsce_phe_php';
$vsce_phe_php = 'vsce_phe_php';
$virgil_crypto_php = 'virgil_crypto_php';

$result = [
'EXTENSION_NAME' => $extension,
'VSCE_PHE_PHP_EXTENSION' => $vsce_phe_php,
'IS_VSCE_PHE_PHP_EXTENSION_LOADED' => extension_loaded($vsce_phe_php),
'VIRGIL_CRYPTO_PHP_EXTENSION' => $virgil_crypto_php,
'IS_VIRGIL_CRYPTO_PHP_EXTENSION_LOADED' => extension_loaded($virgil_crypto_php),
'OS' => PHP_OS,
'PHP' => PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION,
'PATH_TO_EXTENSION_DIR' => PHP_EXTENSION_DIR,
'PATH_TO_EXTENSIONS_DIR' => PHP_EXTENSION_DIR,
'PATH_TO_PHP.INI' => php_ini_loaded_file(),
'IS_EXTENSION_LOADED' => extension_loaded($extension),
];

var_dump($result);
exit();
exit();
Loading

0 comments on commit 3f7cf02

Please sign in to comment.