Skip to content
This repository has been archived by the owner on Jul 12, 2022. It is now read-only.

Commit

Permalink
Merge pull request #1 from herpaderpaldent/develop
Browse files Browse the repository at this point in the history
Start SeAT
  • Loading branch information
herpaderpaldent authored Apr 6, 2018
2 parents ab1178a + a1f1255 commit b7dca50
Show file tree
Hide file tree
Showing 17 changed files with 231 additions and 802 deletions.
10 changes: 0 additions & 10 deletions .gitattributes

This file was deleted.

5 changes: 0 additions & 5 deletions .gitignore

This file was deleted.

44 changes: 0 additions & 44 deletions .travis.yml

This file was deleted.

1 change: 0 additions & 1 deletion VERSION

This file was deleted.

24 changes: 14 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,48 +1,52 @@
{
"name": "spinen/laravel-discourse-sso",
"description": "Integrate Discourse SSO into Laravel.",
"name": "herpaderpaldent/seat-discourse",
"description": "Integrate Discourse SSO and API into SeAT.",
"keywords": [
"discourse",
"laravel",
"library",
"single sign on",
"spinen",
"sso"
"sso",
"seat"
],
"type":"seat-plugin",
"license": "MIT",
"authors": [
{
"name": "Jimmy Puckett",
"email": "[email protected]"
"name": "Felix Huber",
"email": "[email protected]"
}
],
"require": {
"php": ">=5.5.9",
"cviebrock/discourse-php": "^0.9.3",
"illuminate/routing": "5.2.*|5.3.*|5.4.*|5.5.*",
"illuminate/support": "5.2.*|5.3.*|5.4.*|5.5.*"
"illuminate/support": "5.2.*|5.3.*|5.4.*|5.5.*",
"richp10/discourse-api-php": "^1.2"
},
"require-dev": {
"mockery/mockery": "^0.9.1",
"phpunit/phpunit": "~4.0|~5.0",
"psy/psysh": "^0.5.1",
"satooshi/php-coveralls": "^0.6.1|^1",
"symfony/var-dumper": "~2.7|~3.0"
"symfony/var-dumper": "~2.7|~3.0",
"richp10/discourse-api-php": "^1.2"
},
"autoload": {
"psr-4": {
"Spinen\\Discourse\\": "src"
"Herpaderpaldent\\Seat\\SeatDiscourse\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Spinen\\Discourse\\": "tests"
"Herpaderpaldent\\Seat\\SeatDiscourse\\": "src/"
}
},
"extra": {
"laravel": {
"providers": [
"Spinen\\Discourse\\SsoServiceProvider"
"Herpaderpaldent\\Seat\\SeatDiscourse\\SeatDiscourseServiceProvider"
]
}
},
Expand Down
25 changes: 0 additions & 25 deletions gulpfile.js

This file was deleted.

5 changes: 0 additions & 5 deletions nitpick.json

This file was deleted.

58 changes: 0 additions & 58 deletions phpunit.xml.dist

This file was deleted.

130 changes: 9 additions & 121 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,141 +1,29 @@
# SPINEN's Discourse SSO for Laravel
# Hepraderp Aldent's - SeAT Discourse

[![Latest Stable Version](https://poser.pugx.org/spinen/laravel-discourse-sso/v/stable)](https://packagist.org/packages/spinen/laravel-discourse-sso)
[![Total Downloads](https://poser.pugx.org/spinen/laravel-discourse-sso/downloads)](https://packagist.org/packages/spinen/laravel-discourse-sso)
[![Latest Unstable Version](https://poser.pugx.org/spinen/laravel-discourse-sso/v/unstable)](https://packagist.org/packages/spinen/laravel-discourse-sso)
[![Dependency Status](https://www.versioneye.com/php/spinen:laravel-discourse-sso/0.1.1/badge.svg)](https://www.versioneye.com/php/spinen:laravel-discourse-sso/0.1.1)
[![License](https://poser.pugx.org/spinen/laravel-discourse-sso/license)](https://packagist.org/packages/spinen/laravel-discourse-sso)

[Discourse](https://www.discourse.org) is a great online forum software that supports Single Sign On ([SSO](https://meta.discourse.org/t/official-single-sign-on-for-discourse/13045)). There is a great PHP library that handles all of the heavy lifting to make the SSO work called [cviebrock/discourse-php](https://github.com/cviebrock/discourse-php), which this package uses. This package is loosely based on the work done by [jaewun/discourse-sso-laravel](https://github.com/jaewun/discourse-sso-laravel).

## Build Status

| Branch | Status | Coverage | Code Quality |
| ------ | :----: | :------: | :----------: |
| Develop | [![Build Status](https://travis-ci.org/spinen/laravel-discourse-sso.svg?branch=develop)](https://travis-ci.org/spinen/laravel-discourse-sso) | [![Coverage Status](https://coveralls.io/repos/spinen/laravel-discourse-sso/badge.svg?branch=develop&service=github)](https://coveralls.io/github/spinen/laravel-discourse-sso?branch=develop) | [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/spinen/laravel-discourse-sso/badges/quality-score.png?b=develop)](https://scrutinizer-ci.com/g/spinen/laravel-discourse-sso/?branch=develop) |
| Master | [![Build Status](https://travis-ci.org/spinen/laravel-discourse-sso.svg?branch=master)](https://travis-ci.org/spinen/laravel-discourse-sso) | [![Coverage Status](https://coveralls.io/repos/spinen/laravel-discourse-sso/badge.svg?branch=master&service=github)](https://coveralls.io/github/spinen/laravel-discourse-sso?branch=master) | [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/spinen/laravel-discourse-sso/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/spinen/laravel-discourse-sso/?branch=master) |
This SeAT-Package is based upon [SPINEN's Discourse SSO for Laravel](https://github.com/spinen/laravel-discourse-sso).
Extendend with [richp10/discourse-api-php](https://github.com/richp10/discourse-api-php) to be able to create users and
topics based on roles in SeAT.

## Prerequisite

Aside from Laravel >= 5.2, there is 1 package that is required. NOTE: There are limitations in the way that 5.1 deals with collections, so I am taking the easy way & just not supporting it. If you need this in 5.1, then please make a merge request on the `SsoController`.
There are two dependencies.

* ["cviebrock/discourse-php": "^0.9.3",](https://github.com/cviebrock/discourse-php)
* ["cviebrock/discourse-php": "^0.9.3"](https://github.com/cviebrock/discourse-php)
* ["richp10/discourse-api-php": "^1.2"](https://github.com/richp10/discourse-api-php)

## Install

Install Discourse SSO for Laravel:

```bash
$ composer require spinen/laravel-discourse-sso
$ composer require herpaderpaldent/seat-discourse
```

### For >= Laravel 5.5, you are done with the Install
### For SeAT 3.0, you are done with the Install

The package uses the auto registration feature

### For < Laravel 5.5, you have to register the Service Provider

Add the Service Provider to `config/app.php`:

```php
'providers' => [
// ...
Spinen\Discourse\SsoServiceProvider::class,
];
```

## Configuration

All of the configuration values are stored in under a `discourse` key in `config/services.php`. Here is the array to add...

```php
'discourse' => [
// The route's URI that acts as the entrypoint for Discourse to start the SSO process.
// Used by Discourse to route incoming logins.
'route' => 'discourse/sso',

// Secret string used to encrypt/decrypt SSO information,
// be sure that it is 10 chars or longer
'secret' => env('DISCOURSE_SECRET'),

// Disable Discourse from sending welcome message
'suppress_welcome_message' => 'true',

// Where the Discourse form lives
'url' => env('DISCOURSE_URL'),

// User specific items
// NOTE: The 'email' & 'external_id' are the only 2 required fields
'user' => [
// Check to see if the user has forum access & should be logged in via SSO
'access' => null,

// Groups to make sure that the user is part of in a comma-separated string
// NOTE: Groups cannot have spaces in their names & must already exist in Discourse
'add_groups' => null,

// Boolean for user a Discourse admin, leave null to ignore
'admin' => null,

// Full path to user's avatar image
'avatar_url' => null,

// The avatar is cached, so this triggers an update
'avatar_force_update' => false,

// Content of the user's bio
'bio' => null,

// Verified email address (see "require_activation" if not verified)
'email' => 'email',

// Unique string to the user that will never change
'external_id' => 'id',

// Boolean for user a Discourse admin, leave null to ignore
'moderator' => null,

// Full name on Discourse if the user is new or
// if SiteSetting.sso_overrides_name is set
'name' => 'name',

// Groups to make sure that the user is *NOT* part of in a comma-separated string
// NOTE: Groups cannot have spaces in their names & must already exist in Discourse
// There is not a way to specify the exact list of groups that a user is in, so
// you may want to send the inverse of the 'add_groups'
'remove_groups' => null,

// If the email has not been verified, set this to true
'require_activation' => false,

// username on Discourse if the user is new or
// if SiteSetting.sso_overrides_username is set
'username' => 'email',
],
],
```

The value of the properties for the `user` property can be one of 4 values...

1. `false` -- passed as set to Discourse
2. `true` -- passed as set to Discourse
3. `null` -- disables sending property to Discourse
4. a `string` -- name of a property on the `User` model

You can then add logic to the `User` model inside of [Accessors](https://laravel.com/docs/master/eloquent-mutators#defining-an-accessor) to provide the values for the properties configured for the user. For example, if you wanted any user with an email address that matched "yourdomain.tld" to be a moderator, then you could set the `moderator` property to a string like `discourse_moderator` and add the following to your `User` model...

```php
/**
* Is the user a Discourse moderator.
*
* @param string $value
* @return boolean
*/
public function getDiscourseModeratorAttribute($value)
{
return ends_with($this->email, "yourdomain.tld");
}
```

## Left to do

Expand Down
28 changes: 28 additions & 0 deletions src/Commands/SyncRolesWithDiscourse.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
/**
* Created by PhpStorm.
* * User: Herpaderp Aldent
* Date: 05.04.2018
* Time: 19:09
*/

namespace Herpaderpaldent\Seat\SeatDiscourse\Commands;


use Illuminate\Console\Command;

class SyncRolesWithDiscourse extends Command
{
protected $signature = 'seat-groups:users:update';
protected $description = 'This command creates Discourse Groups according to the Roles in SeAT';

public function __construct()
{
parent::__construct();
}

public function handle()
{

}
}
Loading

0 comments on commit b7dca50

Please sign in to comment.