API Users 1.0.0

XF 2.2 / 2.3 API Users 1.0.0 beta 2

Add-on xenforo 2

Ressources et modules complémentaires pour XenForo 2

Styles xenforo 2

Styles / Thèmes et apparence pour xenforo 2

Templates xenforo 2

Codes pour modifier les templates sur xenforo 2

Section Premium

Add-on et Styles pour membre Premium
  • ⚠️ Section Premium. Réserver aux Membres Premium ⚠️
API Users 1.0.0

XF 2.2 / 2.3 API Users 1.0.0 beta 2

Catégorie Catégorie Add-Ons
Titre du sujet Titre du sujet API Users 1.0.0
Auteur de la discussion Auteur de la discussion laurent68
Date de début Date de début
Réponses Réponses 0
Affichages Affichages 4
Réaction Réaction 0
Dernier message par Dernier message par laurent68

laurent68

Fondateur

Staff
fondateur
Réputation: 100%
Discussions
5 084
Messages
13 297
Solutions
85
J'aime
8 133
Points
198
API Users creates user accounts that exist only to hold an API key. An API user has no password and no email address, cannot log in, and is not shown to the public as a member.

It is for an administrator who wants a script, a monitor or an integration to act through the REST API as its own account, without that account also being a way into the forum.

1791717377842.webp


Why not an ordinary account?​

A key that acts as a real member is only as safe as that member's account. If the account has a password, it can be guessed, phished or reset by email. If you hand the integration a super user key instead, it can do anything.

An API user is a real, valid account with its own permissions, so a key naming it can do exactly what you allow and nothing else, and there is no other way in to protect.

What an API user is​

  • It cannot log in. It has its own authentication scheme, which refuses every password.
  • It cannot be given a password or an email address. Both are refused wherever they are set: the user edit page, the REST API, a password reset, or another add-on.
  • It is not a member to the public. It is left out of the member list, member counts, newest members, statistics and the username autocomplete.
  • It has no public profile. Only the account itself and staff who can bypass user privacy can view it.
  • It cannot follow anyone or be followed.
  • It cannot be merged with another account, in either direction.
  • It is still found in the control panel. User search and the username autocomplete both find it, and its edit page is marked.
An API user is recorded as one by this add-on. It is not identified by having no password, so the passwordless accounts XenForo creates itself, for a registration through a connected account, are left alone.

Hiding the account does not hide what it writes. An API user that creates a thread through the API is named on it, like any member.

Creating one​

In the control panel: Setup > API users lists them and has an Add API user button. It needs the new administrator permission Manage API users, which is granted separately from managing users.

1791713174229.webp


From the command line:
Bash:
php cmd.php api-users:create "Monitor" --note="what it is for"
php cmd.php api-users:create "Monitor" --admin
php cmd.php api-users:list

Then give it a key. An API user can do nothing until an API key names it. Under Setup > API keys, add a key of type User key with the API user's name.

As an administrator​

Either route can also make the account an administrator, for a key that needs to reach the administrative parts of the API. It is given an administrator record holding no permissions; grant the ones it needs under Groups & permissions > Administrators. In the control panel this also needs the Manage administrators permission and your own password, as adding any administrator does.

Converting an existing account​

If you already have an account that was made to be a bot, its edit page offers Actions > Convert to API user.

1791713368816.webp


Converting removes the account's email address and password, and every other way it could log in: connected accounts, passkeys, two-step verification, saved logins and OAuth tokens. It also removes its follows. Its API keys and any administrator record are kept. This cannot be undone.
1791713563478.webp


An account that has been used as a member is refused, and the page says where its content is. Content means anything XenForo would reassign when merging or deleting a user: posts, conversations it started or wrote in, reactions, attachments, media, resources, and whatever an installed add-on registers. Login records, alerts, and a conversation the account was only sent, such as a welcome message, do not count. A banned or unconfirmed account, a moderator, and your own account are refused too.

1791713570503.webp


On the user edit page​

An API user's edit page carries a notice saying what it is. Its email and password fields are replaced by a note, so neither can be set by accident, and Merge with user is left out of its actions menu.

1791713300644.webp


These changes are for display. The enforcement is on the account itself, so it holds whatever form or add-on tries to set a password or an email address.

Checking​

Bash:
php cmd.php api-users:validate
Reports whether every API user still has no password and no email address, is hidden, and is able to act, and whether anything has changed an account behind the add-on's back.
  • It exits 0 when everything is fine, and also when there are only warnings.
  • It exits 1 when a check fails.
  • With --strict, a warning exits 2, for a monitor that wants to hear of one.

Requirements​

  • XenForo 2.2.0 or later
  • PHP 7.4 or later
Tested on XenForo 2.2.0 Patch 2 with PHP 7.4, and on XenForo 2.3.13 with PHP 8.3.

Installation​

Install the zip through the admin control panel, or unpack it and run:
Bash:
php cmd.php xf:addon-install Hampel/ApiUsers

The add-on creates one table and removes it when uninstalled. It adds no columns to XenForo's own tables.

Things to know​

  • An API user cannot be converted back into an ordinary account. Delete it and create a new one.
  • A disabled add-on does not guard. While the add-on is disabled an API user still cannot log in, but the user edit form can give it a password. Run api-users:validate after enabling it again.
  • The guards act when XenForo saves an account. A direct database edit or an importer that bypasses XenForo is not refused; api-users:validate reports the result as a failure.
  • Uninstalling moves every API user to XenForo's own passwordless scheme. The accounts remain, still unable to log in, but are no longer hidden or guarded: delete any you do not want kept.
  • With Archive Site: list each API user in its protected users before archiving. api-users:validate warns about any that is missing.

Beta​

This is a beta release. It has an automated test suite and has been installed, upgraded and uninstalled on the versions above and on several of the author's production forums. Please report anything unexpected in the discussion thread.

Télécharger V1.0.0 Beta2 :
 
Contenu similaire Les plus vues Voir plus
Retour
Haut Bas