Vesta Control Panel - Forum

Community Forum

Skip to content

Advanced search
  • Quick links
    • Main site
    • Github repo
    • Google Search
  • FAQ
  • Login
  • Register
  • Board index Dev Section Scripting / API
  • Search

API Key Instead of User and Password

Questions regarding the API
Application Programming Interface
Locked
  • Print view
Advanced search
5 posts • Page 1 of 1
emardotcom
Posts: 54
Joined: Wed Dec 11, 2013 9:05 pm

API Key Instead of User and Password

Post by emardotcom » Sat Dec 06, 2014 7:35 pm

Hello I was wondering why Vesta doesn't use a Key for login instead of username and password. Isn't it more secure to pass a key through post then your username and password?

If there is a key option I couldn't find it at http://vestacp.com/docs/api/ could you point me in the right direction?

Regards
_
Stuart
Top

BBuchanan1013
Posts: 139
Joined: Thu Jan 07, 2016 12:01 am

Re: API Key Instead of User and Password

Post by BBuchanan1013 » Sun Jan 17, 2016 12:01 am

emardotcom wrote:Hello I was wondering why Vesta doesn't use a Key for login instead of username and password. Isn't it more secure to pass a key through post then your username and password?

If there is a key option I couldn't find it at http://vestacp.com/docs/api/ could you point me in the right direction?

Regards
_
Stuart
Just IMO, guessing one long key would be easier than guessing two different fields (username & password).
Top

skurudo
VestaCP Team
Posts: 8099
Joined: Fri Dec 26, 2014 2:23 pm
Contact:
Contact skurudo
Website Facebook Google+ Skype
Twitter

Re: API Key Instead of User and Password

Post by skurudo » Sun Jan 17, 2016 2:17 pm

Stuart, key more secure? Why? Users sometime can't remember password, how come some users can remember key? ;)
Top

tjebbeke
Collaborator
Posts: 783
Joined: Mon May 11, 2015 8:43 am
Contact:
Contact tjebbeke
Website

Os: CentOS 6x
Web: apache + nginx
Re: API Key Instead of User and Password

Post by tjebbeke » Sun Jan 17, 2016 5:15 pm

As I can see in the code, this is already possible to use a KEY instead of user/password in the API.
Generate KEY:
v-generate-api-key

in api request use 'hash' parameter. example:

Code: Select all

<?php

// Server credentials
$vst_hostname = 'server.vestacp.com';
$vst_hash = 'somerandomstringhashcode';
$vst_returncode = 'yes';
$vst_command = 'v-add-user';

// New Account
$username = 'demo';
$password = 'd3m0p4ssw0rd';
$email = '[email protected]';
$package = 'default';
$fist_name = 'Rust';
$last_name = 'Cohle';

// Prepare POST query
$postvars = array(
    'hash' => $vst_hash,
    'returncode' => $vst_returncode,
    'cmd' => $vst_command,
    'arg1' => $username,
    'arg2' => $password,
    'arg3' => $email,
    'arg4' => $package,
    'arg5' => $fist_name,
    'arg6' => $last_name
);
$postdata = http_build_query($postvars);

// Send POST query via cURL
$postdata = http_build_query($postvars);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://' . $vst_hostname . ':8083/api/');
curl_setopt($curl, CURLOPT_RETURNTRANSFER,true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata);
$answer = curl_exec($curl);

// Check result
if($answer == 0) {
    echo "User account has been successfuly created\n";
} else {
    echo "Query returned error code: " .$answer. "\n";
}
?>
Top

skurudo
VestaCP Team
Posts: 8099
Joined: Fri Dec 26, 2014 2:23 pm
Contact:
Contact skurudo
Website Facebook Google+ Skype
Twitter

Re: API Key Instead of User and Password

Post by skurudo » Fri Sep 23, 2016 12:43 pm

First steps to make good docs for all of us, guys! ;-)

API documentation and examples:
http://vestacp.com/docs/API.pdf

CLI commands list and descriptions:
http://vestacp.com/docs/CLI.txt
Top


Locked
  • Print view

5 posts • Page 1 of 1

Return to “Scripting / API”



  • Board index
  • All times are UTC
  • Delete all board cookies
  • The team
Powered by phpBB® Forum Software © phpBB Limited
*Original Author: Brad Veryard
*Updated to 3.2 by MannixMD
 

 

cron

Login  •  Register

I forgot my password