[GH-ISSUE #7] unable to login to nsedit #1

Closed
opened 2026-02-28 01:20:30 +03:00 by kerem · 14 comments
Owner

Originally created by @rpenugonda on GitHub (Oct 21, 2014).
Original GitHub issue: https://github.com/tuxis-ie/nsedit/issues/7

Hi installed nsedit and tried to login with admin/admin and never gets authenticated.

PHP Notice: Use of undefined constant CSRF_TOKEN - assumed 'CSRF_TOKEN' in /home/rpenugonda/nsedit/index.php on line 125

Also i am able to see the user in the DB itself
sqlite> select * from users;
1|admin|$6$41f03d9acdc52ee6$nSYlWjbZ1MXO.9j//.Mz4RJTB.uS51k4FTlVzvsE3jFTFtncxKIdCKWlZcHJdkCv4Dhuzto9e7zdSD7CFM1u20|1

Originally created by @rpenugonda on GitHub (Oct 21, 2014). Original GitHub issue: https://github.com/tuxis-ie/nsedit/issues/7 Hi installed nsedit and tried to login with admin/admin and never gets authenticated. PHP Notice: Use of undefined constant CSRF_TOKEN - assumed 'CSRF_TOKEN' in /home/rpenugonda/nsedit/index.php on line 125 Also i am able to see the user in the DB itself sqlite> select \* from users; 1|admin|$6$41f03d9acdc52ee6$nSYlWjbZ1MXO.9j//.Mz4RJTB.uS51k4FTlVzvsE3jFTFtncxKIdCKWlZcHJdkCv4Dhuzto9e7zdSD7CFM1u20|1
kerem closed this issue 2026-02-28 01:20:30 +03:00
Author
Owner

@tuxis-ie commented on GitHub (Oct 21, 2014):

Hi,

Did you set the $secret-value in config.inc.php? It might be that you're missing hash_pbkdf2. What happens if you unset $secret?

<!-- gh-comment-id:59997048 --> @tuxis-ie commented on GitHub (Oct 21, 2014): Hi, Did you set the $secret-value in config.inc.php? It might be that you're missing hash_pbkdf2. What happens if you unset $secret?
Author
Owner

@rpenugonda commented on GitHub (Oct 21, 2014):

i removed it (i was playing with it etc..) still the same here is my config.

###########

'Tuxis', 'owner' => 'username', # Set to 'public' to make it available to all users 'records' => array( array( 'name' => '', 'type' => 'MX', 'content' => 'mx2.tuxis.nl', 'priority' => '200') ) ); */ $defaults['soa_edit'] = 'INCEPTION-INCREMENT'; $defaults['soa_edit_api'] = 'INCEPTION-INCREMENT'; $defaults['defaulttype'] = 'Master'; # Choose between 'Native' or 'Master' $defaults['primaryns'] = 'unconfigured.primaryns'; # The value of the first NS-record $defaults['secondaryns'] = 'unconfigured.secondaryns'; # The value of the second NS-record $defaults['ttl'] = 3600; # Default TTL for records $defaults['priority'] = 0; # Default for priority in records /\* No need to change stuf below */ $defaults['defaulttype'] = ucfirst(strtolower($defaults['defaulttype'])); if (!file_exists($authdb)) { is_dir(dirname($authdb)) || mkdir(dirname($authdb)); $db = new SQLite3($authdb, SQLITE3_OPEN_CREATE|SQLITE3_OPEN_READWRITE); $createsql = file_get_contents('includes/scheme.sql'); $db->exec($createsql); $salt = bin2hex(openssl_random_pseudo_bytes(16)); $db->exec("INSERT INTO users (emailaddress, password, isadmin) VALUES ('admin', '".crypt("admin", '$6$'.$salt)."', 1)"); } ##############
<!-- gh-comment-id:59998304 --> @rpenugonda commented on GitHub (Oct 21, 2014): i removed it (i was playing with it etc..) still the same here is my config. ########### <?php /* $apiuser = 'a'; # The PowerDNS API username $apipass = 'changeme'; # The PowerDNS API-user password $apiip = '10.22.7.79'; # The IP of the PowerDNS API $apiport = '8081'; # The port of the PowerDNS API $apisid = 'localhost'; # PowerDNS's :server_id $allowzoneadd = FALSE; # Allow normal users to add zones */ #If you configure this, nsedit will try to authenticate via WeFact too. #Debtors will be added to the sqlitedatabase with their crypted password. #$wefactapiurl = 'https://yourdomain/Pro/apiv2/api.php'; #$wefactapikey = 'xyz'; #If you want external scripts to be able to execute stuff here, add the #remote-ip to $adminapiips and create a $adminapikey #$adminapiips = array(); #$adminapikey = 'thisshouldbequitealongstring,youknow'; $authdb = "../etc/pdns.users.sqlite3"; #Set a random generated secret to enable auto-login and long living csrf tokens #$secret = 'adadfksnfskjfnsfiyqweqe03nqwffdsch23enqkfs91newf9'; $templates = array(); /* $templates[] = array( 'name' => 'Tuxis', 'owner' => 'username', # Set to 'public' to make it available to all users 'records' => array( array( 'name' => '', 'type' => 'MX', 'content' => 'mx2.tuxis.nl', 'priority' => '200') ) ); */ $defaults['soa_edit'] = 'INCEPTION-INCREMENT'; $defaults['soa_edit_api'] = 'INCEPTION-INCREMENT'; $defaults['defaulttype'] = 'Master'; # Choose between 'Native' or 'Master' $defaults['primaryns'] = 'unconfigured.primaryns'; # The value of the first NS-record $defaults['secondaryns'] = 'unconfigured.secondaryns'; # The value of the second NS-record $defaults['ttl'] = 3600; # Default TTL for records $defaults['priority'] = 0; # Default for priority in records /\* No need to change stuf below */ $defaults['defaulttype'] = ucfirst(strtolower($defaults['defaulttype'])); if (!file_exists($authdb)) { is_dir(dirname($authdb)) || mkdir(dirname($authdb)); $db = new SQLite3($authdb, SQLITE3_OPEN_CREATE|SQLITE3_OPEN_READWRITE); $createsql = file_get_contents('includes/scheme.sql'); $db->exec($createsql); $salt = bin2hex(openssl_random_pseudo_bytes(16)); $db->exec("INSERT INTO users (emailaddress, password, isadmin) VALUES ('admin', '".crypt("admin", '$6$'.$salt)."', 1)"); } ##############
Author
Owner

@rpenugonda commented on GitHub (Oct 21, 2014):

I made sure the API works by using below.
curl -X PATCH --data '{ "rrsets": [ { "name": "ramesh.example.org", "type": "A", "changetype": "REPLACE", "records": [ { "content": "12.2.3.4", "name": "ramesh.example.org", "ttl": 3600, "priority": 1, "type": "A", "disabled": false} ] } ] }' -v http://a:changeme@10.22.7.79:8081/servers/localhost/zones/example.org.

<!-- gh-comment-id:59998801 --> @rpenugonda commented on GitHub (Oct 21, 2014): I made sure the API works by using below. curl -X PATCH --data '{ "rrsets": [ { "name": "ramesh.example.org", "type": "A", "changetype": "REPLACE", "records": [ { "content": "12.2.3.4", "name": "ramesh.example.org", "ttl": 3600, "priority": 1, "type": "A", "disabled": false} ] } ] }' -v http://a:changeme@10.22.7.79:8081/servers/localhost/zones/example.org.
Author
Owner

@tuxis-ie commented on GitHub (Oct 21, 2014):

Ok. Are you sure that you're not seeing any other error messages in the webserver errorlog? Which version of php on which OS are you running?

<!-- gh-comment-id:59999959 --> @tuxis-ie commented on GitHub (Oct 21, 2014): Ok. Are you sure that you're not seeing any other error messages in the webserver errorlog? Which version of php on which OS are you running?
Author
Owner

@rpenugonda commented on GitHub (Oct 21, 2014):

screen shot 2014-10-21 at 4 17 32 pm

<!-- gh-comment-id:60000408 --> @rpenugonda commented on GitHub (Oct 21, 2014): ![screen shot 2014-10-21 at 4 17 32 pm](https://cloud.githubusercontent.com/assets/9339957/4726979/b98c363c-5967-11e4-8590-7dd0245a23c7.png)
Author
Owner

@rpenugonda commented on GitHub (Oct 21, 2014):

[root@pdns-testvm1 rpenugonda]# php -v
PHP 5.3.6 (cli) (built: Jun 13 2011 12:44:31)
Copyright (c) 1997-2011 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies

[root@pdns-testvm1 ]# uname -a
Linux pdns-testvm1 2.6.32-431.el6.x86_64 #1 SMP Fri Nov 22 03:15:09 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
[root@pdns-testvm1 ]# cat /etc/redhat-release
CentOS release 6.5 (Final)

this is the only error i am seeing.

[Tue Oct 21 21:20:27 2014] [error] [client 10.60.128.96] PHP Notice: Use of undefined constant CSRF_TOKEN - assumed 'CSRF_TOKEN' in /home/rpenugonda/nsedit/index.php on line 125

<!-- gh-comment-id:60000621 --> @rpenugonda commented on GitHub (Oct 21, 2014): [root@pdns-testvm1 rpenugonda]# php -v PHP 5.3.6 (cli) (built: Jun 13 2011 12:44:31) Copyright (c) 1997-2011 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies [root@pdns-testvm1 ]# uname -a Linux pdns-testvm1 2.6.32-431.el6.x86_64 #1 SMP Fri Nov 22 03:15:09 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux [root@pdns-testvm1 ]# cat /etc/redhat-release CentOS release 6.5 (Final) this is the only error i am seeing. [Tue Oct 21 21:20:27 2014] [error] [client 10.60.128.96] PHP Notice: Use of undefined constant CSRF_TOKEN - assumed 'CSRF_TOKEN' in /home/rpenugonda/nsedit/index.php on line 125
Author
Owner

@tuxis-ie commented on GitHub (Oct 21, 2014):

ok. Ehm, are you sure that you have php enabled in your webserver? The screendump you post looks exactly like what I see when I look at index.php without php enabled..

<!-- gh-comment-id:60001638 --> @tuxis-ie commented on GitHub (Oct 21, 2014): ok. Ehm, are you sure that you have php enabled in your webserver? The screendump you post looks exactly like what I see when I look at index.php without php enabled..
Author
Owner

@rpenugonda commented on GitHub (Oct 22, 2014):

I created a version.php and got this, seems to be php is enabled (not sure if i am missing anything)
screen shot 2014-10-22 at 9 36 28 am

<!-- gh-comment-id:60094689 --> @rpenugonda commented on GitHub (Oct 22, 2014): I created a version.php and got this, seems to be php is enabled (not sure if i am missing anything) ![screen shot 2014-10-22 at 9 36 28 am](https://cloud.githubusercontent.com/assets/9339957/4737896/e9322e82-59f8-11e4-8270-70896121d942.png)
Author
Owner

@tuxis-ie commented on GitHub (Oct 22, 2014):

Are you running nginx and php-fpm? You're testing version.php directly via port 9000, which is a default for php-fpm.

You need to tell (or Apache) that they should push php through fpm..

<!-- gh-comment-id:60145440 --> @tuxis-ie commented on GitHub (Oct 22, 2014): Are you running nginx and php-fpm? You're testing version.php directly via port 9000, which is a default for php-fpm. You need to tell (or Apache) that they should push php through fpm..
Author
Owner

@rpenugonda commented on GitHub (Oct 22, 2014):

it's apache and php, I had to ssh tunnel it etc.. to bypass the firewall. Is there a debug flag i can set so that i can see more info in the logs. Also i should be able to login irrespective of powerdns correct. does nsedit expose powerdns API with user acls etc..

<!-- gh-comment-id:60146351 --> @rpenugonda commented on GitHub (Oct 22, 2014): it's apache and php, I had to ssh tunnel it etc.. to bypass the firewall. Is there a debug flag i can set so that i can see more info in the logs. Also i should be able to login irrespective of powerdns correct. does nsedit expose powerdns API with user acls etc..
Author
Owner

@tuxis-ie commented on GitHub (Oct 22, 2014):

ok, found it. Please set 'short_open_tag' to 'On' ....

<!-- gh-comment-id:60148825 --> @tuxis-ie commented on GitHub (Oct 22, 2014): ok, found it. Please set 'short_open_tag' to 'On' ....
Author
Owner

@rpenugonda commented on GitHub (Oct 22, 2014):

thank you it works now.
Also does nsedit augment any API powerdns already provides like, having multiple api users, privileges etc..

<!-- gh-comment-id:60151204 --> @rpenugonda commented on GitHub (Oct 22, 2014): thank you it works now. Also does nsedit augment any API powerdns already provides like, having multiple api users, privileges etc..
Author
Owner

@rpenugonda commented on GitHub (Oct 23, 2014):

now i get a different error
screen shot 2014-10-22 at 11 04 01 pm

so i pulled an older version of zones.php (c5ae169b2d) and that works.
screen shot 2014-10-22 at 11 06 49 pm

<!-- gh-comment-id:60190311 --> @rpenugonda commented on GitHub (Oct 23, 2014): now i get a different error ![screen shot 2014-10-22 at 11 04 01 pm](https://cloud.githubusercontent.com/assets/9339957/4748171/c21a6c8a-5a69-11e4-90dc-b27239269731.png) so i pulled an older version of zones.php (c5ae169b2d9f85c27a3e1543a6661e02a2a697cc) and that works. ![screen shot 2014-10-22 at 11 06 49 pm](https://cloud.githubusercontent.com/assets/9339957/4748180/0ae8167e-5a6a-11e4-9e0e-3ecce35c93cb.png)
Author
Owner

@tuxis-ie commented on GitHub (Oct 23, 2014):

That bug is now fixed in b035bfd52a. Sorry about that.

<!-- gh-comment-id:60204087 --> @tuxis-ie commented on GitHub (Oct 23, 2014): That bug is now fixed in b035bfd52a27ce9f2d196b97f1fcbc70db62e03c. Sorry about that.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/nsedit#1
No description provided.