PHPackages                             cviebrock/discourse-php - 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. cviebrock/discourse-php

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

cviebrock/discourse-php
=======================

Helper class for building a single sign-on source for Discourse forums

0.9.3(8y ago)66502.3k↑30.2%99MITPHPPHP &gt;=5.3.0

Since Jan 20Pushed 8y ago5 watchersCompare

[ Source](https://github.com/cviebrock/discourse-php)[ Packagist](https://packagist.org/packages/cviebrock/discourse-php)[ Docs](https://github.com/cviebrock/discourse-php)[ RSS](/packages/cviebrock-discourse-php/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (5)Used By (9)

Discourse Single-Sign-On Helper for PHP
=======================================

[](#discourse-single-sign-on-helper-for-php)

This is a small class to help with providing an SSO source for Discourse forums. It provides 3 helper functions for validating incoming requests, extracting nonce, and building the returning query string.

For more information on the SSO settings in Discourse, visit

> Original code from Johan Jatko: [https://github.com/ArmedGuy/discourse\_sso\_php](https://github.com/ArmedGuy/discourse_sso_php)

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

[](#installation)

The package is registered at Packagist as [cviebrock/discourse-php](https://packagist.org/packages/cviebrock/discourse-php) and can be installed using [composer](http://getcomposer.org/):

```
composer require "cviebrock/discourse-php"

```

Usage
-----

[](#usage)

```
$sso = new Cviebrock\DiscoursePHP\SSOHelper();

// this should be the same in your code and in your Discourse settings:
$secret = 'super_secret_sso_key';
$sso->setSecret( $secret );

// load the payload passed in by Discourse
$payload = $_GET['sso'];
$signature = $_GET['sig'];

// validate the payload
if (!($sso->validatePayload($payload,$signature))) {
    // invaild, deny
    header("HTTP/1.1 403 Forbidden");
    echo("Bad SSO request");
    die();
}

$nonce = $sso->getNonce($payload);

// Insert your user authentication code here ...

// Required and must be unique to your application
$userId = '...';

// Required and must be consistent with your application
$userEmail = '...';

// Optional - if you don't set these, Discourse will generate suggestions
// based on the email address

$extraParameters = array(
    'username' => $userUsername,
    'name'     => $userFullName
);

// build query string and redirect back to the Discourse site
$query = $sso->getSignInString($nonce, $userId, $userEmail, $extraParameters);
header('Location: http://discourse.example.com/session/sso_login?' . $query);
exit(0);
```

Bugs, Suggestions and Contributions
-----------------------------------

[](#bugs-suggestions-and-contributions)

Please use Github for bugs, comments, suggestions.

1. Fork the project.
2. Create your bugfix/feature branch and write your (well-commented) code.
3. Commit your changes and push to your repository.
4. Create a new pull request against this project's `master` branch.

Copyright and License
---------------------

[](#copyright-and-license)

**discourse-php** was written by Colin Viebrock and released under the MIT License. See the LICENSE file for details.

Copyright 2015 Colin Viebrock

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity50

Moderate usage in the ecosystem

Community27

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~299 days

Total

4

Last Release

3237d ago

### Community

Maintainers

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

---

Top Contributors

[![ArmedGuy](https://avatars.githubusercontent.com/u/3276817?v=4)](https://github.com/ArmedGuy "ArmedGuy (16 commits)")[![dillchuk](https://avatars.githubusercontent.com/u/11740626?v=4)](https://github.com/dillchuk "dillchuk (6 commits)")[![cviebrock](https://avatars.githubusercontent.com/u/166810?v=4)](https://github.com/cviebrock "cviebrock (4 commits)")[![adamcapriola](https://avatars.githubusercontent.com/u/279928?v=4)](https://github.com/adamcapriola "adamcapriola (3 commits)")[![riking](https://avatars.githubusercontent.com/u/627891?v=4)](https://github.com/riking "riking (2 commits)")[![jimmypuckett](https://avatars.githubusercontent.com/u/3220069?v=4)](https://github.com/jimmypuckett "jimmypuckett (1 commits)")[![martinduparc](https://avatars.githubusercontent.com/u/839534?v=4)](https://github.com/martinduparc "martinduparc (1 commits)")

---

Tags

forumdiscourse

### Embed Badge

![Health badge](/badges/cviebrock-discourse-php/health.svg)

```
[![Health](https://phpackages.com/badges/cviebrock-discourse-php/health.svg)](https://phpackages.com/packages/cviebrock-discourse-php)
```

###  Alternatives

[gesdinet/jwt-refresh-token-bundle

Implements a refresh token system over Json Web Tokens in Symfony

70516.4M35](/packages/gesdinet-jwt-refresh-token-bundle)[illuminate/auth

The Illuminate Auth package.

9327.3M1.0k](/packages/illuminate-auth)[beatswitch/lock

A flexible, driver based Acl package for PHP 5.4+

870304.7k2](/packages/beatswitch-lock)[discourse/wp-discourse

WordPress plugin that allows you to use Discourse as a community engine for your WordPress blog.

5419.5k](/packages/discourse-wp-discourse)[amocrm/amocrm-api-library

amoCRM API Client

182728.5k6](/packages/amocrm-amocrm-api-library)[spinen/laravel-discourse-sso

Integrate Discourse SSO into Laravel.

4897.8k](/packages/spinen-laravel-discourse-sso)

PHPackages © 2026

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