Download the PHP package mwstake/mediawiki-component-token-authenticator without Composer

On this page you can find all versions of the php package mwstake/mediawiki-component-token-authenticator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package mediawiki-component-token-authenticator

Purpose in life

This component provides everything needed to generate random tokens for users that can be later exchanged for user information.

Usage - User token

Generate token

REST API endpoint /mws/v1/user-token/generate can be used to generate a token for the user.

Client-side: mws.tokenAuthenticator.generateToken( withIssuer ). Params: withIssuer - boolean - default: false. If true, will include info about the wiki (url) that issued the token. To be used when verifying token, as a target for verification. If used, salt must be used.

Verify token

Call REST API endpoint /mws/v1/user-token/verify/{token} to verify the token. If valid, you will receive info on the user that the token was issued for, including user ID, username, and other info.

Verification when using salt

If token was salted, you will need to decode it using the salt, and then b64 decode it. Pass only the token from the decoded token object at verification time.

Salt

Configure $GLOBALS['mwsgTokenAuthenticatorSalt'] = '<random string>'; in your LocalSettings.php file, to salt the tokens issued by this service. This is recommended for security reasons. Note that token will only be salted if so required, not by default.

When salted, token structure is changed, instead of just a plain string token, token is a b64-encoded JSON that looks like this

[
    'verifyCallback' => $callbackUrl,
    'token' => $token,
    'sig' => $signature,
]

Where:

Static token for service authentication

For service-to-service authentication, you can use a static token.

Include header Authorization: ApiKey {my_token} when making calls. This authentication only works for REST and Action API calls.

Configure token(s)

Of these values, optional are:

Global settings

You can limit access to specific CIDR ranges by configuring

$GLOBALS['mwsgTokenAuthenticatorServiceCIDR'] = '127.0.0.1/32';

Configuring user that the service token represents:

$GLOBALS['mwsgTokenAuthenticatorServiceUser'] = 'ChatBot service user';

This is the default user and it will be create and configured automatically. If you want to use a different user, create it manually and set this variable to the username. Due to user token limitations, only "actual" (non-system) users can be used here.

Dynamic token for service authentication

As static token limits the amount of APIs you can access, in order to access full range of APIs, use dynamic token. This token is similar to a user token, but instead of being issued for a user, it's issued for a service, and can be used to authenticate the service on the behalf of the "Service user".

This tokens are always encrypted and salted, so you will need to decode it first using the salt value, to get the actual token, and callbackUrl

Generate using /mws/v1/app-token/generate.

When making requests provide header: Authorization AppToken {decoded token}. This will provide you with a full-access session.

Note that this will authenticate as user mwsgTokenAuthenticatorServiceUser. It will give this user sysop group, to ensure it can execute all APIs. If another user is assigned to this, make sure it is ok that this user gets sysop group.

When issuing and granting sessions based on these tokens, $GLOBALS['mwsgTokenAuthenticatorServiceCIDR'] = '127.0.0.1/32'; is respected, to limit access.

When session is created for such token, it will be created on behalf of $GLOBALS['mwsgTokenAuthenticatorServiceUser']

Logging

Component logs into MWStake.TokenAuthenticator channel for token verification and to session for session providing.


All versions of mediawiki-component-token-authenticator with dependencies

PHP Build Version
Package Version
Requires mwstake/mediawiki-componentloader Version ~1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package mwstake/mediawiki-component-token-authenticator contains the following files

Loading the files please wait ...