pve2-api-php-client icon indicating copy to clipboard operation
pve2-api-php-client copied to clipboard

Add API Token Auth Support

Open spamhome opened this issue 2 years ago • 1 comments

Add the support for auth with API Token

How it works

the class now parse the password parameter ($this->password). if there a ":" in password they will be use token authentification.

if not the class is use username + password authentification

So the class is compatible backwards

How to use

Login with username & password: $pve2 = new PVE2_API("hostname", "username", "realm", "password");

Login with API Token: $pve2 = new PVE2_API("hostname", "username", "realm", "TokenID:TokenValue");

Example: $pve2 = new PVE2_API("hostname", "root", "pam", "TestToken:7381a050-0185-43d1-a651-0c30a2bba5cc");

spamhome avatar Jul 20 '23 20:07 spamhome

I think that using the presence of a colon in the password is too unpredictable, especially in current times.

Perhaps if the password field is null when PVE2_API is initiated, a new field in the request can be checked?

  1. hostname
  2. username
  3. realm
  4. password
  5. ticket

lsthompson avatar Dec 14 '23 03:12 lsthompson