Giter Club home page Giter Club logo

flarum-ext-sso's Introduction

DEPRECATED - Flarum Single Sign On

(no longer actively maintained)

This extension equips Flarum with Single Sign On. The workflow is based on this post. The extension is useful if you run Flarum on a subdomain but you want to use the login mechanism of your main website. A dummy main website is provided in the sample-website/ folder.

Installation

  1. Create a random token and put it into the api_keys table of your Flarum database.

  2. Go into sample-website folder and copy config.php.dist to config.php:

cd sample-website/
cp config.php.dist config.php
  1. Open config.php with an editor of your choice and configure all settings.

  2. Upload the Forum.php class and config.php to your main website and setup the Forum.php class. An example is given in index.php / logout.php.

  3. Install and activate the extension. Fill in redirect urls for login, signup and logout.

composer require wuethrich44/flarum-ext-sso
  1. Now you should able to log in with your existing users.

Wordpress

This extension comes with a Wordpress plugin which allows you to login into Wordpress and gain also access to your Flarum forum. In order to install the plugin execute the following steps:

  1. Upload the sample-website folder into the plugin folder (/wp-content/plugins/) of your wordpress instance.

  2. Rename it to a name of your choice (e.g. flarum-sso).

  3. Copy config.php.dist to config.php and configure all settings.

  4. Activate the plugin in the settings.

  5. Install and activate the Flarum extension.

composer require wuethrich44/flarum-ext-sso
  1. Fill in the correct urls according to your wordpress instance:

    Login-Url: http://example.com/wp-login.php?redirect_to=forum

    (The redirect_to=forum part is important as it will redirect your users back to the forum)

    Logout-Url: http://example.com/wp-login.php?action=logout

    Signup-Url: Depending on which plugin you use.

  2. That's it!

flarum-ext-sso's People

Contributors

fabwu avatar glombers avatar sampoyigi avatar zinsserzh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

flarum-ext-sso's Issues

Hello there, can not seem to get this working

Hello there. I wanted to post this here in hopes that you might see it, as it looks like you have not posted on Flarum forums since November. Here is what I had said.

"Hey there, I am unable to get this to work unfortunately. When I sign up, it creates the user in WP, when I login it takes me to the WP user page. If I go to my forum and login, it takes me to the WP page, I login, it then finally takes me back to the forum but I am not logged in, it just has the sign up or login button again and continues to do so. If I go to WP it shows me as logged in there it just is not transferring over to Flarum for some reason.

I, of course, have the api_key and what not in the db and did everything that was shown in the instructions.

I have these in the access log, but nothing I am seeing wrong in the error log

[12/Feb/2018:22:33:45 +0000] "GET /wp-login.php?redirect_to=forum HTTP/1.1" 200 1600 "https://changed_for_security/forum/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:58.0) Gecko/20100101 Firefox/58.0"
[12/Feb/2018:22:33:48 +0000] "POST /forum/api/token HTTP/1.1" 401 3399 "-" "-"
[12/Feb/2018:22:33:48 +0000] "POST /forum/api/users HTTP/1.1" 422 3500 "-" "-"
[12/Feb/2018:22:33:48 +0000] "POST /forum/api/token HTTP/1.1" 401 3399 "-" "-"

Also, nothing related in the actual Flarum logs, it just simply isn't doing anything it seems.

My WP is in domain.com and forum is domain.com/forum if that makes any sort of difference. Everything else is working fine for both, just not logging in to the forum now.

I am assuming the random key I made up and put into the api_key in the db then goes into the config, and then I just type a random key into password token? I figured I would try it with nothing written in the api_key or password key fields and it acts the exact same was as when I do have the key in there and there are no errors or anything still."

Using existing user password.

Hi Guys,

Just want to share a bit knowledge here to save time.

Recently I got a project to migrate forum from PHPBB to Flarum. And the existing users and their password needs to be reusable.

But when you are trying to use Forum class->login($username, $email) function from this repository, Flarum system API may not return the token for your system. Instead, it will show message "Permission denied".
For example , there was a username called "Jack", and his previous password in PHPBB was "123".
When you use login('Jack', '[email protected]'), then the permission error will show.

However, you may need to pass in the password within login() from your primary website database. To be able to do that, you will need to adjust your code to do it.

For example in login.php :
$old_password = "123";
$forum = new Forum();
$forum->login($username, $email, $old_password );

Then in Forum.php:
public function login($username, $email, $password = '')
{
if($password == "" ){
$password = $this->createPassword($username);
}
$token = $this->getToken($username, $password);
if (empty($token)) {
$this->signup($username, $password, $email);
$token = $this->getToken($username, $password);
}
$this->setRememberMeCookie($token);
return true;
}

Hopefully this will help someone in future.

Kind regards

Reply to thread when not logged in

if you try to reply to a thread when not logged in, the default Flarum Login/Registration Popup is shown instead of a redirect to the SSO Login Page.

SSO between sudomains

Hi,
I have an SSO system on the account subdomain (for example account.example.com) and a Flarum installation on the community subdomain (community.example.com). This setup doesn't seem to work. Could you please add this feature?
Also, as you can see here a lot of people need your help!
Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.