Skip to content

Commit

Permalink
Fix api token checking
Browse files Browse the repository at this point in the history
  • Loading branch information
aheinze committed Jun 24, 2023
1 parent 667b0fc commit 0f786f7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Release Notes

## 2.6.1 (2023-06-24)

- Fix api token checking

## 2.6.0 (2023-06-21)

- Try to auto-generate meaningful linked content preview if display setting is missing
Expand Down
2 changes: 1 addition & 1 deletion bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

const APP_VERSION = '2.6.0';
const APP_VERSION = '2.6.1';

if (!defined('APP_START_TIME')) define('APP_START_TIME', microtime(true));
if (!defined('APP_ADMIN')) define('APP_ADMIN', false);
Expand Down
24 changes: 10 additions & 14 deletions modules/App/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,27 +40,23 @@
'role' => null
];

if ($token != 'public') {
if ($token != 'public' && preg_match('/^USR-/', $token)) {

if (preg_match('/^USR-/', $token)) {
$user = $this->dataStorage->findOne('system/users', ['apiKey' => $token]);

$user = $this->dataStorage->findOne('system/users', ['apiKey' => $token]);

if (!$user) {
$this->response->status = 412;
return ['error' => 'Authentication failed'];
}
if (!$user) {
$this->response->status = 412;
return ['error' => 'Authentication failed'];
}

$apiUser['user'] = $user['user'];
$apiUser['role'] = $user['role'];
$apiUser['user'] = $user['user'];
$apiUser['role'] = $user['role'];

// is jwt token?
} elseif (preg_match('/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/', $token)) {
// is jwt token?
} elseif ($token != 'public' && preg_match('/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/', $token)) {

// todo

}

} else {

$key = $this->helper('api')->getKey($token);
Expand Down

0 comments on commit 0f786f7

Please sign in to comment.