Skip to content
X-Ryl669 edited this page Dec 19, 2016 · 1 revision

Integrating kutr in any CMS should be possible, provided you follow these rules:

  1. kutr must run with its own subdomain (this is a restriction with Laravel, and I have not removed it)
  2. You have access to the source code for your CMS and the API for login and logout are documented

Then, in that case, you'll have to do:

  1. Copy the file cms_login.php.example to cms_login.php in the root dir of your CMS.
  2. If you look into that file, you'll find it's structured in 3 parts, authenticating with your CMS, making a token and redirecting to kutr.

The first part, if specific to your CMS. That's the lines:

// Require your CMS bootstrap code here
require_once("yourCMSbootstrap.php");
// Bootstrap your CMS and check the session is valid (if not your CMS will fallback the login screen)
checkSession();

// The basic idea being to match the user name in your CMS with the user name in Kotr's DB, you must have 1:1 user name in both
$login = getCurrentUserLogin();

Usually, the require_once is explained in the documentation of your CMS in the section "bootstrapping". Typically, this calls the class autoloader, and all the other stuff required for your CMS basic functions to work.

The function checkSession() is valid for my CMS, but you'll need to adapt to yours. Typically, this is where the CMS checks the session (cookie, token, whatever) for the current user is valid, and if not redirect to the login page.

The function getCurrentUserLogin() must return the name of the current user logged-in. You must have a 1:1 mapping between this name in your CMS and the account's name in kutr. Please notice that we don't care about the password in kutr's database

That's for the first part.

Then, the second part is not that hard:

// Should be the same as the one set in .env file in the REMOTE_AUTH_SECRET key
$secret = "<your secret here>";

The comment says it all, you'll need to write here the secret you've chose (whatever you want, but must be the same in both this file and the content of the REMOTE_AUTH_SECRET variable in your .env file.

The last part you need to modify is the redirection URL:

header("Location: ".$https."music.yourserver.net/loginRedir.php?token=".makeToken());

Obviously, you need to change "music.yourserver.net" to the subdomain of the Kutr's installation.

When you've done this, you're 99% done, you just need to add a link in your CMS to this file, that is, you need to add somewhere in your CMS's rendered output a <a href='cms_login.php'>Music</a> and you're done, it should work for login.

Logout is even simpler, you need to figure out what is the logout URL for your CMS, and write this URL in the .env file.

Clone this wiki locally