Creating a luna plugin

Avatar

By pixelogy 9 March 2016 11:13

Member · 14 comments

Hey there,

Is there any "guide" or anything similar on how to verify the login of a specific user? I want to create a plugin for my server that needs to connect to the luna database and check whether the login data is the same as on the forum. I already checked the database entries but it seems that the password is encrypted in some kind of way.

Regards
Pixelogy

Avatar

By Yannick 9 March 2016 12:04

Administrator · 1,387 comments

I currently do not have such a guide.


You can do anything

Avatar

By pixelogy 9 March 2016 13:52

Member · 14 comments

I solved this by adding another action to extern.php, based on the code of login.php:

-- Snipped --

Not sure if this is useful for people working with luna, but i felt like it should be better to share.
This allows to check if the specified login data is valid. To use it, one calls the url:
[yourboardbaseurl]?action=authenticate&username=[yourusername]&password=[yourpassword]

Avatar

By Yannick 9 March 2016 14:53

Administrator · 1,387 comments

Wait, wait, wait. Never - EVER - put your password in an URL, even if hashed. SHA-1 is, sadly, a very bad encryption (which is why it is being dropped in Luna 1.4), making it visible like that is even worse than the situation already is.


You can do anything

Avatar

By pixelogy 9 March 2016 16:24

Member · 14 comments
Yannick wrote

Wait, wait, wait. Never - EVER - put your password in an URL, even if hashed. SHA-1 is, sadly, a very bad encryption (which is why it is being dropped in Luna 1.4), making it visible like that is even worse than the situation already is.

I understand. Is there any other way i can authenticate users though?

Avatar

By Yannick 9 March 2016 21:11

Administrator · 1,387 comments

I'm not sure what you're trying to achieve here: does it need to use the Luna UI or is it an external page. In case it's the later, I think including the following should be enough to authenticate:

define('LUNA_ROOT', dirname(__FILE__).'/');
require LUNA_ROOT.'include/common.php';

Make sure to correctly define the path to the Luna root. If you want to use the Luna UI (so basically, something similar to the Help-page: a full empty page to fill up with your own content, you can use the following:

define('LUNA_ROOT', dirname(__FILE__).'/');
require LUNA_ROOT.'include/common.php';

if ($luna_user['g_read_board'] == '0')
	message(__('You do not have permission to view this page.', 'luna'), false, '403 Forbidden');

$page_title = 'This is the page title';
define('LUNA_ACTIVE_PAGE', 'page');
require load_page('header.php');

<here goes the content you want to add>

require load_page('footer.php');

Again, make sure to define the Luna-root. And add a page title, obviously. 😁

Also, I'm stripping the code from your previous comment due to security issues in that code, it's not something I would want anyone to use.


You can do anything

Avatar

By pixelogy 10 March 2016 17:22

Member · 14 comments
Yannick wrote

I'm not sure what you're trying to achieve here: does it need to use the Luna UI or is it an external page

I am trying to authenticate a user of the luna forum with a java application. I am not very experienced in php and im sorry for any problem i caused with my code snippet above.

Avatar

By Yannick 10 March 2016 17:43

Administrator · 1,387 comments
pixelogy wrote
Yannick wrote

I'm not sure what you're trying to achieve here: does it need to use the Luna UI or is it an external page

I am trying to authenticate a user of the luna forum with a java application. I am not very experienced in php and im sorry for any problem i caused with my code snippet above.

You're not causing a problem, it just isn't really save to have it on here if people don't read further in the thread. 😁


You can do anything