Skip to content

Add API Token Auth Support #44

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

spamhome
Copy link
Contributor

@spamhome spamhome commented Jul 20, 2023

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");

Add the support to use PVE API Tokens.

How it function
===========
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 spamhome changed the title Add API Token Support Add API Token Auth Support Jul 20, 2023
@lsthompson
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants