Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion README-internal.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Project Requirements

- PHP 7.4 or higher
- PHP 8.2 or higher (CI runs the tests on 8.2, 8.3, 8.4 and 8.5)
- Composer

## Setup Instructions
Expand Down Expand Up @@ -55,5 +55,31 @@

(Requires Xdebug or PCOV extension)

## Releasing

Releases run from the **Release QueueToken PHP** pipeline (`pipelines/release.yml`). Do not
change `version` in `composer.json` by hand: it holds the last released version, and the
pipeline calculates the next one from it.

Before running it:

- Write `docs/release-notes/<version>.md` and add its row to `docs/release-notes/README.md`
(see that README for the standard), and merge that to `master`. The pipeline fails if
either is missing. A prerelease (`<version>-rc.<timestamp>`) uses the notes of `<version>`.

Then:

1. Run the pipeline with **ReleaseType** `major`, `minor`, `patch` or `prerelease`. It tests
on the minimum supported PHP version, sets the new version in `composer.json`, pushes
`release/v<version>` to `github.com/queueit/QueueToken.V1.PHP` and commits the version
bump back to `master`.
2. Pushing the branch opens the release PR on GitHub. Its description is the release notes
file.
3. Review and merge the PR. The merge runs the **Final GitHub Release** workflow, which
tags the merged commit `v<version>` and creates the GitHub release with the PR
description as its text.
4. Packagist publishes the tag through its GitHub hook within a few minutes:
https://packagist.org/packages/queueit/queuetoken-v1-php

---
This file is for internal use and documents the setup and test process for developers working on this project.
51 changes: 29 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

The `Queue-it` Queue Token SDK is used to ensure that end users cannot enter the queue without a valid token and to be a container which can carry sensitive user information from integrating system into the queue.

## Requirements

- PHP 8.2 or later. The library is tested on PHP 8.2, 8.3, 8.4 and 8.5.
- The OpenSSL extension (`ext-openssl`).

Applications running PHP 7.4, 8.0 or 8.1 must stay on version 1.1.x. Composer selects it automatically on those PHP versions.

## The Token

The token consists of two parts. Firstly, a header containing non-sensitive metadata. Secondly the payload of the token.
Expand Down Expand Up @@ -52,43 +59,43 @@ Both header and payload are in JSON format.
## Usage

```php
const secretKey = '...';
const token = Token
.enqueue("ticketania")
.withPayload(Payload
.enqueue()
.withKey("XKDI42W")
.withRelativeQuality(0.4578)
.withCustomData("size", "medium")
.generate())
.withEventId("demoevent")
.withIpAddress("75.86.129.4", "45.67.2.4,34.56.3.2")
.withValidity(60000)
.generate(secretKey);

const tokenValue = token.Token;
use QueueIT\QueueToken\Payload;
use QueueIT\QueueToken\Token;

$secretKey = '...';
$token = Token::enqueue("ticketania")
->withPayload(Payload::enqueue()
->withKey("XKDI42W")
->withRelativeQuality(0.4578)
->withCustomData("size", "medium")
->generate())
->withEventId("demoevent")
->withIpAddress("75.86.129.4", "45.67.2.4,34.56.3.2")
->withValidity(60000)
->generate($secretKey);

$tokenValue = $token->getToken();
```

### Specifying token identifier prefix

A prefix for the token identifier can optionally be provided to restrict the user session after getting through the queue to the one used before entering the queue. Once the user is through the queue the token identifier is provided to the target application in the Known User token. The format of the token identifier is then `[YOUR PREFIX]~[GUID]`, e.g: AnfTDnpwazllYmnmgaCJ8tErV80YHv77ni5NgqQNhfWwxNqrNcHb~e937ef0d-48ec-4ff7-866e-52033273cb3d.

```php
const tokenIdentifierPrefix = "AnfTDnpwazllYmnmgaCJ8tErV80YHv77ni5NgqQNhfWwxNqrNcHb";
const token = Token
.enqueue("ticketania", tokenIdentifierPrefix)
.generate(secretKey);
$tokenIdentifierPrefix = "AnfTDnpwazllYmnmgaCJ8tErV80YHv77ni5NgqQNhfWwxNqrNcHb";
$token = Token::enqueue("ticketania", $tokenIdentifierPrefix)
->generate($secretKey);

const tokenIdentifier = token.TokenIdentifier;
// tokenIdentifier example: AnfTDnpwazllYmnmgaCJ8tErV80YHv77ni5NgqQNhfWwxNqrNcHb~e937ef0d-48ec-4ff7-866e-52033273cb3d
$tokenIdentifier = $token->getTokenIdentifier();
// $tokenIdentifier example: AnfTDnpwazllYmnmgaCJ8tErV80YHv77ni5NgqQNhfWwxNqrNcHb~e937ef0d-48ec-4ff7-866e-52033273cb3d
```

## Serialized Token

> eyJ0eXAiOiJRVDEiLCJlbmMiOiJBRVMyNTYiLCJpc3MiOjE1MzQ3MjMyMDAwMDAsImV4cCI6MTUzOTEyOTYwMDAwMCwidGkiOiJhMjFkNDIzYS00M2ZkLTQ4MjEtODRmYS00MzkwZjZhMmZkM2UiLCJjIjoidGlja2V0YW5pYSIsImUiOiJteWV2ZW50In0.0rDlI69F1Dx4Twps5qD4cQrbXbCRiezBd6fH1PVm6CnVY456FALkAhN3rgVrh_PGCJHcEXN5zoqFg65MH8WZc_CQdD63hJre3Sedu0-9zIs.aZgzkJm57etFaXjjME_-9LjOgPNTTqkp1aJ057HuEiU

The format of the token is [header].[payload].[hash] where each part is Base64Url encoded.
The payload is AES 256 encrypted with the secret key supplied in the `.Generate(secretKey)` method.
The payload is AES 256 encrypted with the secret key supplied to the `generate($secretKey)` method.
If the "e" key is provided in the header, the secret key on the event must be used.
If no "e" key is provided the default key on the customer account must be used.
The token is signed with SHA 256 using the same secret key.
14 changes: 9 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "queueit/queuetoken-v1-php",
"version": "1.1.0",
"version": "1.2.0",
"description": "Queue-it PHP queue token library for managing enqueue tokens",
"type": "library",
"keywords": [
Expand All @@ -19,12 +19,11 @@
}
],
"require": {
"php": ">=7.4",
"ext-json": "*",
"php": ">=8.2",
"ext-openssl": "*"
},
"require-dev": {
"phpunit/phpunit": "^9.5"
"phpunit/phpunit": "^9.6.11"
},
"autoload": {
"psr-4": {
Expand All @@ -36,12 +35,17 @@
"QueueIT\\QueueToken\\Tests\\": "tests/"
}
},
"config": {
"platform": {
"php": "8.2.0"
}
},
"extra": {
"branch-alias": {
"dev-main": "1.x-dev"
}
},
"scripts": {
"test": "vendor\\bin\\phpunit tests --testdox"
"test": "phpunit --testdox"
}
}
Loading
Loading