Skip to content

Commit

Permalink
Merge pull request #219 from ember-nexus/github-issue/59
Browse files Browse the repository at this point in the history
GitHub issue/59
  • Loading branch information
Syndesi authored Dec 16, 2023
2 parents 9cbf809 + b4d3582 commit a7118fe
Show file tree
Hide file tree
Showing 43 changed files with 1,097 additions and 117 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ ELASTIC_AUTH=ember-nexus-elasticsearch:9200
REDIS_AUTH=tcp://ember-nexus-redis?password=redis-password
RABBITMQ_AUTH=amqp://user:password@ember-nexus-rabbitmq:5672

REFERENCE_DATASET_VERSION=0.0.20
REFERENCE_DATASET_VERSION=0.0.22
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Unreleased
### Added
- Add documentation and automatic documentation tests for endpoint DELETE `/token`, closes #208.
- Add command `token:revoke`, closes #59.
### Changed
- **Switch license to AGPL-3.0-only, closes #215.**
- Remove commented and unused code, configuration etc., closes #168.
- Remove test CI triggers "pull_request" and "fork", closes #216.
- Rename command `user:token:create` to `token:create`, related to #59.
- Tokens cached by Redis now automatically expire within 30 minutes or as their expiration date is reached, part of #59.
### Fixed
- Deleting tokens now deletes the correct token from Redis, fixes #186.
- Add missing feature tests, related to #168.
- Fix bug where datetime-similar properties could not be correctly returned to the user, uncovered during #59.

## 0.0.38 - 2023-12-08
### Added
- Add documentation and automatic example generation for healthcheck command, closes [#184].
- Add 401 error case for the GET /me endpoint, closes [#190].
- Add parameters `page` and `pageSize` to documentation of collection endpoints, closes [#189].

### Changed
- Rename `_PartialUnifiedCollection` to `_PartialElementCollection`, closes [#187].
- All CI tasks are configured to have timeouts, closes [#201].
Expand Down
4 changes: 3 additions & 1 deletion docs/_sidebar.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@
- [`healthcheck`](/commands/system/healthcheck)
- **User Commands**
- [`user:create`](/commands/user/user-create)
- [`user:token:create`](/commands/user/user-token-create)
- **Token Commands**
- [`token:create`](/commands/token/token-create)
- [`token:revoke`](/commands/token/token-revoke)
- **Backup Commands**
- [`backup:list`](/commands/backup/backup-list)
- [`backup:fetch`](/commands/backup/backup-fetch)
Expand Down
2 changes: 1 addition & 1 deletion docs/commands/assets/backup-create-help.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
backup:create [options] [--] [<name>]

<span class="yellow ">Arguments:</span>
<span class="green ">name</span> Name of the backup, defaults to the current timestamp.<span class="yellow "> [default: &quot;20231203120809&quot;]</span>
<span class="green ">name</span> Name of the backup, defaults to the current timestamp.<span class="yellow "> [default: &quot;20231216152852&quot;]</span>

<span class="yellow ">Options:</span>
<span class="green ">-p, --pretty|--no-pretty</span> Activates pretty print of JSON.
Expand Down
12 changes: 6 additions & 6 deletions docs/commands/assets/backup-fetch.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,20 @@
<span class="bold ">Backup Fetch</span>

<span class="bold "> Downloading and inspecting archive </span>───────────────────────────────────────────
│ Loaded archive is <span class="green ">298.77 KB</span> big.
│ SHA1 sum of file is <span class="green ">f3e3bcac6e354425771bb2c8ac839841d88150e5</span>.
│ Found backup inside ZIP in folder <span class="green ">reference-dataset-0.0.12</span>.
│ Loaded archive is <span class="green ">313.67 KB</span> big.
│ SHA1 sum of file is <span class="green ">f232952d9fc8a742d7f8441e97d3ceeafb14622a</span>.
│ Found backup inside ZIP in folder <span class="green ">reference-dataset-0.0.19</span>.
│ Required folders exist.
└ Download complete.

<span class="bold "> Extracting nodes </span>─────────────────────────────────────────────────────────────
0 [&gt;---------------------------] 61 [-&gt;--------------------------] 107 [---&gt;------------------------] 153 [-----&gt;----------------------] 206 [-------&gt;--------------------] 253 [---------&gt;------------------] 303 [-----------&gt;----------------] 345 [============================]└ All nodes extracted.
└ All nodes extracted.

<span class="bold "> Extracting relations </span>─────────────────────────────────────────────────────────
0 [&gt;---------------------------] 60 [-&gt;--------------------------] 105 [---&gt;------------------------] 147 [-----&gt;----------------------] 189 [-------&gt;--------------------] 239 [---------&gt;------------------] 290 [-----------&gt;----------------] 340 [-------------&gt;--------------] 391 [--------------&gt;-------------] 399 [============================]└ All relations extracted.
└ All relations extracted.

<span class="bold "> Extracting files </span>─────────────────────────────────────────────────────────────
0 [&gt;---------------------------] 1 [============================]└ All files extracted.
└ All files extracted.

<span class="bold "> Extracting summary.json </span>──────────────────────────────────────────────────────
└ summary.json extracted.
Expand Down
2 changes: 1 addition & 1 deletion docs/commands/assets/backup-list.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<span class="bold ">Backup List</span>

<span class="bold ">Name </span> <span class="bold ">Hostname </span> <span class="bold ">Version </span> <span class="bold ">Date </span> <span class="bold ">Nodes </span> <span class="bold ">Edges </span> <span class="bold ">Files </span>
test 4909d747e715 0.0.38 2023-12-03 0 0 0
test 1a157b4a46a8 0.0.38 2023-12-16 0 0 0
reference-dataset ember-nexus dev 2023-05-06 282 338 0

▶ Command finished successfully.
Expand Down
4 changes: 2 additions & 2 deletions docs/commands/assets/backup-load.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@
<span class="bold ">Backup Load</span>

<span class="bold "> Step 1 of 4: Loading Nodes </span>───────────────────────────────────────────────────
└ Loaded <span class="green ">291</span> nodes.
└ Loaded <span class="green ">306</span> nodes.

<span class="bold "> Step 2 of 4: Loading Relations </span>───────────────────────────────────────────────
└ Loaded <span class="green ">344</span> relations.
└ Loaded <span class="green ">356</span> relations.

<span class="bold "> Step 3 of 4: Loading Files </span>───────────────────────────────────────────────────
│ Currently not implemented.
Expand Down
2 changes: 1 addition & 1 deletion docs/commands/assets/system-healthcheck.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
└ All databases are online.

<span class="bold "> Check internal services </span>──────────────────────────────────────────────────────
│ Alpine version: 3.18.4
│ Alpine version: 3.19.0
│ NGINX Unit version: 1.31.1
│ PHP version: 8.3.0
└ Internal services are ok.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
Creates a new token for an user.

<span class="yellow ">Usage:</span>
user:token:create &lt;identifier&gt; &lt;password&gt;
token:create &lt;identifier&gt; &lt;password&gt;

<span class="yellow ">Arguments:</span>
<span class="green ">identifier</span> Unique identifier of the user (email) or the user's UUID
Expand Down
6 changes: 3 additions & 3 deletions docs/commands/assets/user-token-create.html → docs/commands/assets/token-create.html
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@
<span class="highlighted dimgray "></span><span class="highlighted dimgray bg-red ">▀ ▀</span><span class="highlighted dimgray "></span> <span class="bold ">Ember Nexus API</span>
<span class="highlighted red "></span><span class="highlighted white "></span><span class="highlighted red "></span> v0.0.38, production mode

<span class="bold ">User Token Create</span>
<span class="bold ">Token Create</span>

Found user with identifier '<span class="green ">command-[email protected]</span>', user's UUID is <span class="green ">d604dae6-3922-45bd-aa76-0a9f1fcce1d5</span>.
Found user with identifier '<span class="green ">token-create-[email protected]</span>', user's UUID is <span class="green ">de970375-ae1e-46e5-9890-db04b9e51357</span>.

▶ Successfully created new token: <span class="green ">secret-token:Hrdb2bgQVHiAB4EvBMhted</span> .
▶ Successfully created new token: <span class="green ">secret-token:8hWTs5uFMAEYmYsRnlcZga</span> .

</pre>
</body>
Expand Down
68 changes: 68 additions & 0 deletions docs/commands/assets/token-revoke-help.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!-- This file was created with the aha Ansi HTML Adapter. https://github.com/theZiz/aha -->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="application/xml+xhtml; charset=UTF-8"/>
<title>stdin</title>
<link rel="stylesheet" href="./cli-style.css" />
<style type="text/css">
body {color: white; background-color: black;}
.reset {color: white;}
.bg-reset {background-color: black;}
.inverted {color: black;}
.bg-inverted {background-color: white;}
.dimgray {color: dimgray;}
.red {color: red;}
.green {color: lime;}
.yellow {color: yellow;}
.blue {color: #3333FF;}
.purple {color: fuchsia;}
.cyan {color: aqua;}
.white {color: white;}
.bg-black {background-color: black;}
.bg-red {background-color: red;}
.bg-green {background-color: lime;}
.bg-yellow {background-color: yellow;}
.bg-blue {background-color: #3333FF;}
.bg-purple {background-color: fuchsia;}
.bg-cyan {background-color: aqua;}
.bg-white {background-color: white;}
.underline {text-decoration: underline;}
.bold {font-weight: bold;}
.italic {font-style: italic;}
.blink {text-decoration: blink;}
.crossed-out {text-decoration: line-through;}
.highlighted {filter: contrast(70%) brightness(190%);}
</style>
</head>
<body>
<pre>
<span class="yellow ">Description:</span>
Revoke tokens.

<span class="yellow ">Usage:</span>
token:revoke [options]

<span class="yellow ">Options:</span>
<span class="green ">-f, --force|--no-force</span> If enabled, command will not ask for manual confirmation.
<span class="green "> --dry-run|--no-dry-run</span> Does not apply revocation. Also lists all tokens which would be affected.
<span class="green ">-l, --list-all-affected-tokens|--no-list-all-affected-tokens</span> Lists all tokens.
<span class="green ">-u, --user=USER</span> Token revocation is only applied to an given user. User can be specified by its UUID (takes precedent) or its identifier.
<span class="green ">-g, --group=GROUP</span> Token revocation is only applied to users of given group. Group must be specified by its UUID.
<span class="green ">-b, --issued-before=ISSUED-BEFORE</span> Token revocation is only applied to tokens issued before a given point in time. Datetime must be in the format &quot;YYYY-MM-DD HH:MM&quot; (UTC).
<span class="green ">-a, --issued-after=ISSUED-AFTER</span> Token revocation is only applied to tokens issued after a given point in time. Datetime must be in the format &quot;YYYY-MM-DD HH:MM&quot; (UTC).
<span class="green "> --issued-without-expiration-date</span> Token revocation is only applied to tokens with no explicit expiration date.
<span class="green "> --issued-with-expiration-date</span> Token revocation is only applied to tokens with explicit expiration date set.
<span class="green ">-h, --help</span> Display help for the given command. When no command is given display help for the <span class="green ">list</span> command
<span class="green ">-q, --quiet</span> Do not output any message
<span class="green ">-V, --version</span> Display this application version
<span class="green "> --ansi|--no-ansi</span> Force (or disable --no-ansi) ANSI output
<span class="green ">-n, --no-interaction</span> Do not ask any interactive question
<span class="green ">-e, --env=ENV</span> The Environment name.<span class="yellow "> [default: &quot;prod&quot;]</span>
<span class="green "> --no-debug</span> Switch off debug mode.
<span class="green "> --profile</span> Enables profiling (requires debug).
<span class="green ">-v|vv|vvv, --verbose</span> Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
</pre>
</body>
</html>
68 changes: 68 additions & 0 deletions docs/commands/assets/token-revoke.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!-- This file was created with the aha Ansi HTML Adapter. https://github.com/theZiz/aha -->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="application/xml+xhtml; charset=UTF-8"/>
<title>stdin</title>
<link rel="stylesheet" href="./cli-style.css" />
<style type="text/css">
body {color: white; background-color: black;}
.reset {color: white;}
.bg-reset {background-color: black;}
.inverted {color: black;}
.bg-inverted {background-color: white;}
.dimgray {color: dimgray;}
.red {color: red;}
.green {color: lime;}
.yellow {color: yellow;}
.blue {color: #3333FF;}
.purple {color: fuchsia;}
.cyan {color: aqua;}
.white {color: white;}
.bg-black {background-color: black;}
.bg-red {background-color: red;}
.bg-green {background-color: lime;}
.bg-yellow {background-color: yellow;}
.bg-blue {background-color: #3333FF;}
.bg-purple {background-color: fuchsia;}
.bg-cyan {background-color: aqua;}
.bg-white {background-color: white;}
.underline {text-decoration: underline;}
.bold {font-weight: bold;}
.italic {font-style: italic;}
.blink {text-decoration: blink;}
.crossed-out {text-decoration: line-through;}
.highlighted {filter: contrast(70%) brightness(190%);}
</style>
</head>
<body>
<pre>

<span class="highlighted dimgray "></span>
<span class="highlighted dimgray "></span><span class="highlighted dimgray bg-red ">▀ ▀</span><span class="highlighted dimgray "></span> <span class="bold ">Ember Nexus API</span>
<span class="highlighted red "></span><span class="highlighted white "></span><span class="highlighted red "></span> v0.0.38, production mode

<span class="bold ">Token Revocation</span>

51 tokens are affected by revocation. First 10 are shown:

<span class="bold ">Token UUID </span> <span class="bold ">User UUID </span> <span class="bold ">User identifier </span> <span class="bold ">Created </span> <span class="bold ">Expires on </span>
374fa7ea-4df7-475c-a6a6-b35ff7b9bae1 1a0fd886-9f62-497f-8d20-bd61a40b49b7 [email protected] 2023-12-16 15:29:06 -
840fee16-996e-4b1a-af2a-77d77c4aeda7 a70e49dc-ec45-414a-beb2-43e6fa56eb41 [email protected] 2023-12-16 15:29:06 -
5f450171-c535-4365-ac70-a283955d4ff5 4250a83d-707b-4f7a-b7dc-225af430f093 [email protected] 2023-12-16 15:29:06 -
9543e70d-6552-4409-ab6a-dfaf003382a2 8d70608f-ebca-4077-98d2-12733b7fd08e [email protected] 2023-12-16 15:29:06 -
6009d74a-1db9-4d1a-bc16-a948706dca58 2274873a-b9a2-4e77-b330-900857b76c1d [email protected] 2023-12-16 15:29:06 -
571b30e2-40eb-43f5-a888-a6b7ec6c15fc fdf0509d-812c-4435-a863-a4fd6f17e9c4 [email protected] 2023-12-16 15:29:06 -
ca9fa4fe-1fbd-4e8a-a6bf-701d97a7ec12 7935a9d2-e453-4dec-bc4a-243e3ced678a [email protected] 2023-12-16 15:29:06 -
84e32a4f-840b-435a-a064-2e72f19d8b20 53ae199c-6b71-44c1-b10c-fca306b32cbf [email protected] 2023-12-16 15:29:06 -
befd839e-5711-414e-8fe3-a8a3225dd603 1eb25cca-9c9e-4ec9-a9be-9044741b2b8c [email protected] 2023-12-16 15:29:06 -
ed1891bf-d7a8-4e64-ba0d-ebec82ad173e 1eb25cca-9c9e-4ec9-a9be-9044741b2b8c [email protected] 2023-12-16 15:29:06 -

Revoking tokens...

▶ Successfully revoked tokens.

</pre>
</body>
</html>
2 changes: 1 addition & 1 deletion docs/commands/assets/user-create.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

<span class="bold ">User Create</span>

▶ Created user with email '<span class="green ">[email protected]</span>' successfully, UUID is <span class="green ">d604dae6-3922-45bd-aa76-0a9f1fcce1d5</span>.
▶ Created user with email '<span class="green ">[email protected]</span>' successfully, UUID is <span class="green ">0332e376-52e7-46b6-9336-d1b9e258a5f1</span>.

</pre>
</body>
Expand Down
17 changes: 17 additions & 0 deletions docs/commands/token/token-create.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# `token:create`

<div class="code-title auto-refresh">Help Output</div>

```bash
php bin/console token:create --help
```

[](../assets/token-create-help.html ':include :type=html')

<div class="code-title auto-refresh">Example Command</div>

```bash
php bin/console token:create [email protected] 1234
```

[](../assets/token-create.html ':include :type=html')
17 changes: 17 additions & 0 deletions docs/commands/token/token-revoke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# `token:revoke`

<div class="code-title auto-refresh">Help Output</div>

```bash
php bin/console token:revoke --help
```

[](../assets/token-revoke-help.html ':include :type=html')

<div class="code-title auto-refresh">Example Command</div>

```bash
php bin/console token:revoke -f
```

[](../assets/token-revoke.html ':include :type=html')
17 changes: 0 additions & 17 deletions docs/commands/user/user-token-create.md

This file was deleted.

3 changes: 3 additions & 0 deletions lib/EmberNexusBundle/src/Service/EmberNexusConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,9 @@ public function setRegisterUniqueIdentifier(string $registerUniqueIdentifier): E
if (0 === strlen($registerUniqueIdentifier)) {
throw new Exception('Unique identifier can not be an empty string.');
}
if (!preg_match('/^[A-Za-z0-9_]+$/', $registerUniqueIdentifier)) {
throw new Exception("Unique identifier must only contain alphanumeric characters and '_'.");
}
$this->registerUniqueIdentifier = $registerUniqueIdentifier;

return $this;
Expand Down
Loading

0 comments on commit a7118fe

Please sign in to comment.