You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This repository contains a sample backend code that demonstrates how to generate a Virgil JWT using the PHP SDK
Do not use this authentication in production. Requests to /virgil-jwt endpoint must be allowed for authenticated users. Use your application authorization strategy.
Note that required Virgil extensions installs automatically as post install composer script (see composer.json)
Сrypto extensions installation...
----------
Checking input... [OK]
Checking PHP version... [OK]
Checking OS... [OK]
Checking package version... [OK]
Checking PHP extensions directory... [OK]
Checking additional .ini files directory... [OK]
----------
SYSTEM CONFIGURATION:
Crypto version:
OS (short): Linux
PHP version (short): 7.2
PHP version (full):
PHP 7.2.26 (cli) (built: Dec 22 2019 06:01:52) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Xdebug v2.6.1, Copyright (c) 2002-2018, by Derick Rethans
Extensions directory: /usr/lib/php7/modules
Additional .ini files directory: /etc/php7/conf.d /etc/php7/conf.d
----------
Copying vendor/virgil/crypto-wrapper/_extensions/bin/lin/php7.2/vsce_phe_php7.2_v0.15.2.so to the /usr/lib/php7/modules/... [OK]
Copying vendor/virgil/crypto-wrapper/_extensions/bin/lin/php7.2/vscf_foundation_php7.2_v0.15.2.so to the /usr/lib/php7/modules/... [OK]
Copying vendor/virgil/crypto-wrapper/_extensions/bin/lin/php7.2/vscp_pythia_php7.2_v0.15.2.so to the /usr/lib/php7/modules/... [OK]
Copying vendor/virgil/crypto-wrapper/_extensions/bin/lin/php7.2/virgil_crypto.ini file to the /etc/php7/conf.d/virgil_crypto.ini... [OK]
Copying vendor/virgil/crypto-wrapper/_extensions/bin/lin/php7.2/virgil_crypto.ini file to the /etc/php7/conf.d/virgil_crypto.ini... [OK]
----------
STATUS: Restart your webserver (or php-service if available)
Ensure that vscf_foundation_php, vscp_pythia_php, vsce_phe_php extensions is present in command output after composer install
php -m
Get Virgil Credentials
If you don't have an account yet, sign up for one using your e-mail.
To generate a JWT the following values are required:
Variable Name
Description
APP_KEY
Private key of your API key that is used to sign the JWTs.
APP_KEY_ID
ID of your API key. A unique string value that identifies your account in the Virgil Cloud.
APP_ID
ID of your Virgil Application.
Add Virgil Credentials to the .env
create a .env file from the .env.example and fill it with your account credentials
Configure and Run Server
Make sure that ./app/public/ is a public-accessible directory with a index.php file. Also, you need to make a front-controller and rewrite all requests to the index.php file.
More info on how to configure and run a Apache/nginx/hhvm server can be found here.
Specification
/authenticate endpoint
This endpoint is an example of users authentication. It takes user identity and responds with unique token.
This endpoint checks whether a user is authorized by an authorization header. It takes user's authToken, finds related user identity and generates a virgilToken (which is JSON Web Token) with this identity in a payload. Use this token to make authorized api calls to Virgil Cloud.