PHPackages                             vatsim/sso - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. vatsim/sso

Abandoned → [vatsim/oauth2-vatsim](/?search=vatsim%2Foauth2-vatsim)ArchivedLibrary[Authentication &amp; Authorization](/categories/authentication)

vatsim/sso
==========

VATSIM OAuth

3.0(9y ago)1622.2k—7.1%13[4 issues](https://github.com/KHardern/VatsimSSO/issues)2MITPHPPHP &gt;=5.4.0

Since Jun 23Pushed 8y ago5 watchersCompare

[ Source](https://github.com/KHardern/VatsimSSO)[ Packagist](https://packagist.org/packages/vatsim/sso)[ RSS](/packages/vatsim-sso/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (6)Used By (2)

VatsimSSO
=========

[](#vatsimsso)

**Laravel 4 compatible, use [version 2](https://github.com/KHardern/VatsimSSO/tree/develop) for Laravel 5**

The VatsimSSO package integrates with the VATSIM.net Single Sign On, which lets your users log themselves in using their VATSIM ID. This is especially useful for official vACCs and ARTCCs.

Version
-------

[](#version)

1.0

Installation
------------

[](#installation)

Use [Composer](http://getcomposer.org) to install the VatsimSSO and dependencies.

```
$ composer require vatsim/sso 1.*
```

### Laravel

[](#laravel)

#### Set up

[](#set-up)

Using VatsimSSO in Laravel is made easy through the use of Service Providers. Add the service provider to your `app/config/app.php` file:

```
'providers' => array(
    // ...
    'Vatsim\OAuth\OAuthServiceProvider',
),
```

Followed by the alias:

```
'aliases' => array(
    // ...
    'VatsimSSO'       => 'Vatsim\OAuth\Facades\SSO',
),
```

#### Configuration file

[](#configuration-file)

Use artisan to publish the configuration file. After running the command you will find the file in `app/config/packages/vatsim/sso/config.php`. Change the settings accordingly.

```
$ artisan config:publish vatsim/sso
```

### Outside Laravel

[](#outside-laravel)

Let's first create a configuration file to keep our code clean.

```
/*
 * 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';
```

Now, let's initialise the SSO class.

```
// load the Composer autoload file, which automatically
// loads all the classes required for use by VatsimSSO.
require 'vendor/autoload.php';
require 'config.php';

use Vatsim\OAuth\SSO;

$sso = new SSO($base, $key, $secret, $method, $cert);
```

Usage
-----

[](#usage)

### Logging In

[](#logging-in)

The first step would be to send a request to VATSIM to let the user login. The easiest approach would be using the `login` function. The function takes three parameters.

#### Parameters

[](#parameters)

ParameterTypeDescription`$returnUrl`string | arrayThe URL to which the user should be redirected after the login is successful`$success`string | ClosureCallback function containing the actions needed to be done when you are able to let the user authenticate (ie. when your key/secret are correct). The function will return three variables: `$key`, `$secret` and `$url`.*`$error`*string | Closure*Default: null* – Callback function containing the actions needed to be done when your credentials (ie. key/secret) are incorrect.For both `$success` and `$error`, you may pass a string in `[class]@[method]` format to call a function in another Model, otherwise pass an anonymous function.

#### Return URL

[](#return-url)

The return URL parameter will also take an array instead of a string. In this array you can add the values `suspended` and/or `inactive` to allow members with suspended or inactive accounts to log in. The first element of this array that is a valid URL will be used as the return URL.

#### Success

[](#success)

The success parameter returns three variables: `$key`, `$secret` and `$url`. The `key` and `secret` should be stored in a session for the validation process. The `url` will be used to redirect the user to the VATSIM SSO site.

#### Error

[](#error)

Optional parameter. If this parameter is ignored and an error occurs, the function will return `false`. If you pass a function then one parameter will be returned `$error`, which is an array of data related to the last error.

#### Example

[](#example)

```
// Laravel
return VatsimSSO::login(
    Config::get('vatsimsso:return'),
    function($key, $secret, $url) {
        Session::put('vatsimauth', compact('key', 'secret'));
        return Redirect::to($url);
    },
    function($error) {
        throw new Exception('Could not authenticate: ' . $error['message']);
    }
);

// Outside Laravel
$sso->login(
    $return,
    function($key, $secret, $url) {
        $_SESSION['vatsimauth'] = compact('key', 'secret');
        header('Location: ' . $url);
        die();
    }
);
```

If you prefer not to use the `->login()` function, you may use `->requestToken($returnUrl)`. This will return an object containing the `key` and `secret` or returns `false` if an error occurs, at that point you can use `->error()` to get the array of the last occured error. Then use `->sendToVatsim()` to get the URL for the redirect.

### Validating login

[](#validating-login)

After the login has been successful, we need to get the user data from VATSIM. Also for this we wrote a function to make it easier for you.

#### Parameters

[](#parameters-1)

ParameterTypeDescription`$key`stringThe `key` stored in the session at login`$secret`stringThe `secret` stored in the session at login`$verifier`stringThe `oauth_verifier` passed in the query string`$success`string | ClosureCallback function containing the actions needed to be done when the login has been successful.*`$error`*string | Closure*Default: null* – Callback function containing the actions needed to be done when authentication was unsuccessful (could be because of wrong key/secret/verifier)For both `$success` and `$error`, you may pass a string in `[class]@[method]` format to call a function in another Model, otherwise pass an anonymous function.

#### Success

[](#success-1)

The success parameter returns two variables: `$user` and `$request`. The `user` variable will be an object containing all user data available to your organisation. The `request` variable will give you information about the request.

#### Error

[](#error-1)

Optional parameter. If this parameter is ignored and an error occurs, the function will return `false`. If you pass a function then one parameter will be returned `$error`, which is an array of data related to the last error.

#### Example

[](#example-1)

```
// 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();
    }
);
```

If you prefer not to use the `->validate()` function, you may use `->checkLogin($key, $secret, $verifier)`. This will return an object containing the `user` and `request` objects or returns `false` if an error occurs, at that point you can use `->error()` to get the array of the last occured error.

License
-------

[](#license)

MIT

**Free Software, Hell Yeah!**

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance15

Infrequent updates — may be unmaintained

Popularity36

Limited adoption so far

Community23

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 64.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~325 days

Total

4

Last Release

3372d ago

Major Versions

1.0.1 → 2.02015-02-22

2.0 → 3.02017-02-22

### Community

Maintainers

![](https://www.gravatar.com/avatar/cc3e3c710c175f1874c9c2c541fe4d57e4eb50242bca29392f5a78f579d94d37?d=identicon)[vatsimnetwork](/maintainers/vatsimnetwork)

![](https://www.gravatar.com/avatar/fecd9ec8ce6ae387c36290f1730ea834b95f474baea0d1d8a8be7e986ccc45d4?d=identicon)[bonroyage](/maintainers/bonroyage)

![](https://www.gravatar.com/avatar/80737e5f294400fc32f4d19ad511a7b2cea5805d2208e6d612de6b5510011f9a?d=identicon)[KHardern](/maintainers/KHardern)

---

Top Contributors

[![bonroyage](https://avatars.githubusercontent.com/u/4411748?v=4)](https://github.com/bonroyage "bonroyage (11 commits)")[![KHardern](https://avatars.githubusercontent.com/u/6871785?v=4)](https://github.com/KHardern "KHardern (5 commits)")[![colinschoen](https://avatars.githubusercontent.com/u/2927722?v=4)](https://github.com/colinschoen "colinschoen (1 commits)")

---

Tags

SSOoauthvatsim

### Embed Badge

![Health badge](/badges/vatsim-sso/health.svg)

```
[![Health](https://phpackages.com/badges/vatsim-sso/health.svg)](https://phpackages.com/packages/vatsim-sso)
```

###  Alternatives

[league/oauth2-client

OAuth 2.0 Client Library

3.8k118.6M1.2k](/packages/league-oauth2-client)[league/oauth1-client

OAuth 1.0 Client Library

99698.8M106](/packages/league-oauth1-client)[thenetworg/oauth2-azure

Azure Active Directory OAuth 2.0 Client Provider for The PHP League OAuth2-Client

2509.6M48](/packages/thenetworg-oauth2-azure)[adam-paterson/oauth2-stripe

Stripe OAuth 2.0 Client Provider for The PHP League OAuth2-Client

172.4M4](/packages/adam-paterson-oauth2-stripe)[adam-paterson/oauth2-slack

Slack OAuth 2.0 Client Provider for The PHP League OAuth2-Client

22694.8k5](/packages/adam-paterson-oauth2-slack)[authlete/authlete-laravel

Authlete Library for Laravel

4226.0k](/packages/authlete-authlete-laravel)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
