1. Go to this page and download the library: Download vatsim/sso library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
/*
* DO NOT PUBLISH THE KEY, SECRET AND CERT TO CODE REPOSITORIES
* FOR SECURITY.
*/
/*
* The location of the VATSIM OAuth interface
*/
$base = 'https://';
/*
* The consumer key for your organisation (provided by VATSIM)
*/
$key = 'MY_KEY';
/*
* The secret key for your organisation (provided by VATSIM)
* Do not give this to anyone else or display it to your users. It must be kept server-side
*/
$secret = 'my_secret';
/*
* The signing method you are using to encrypt your request signature.
* Different options must be enabled on your account at VATSIM.
* Options: RSA / HMAC
*/
$method = 'HMAC';
/*
* Your RSA **PRIVATE** key
* If you are not using RSA, this value can be anything (or not set)
*/
$cert = '';
/*
* The URL users will be redirected to after they log in, this should
* be on the same server as the request
*/
$return = 'http://example.com/valiatelogin';
// load the Composer autoload file, which automatically
// loads all the classes o = new SSO($base, $key, $secret, $method, $cert);
// Laravel
$session = Session::get('vatsimauth');
return VatsimSSO::validate(
$session['key'],
$session['secret'],
Input::get('oauth_verifier'),
function($user, $request) {
// At this point we can remove the session data.
Session::forget('vatsimauth');
Auth::loginUsingId($user->id);
return Redirect::home();
},
function($error) {
throw new Exception('Could not authenticate: ' . $error['message']);
}
);
// Outside Laravel
$session = $_SESSION['vatsimauth'];
$sso->validate(
$session['key'],
$session['secret'],
$_GET['oauth_verifier'],
function($user, $request) {
// At this point we can remove the session data.
unset($_SESSION['vatsimauth']);
// do something to log the user in on your site using the user id
// $user->id
// Redirect home
header('Location: /');
die();
}
);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.