@@ -2226,7 +2226,7 @@ |
||
| 2226 | 2226 | * <tt>exec("find ".$path." -type d -exec chmod 755 {} \;");</tt> |
| 2227 | 2227 | * |
| 2228 | 2228 | * @author Jeppe Toustrup (tenzer at tenzer dot dk) |
| 2229 | - * |
|
| 2229 | + * |
|
| 2230 | 2230 | * @param string $path An either relative or absolute path to a file or directory which should be processed. |
| 2231 | 2231 | * @param int $filePerm The permissions any found files should get. |
| 2232 | 2232 | * @param int $dirPerm The permissions any found folder should get. |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | { |
| 95 | 95 | require API_ROOT_PATH . '/../includes/config/tp.config.php'; |
| 96 | 96 | $headers = ['alg'=>'HS256','typ'=>'JWT']; |
| 97 | - $payload = [ |
|
| 97 | + $payload = [ |
|
| 98 | 98 | 'username' => $login, |
| 99 | 99 | 'id' => $id, |
| 100 | 100 | 'exp' => (time() + $SETTINGS['api_token_duration'] + 600), |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | ]; |
| 106 | 106 | |
| 107 | 107 | include_once API_ROOT_PATH . '/inc/jwt_utils.php'; |
| 108 | - return ['token' => generate_jwt($headers, $payload)]; |
|
| 108 | + return ['token' => generate_jwt($headers, $payload)]; |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | //end createUserJWT |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | $ret = []; |
| 35 | 35 | |
| 36 | 36 | foreach ($rows as $row) { |
| 37 | - $isVisible = in_array((int) $row['id'], $foldersId); |
|
| 37 | + $isVisible = in_array((int) $row['id'], $foldersId); |
|
| 38 | 38 | $childrens = $this->getFoldersChildren($row['id'], $foldersId); |
| 39 | 39 | |
| 40 | 40 | if ($isVisible || count($childrens) > 0) { |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | [ |
| 44 | 44 | 'id' => (int) $row['id'], |
| 45 | 45 | 'title' => $row['title'], |
| 46 | - 'isVisible' => $isVisible, |
|
| 46 | + 'isVisible' => $isVisible, |
|
| 47 | 47 | 'childrens' => $childrens |
| 48 | 48 | ] |
| 49 | 49 | ); |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | |
| 64 | 64 | if ( count($childrens) > 0) { |
| 65 | 65 | foreach ($childrens as $children) { |
| 66 | - $isVisible = in_array((int) $children['id'], $foldersId); |
|
| 66 | + $isVisible = in_array((int) $children['id'], $foldersId); |
|
| 67 | 67 | $childs = $this->getFoldersChildren($children['id'], $foldersId); |
| 68 | 68 | |
| 69 | 69 | if (in_array((int) $children['id'], $foldersId) || count($childs) > 0) { |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | [ |
| 73 | 73 | 'id' => (int) $children['id'], |
| 74 | 74 | 'title' => $children['title'], |
| 75 | - 'isVisible' => $isVisible, |
|
| 75 | + 'isVisible' => $isVisible, |
|
| 76 | 76 | 'childrens' => $childs |
| 77 | 77 | ] |
| 78 | 78 | ); |
@@ -2,28 +2,28 @@ |
||
| 2 | 2 | |
| 3 | 3 | declare(strict_types=1); |
| 4 | 4 | |
| 5 | - /** |
|
| 6 | - * Teampass - a collaborative passwords manager. |
|
| 7 | - * --- |
|
| 8 | - * This library is distributed in the hope that it will be useful, |
|
| 9 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 10 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
| 11 | - * --- |
|
| 12 | - * |
|
| 13 | - * @project Teampass |
|
| 14 | - * |
|
| 15 | - * @file search.js.php |
|
| 16 | - * --- |
|
| 17 | - * |
|
| 18 | - * @author Nils Laumaillé ([email protected]) |
|
| 19 | - * |
|
| 20 | - * @copyright 2009-2023 Teampass.net |
|
| 21 | - * |
|
| 22 | - * @license https://spdx.org/licenses/GPL-3.0-only.html#licenseText GPL-3.0 |
|
| 23 | - * --- |
|
| 24 | - * |
|
| 25 | - * @see https://www.teampass.net |
|
| 26 | - */ |
|
| 5 | + /** |
|
| 6 | + * Teampass - a collaborative passwords manager. |
|
| 7 | + * --- |
|
| 8 | + * This library is distributed in the hope that it will be useful, |
|
| 9 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 10 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
| 11 | + * --- |
|
| 12 | + * |
|
| 13 | + * @project Teampass |
|
| 14 | + * |
|
| 15 | + * @file search.js.php |
|
| 16 | + * --- |
|
| 17 | + * |
|
| 18 | + * @author Nils Laumaillé ([email protected]) |
|
| 19 | + * |
|
| 20 | + * @copyright 2009-2023 Teampass.net |
|
| 21 | + * |
|
| 22 | + * @license https://spdx.org/licenses/GPL-3.0-only.html#licenseText GPL-3.0 |
|
| 23 | + * --- |
|
| 24 | + * |
|
| 25 | + * @see https://www.teampass.net |
|
| 26 | + */ |
|
| 27 | 27 | |
| 28 | 28 | Use TeampassClasses\PerformChecks\PerformChecks; |
| 29 | 29 | |
@@ -26,43 +26,43 @@ discard block |
||
| 26 | 26 | Use TeampassClasses\SuperGlobal\SuperGlobal; |
| 27 | 27 | |
| 28 | 28 | function generate_jwt($headers, $payload) { |
| 29 | - $headers_encoded = base64url_encode(json_encode($headers)); |
|
| 29 | + $headers_encoded = base64url_encode(json_encode($headers)); |
|
| 30 | 30 | |
| 31 | - $payload_encoded = base64url_encode(json_encode($payload)); |
|
| 31 | + $payload_encoded = base64url_encode(json_encode($payload)); |
|
| 32 | 32 | |
| 33 | - $signature = hash_hmac('SHA256', "$headers_encoded.$payload_encoded", DB_PASSWD, true); |
|
| 34 | - $signature_encoded = base64url_encode($signature); |
|
| 33 | + $signature = hash_hmac('SHA256', "$headers_encoded.$payload_encoded", DB_PASSWD, true); |
|
| 34 | + $signature_encoded = base64url_encode($signature); |
|
| 35 | 35 | |
| 36 | - $jwt = "$headers_encoded.$payload_encoded.$signature_encoded"; |
|
| 36 | + $jwt = "$headers_encoded.$payload_encoded.$signature_encoded"; |
|
| 37 | 37 | |
| 38 | - return $jwt; |
|
| 38 | + return $jwt; |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | function is_jwt_valid($jwt) { |
| 42 | - // split the jwt |
|
| 43 | - $tokenParts = explode('.', $jwt); |
|
| 44 | - $header = base64_decode($tokenParts[0]); |
|
| 45 | - $payload = base64_decode($tokenParts[1]); |
|
| 46 | - $signature_provided = $tokenParts[2]; |
|
| 42 | + // split the jwt |
|
| 43 | + $tokenParts = explode('.', $jwt); |
|
| 44 | + $header = base64_decode($tokenParts[0]); |
|
| 45 | + $payload = base64_decode($tokenParts[1]); |
|
| 46 | + $signature_provided = $tokenParts[2]; |
|
| 47 | 47 | |
| 48 | - // check the expiration time - note this will cause an error if there is no 'exp' claim in the jwt |
|
| 49 | - $expiration = json_decode($payload)->exp; |
|
| 50 | - $is_token_expired = ($expiration - time()) < 0; |
|
| 48 | + // check the expiration time - note this will cause an error if there is no 'exp' claim in the jwt |
|
| 49 | + $expiration = json_decode($payload)->exp; |
|
| 50 | + $is_token_expired = ($expiration - time()) < 0; |
|
| 51 | 51 | |
| 52 | - // build a signature based on the header and payload using the secret |
|
| 53 | - $base64_url_header = base64url_encode($header); |
|
| 54 | - $base64_url_payload = base64url_encode($payload); |
|
| 55 | - $signature = hash_hmac('SHA256', $base64_url_header . "." . $base64_url_payload, DB_PASSWD, true); |
|
| 56 | - $base64_url_signature = base64url_encode($signature); |
|
| 52 | + // build a signature based on the header and payload using the secret |
|
| 53 | + $base64_url_header = base64url_encode($header); |
|
| 54 | + $base64_url_payload = base64url_encode($payload); |
|
| 55 | + $signature = hash_hmac('SHA256', $base64_url_header . "." . $base64_url_payload, DB_PASSWD, true); |
|
| 56 | + $base64_url_signature = base64url_encode($signature); |
|
| 57 | 57 | |
| 58 | - // verify it matches the signature provided in the jwt |
|
| 59 | - $is_signature_valid = ($base64_url_signature === $signature_provided); |
|
| 58 | + // verify it matches the signature provided in the jwt |
|
| 59 | + $is_signature_valid = ($base64_url_signature === $signature_provided); |
|
| 60 | 60 | |
| 61 | - if ($is_token_expired || !$is_signature_valid) { |
|
| 62 | - return FALSE; |
|
| 63 | - } else { |
|
| 64 | - return TRUE; |
|
| 65 | - } |
|
| 61 | + if ($is_token_expired || !$is_signature_valid) { |
|
| 62 | + return FALSE; |
|
| 63 | + } else { |
|
| 64 | + return TRUE; |
|
| 65 | + } |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | function base64url_encode($data) { |
@@ -70,24 +70,24 @@ discard block |
||
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | function get_authorization_header(){ |
| 73 | - $superGlobal = new SuperGlobal(); |
|
| 74 | - $headers = null; |
|
| 73 | + $superGlobal = new SuperGlobal(); |
|
| 74 | + $headers = null; |
|
| 75 | 75 | |
| 76 | - if (null !== $superGlobal->get('Authorization', 'SERVER')) { |
|
| 77 | - $headers = trim($superGlobal->get('Authorization', 'SERVER')); |
|
| 78 | - } else if (null !== $superGlobal->get('HTTP_AUTHORIZATION', 'SERVER')) { //Nginx or fast CGI |
|
| 79 | - $headers = trim($superGlobal->get('HTTP_AUTHORIZATION', 'SERVER')); |
|
| 80 | - } else if (function_exists('apache_request_headers') === true) { |
|
| 81 | - $requestHeaders = (array) apache_request_headers(); |
|
| 82 | - // Server-side fix for bug in old Android versions (a nice side-effect of this fix means we don't care about capitalization for Authorization) |
|
| 83 | - $requestHeaders = array_combine(array_map('ucwords', array_keys($requestHeaders)), array_values($requestHeaders)); |
|
| 84 | - //print_r($requestHeaders); |
|
| 85 | - if (isset($requestHeaders['Authorization']) === true) { |
|
| 86 | - $headers = trim($requestHeaders['Authorization']); |
|
| 87 | - } |
|
| 88 | - } |
|
| 76 | + if (null !== $superGlobal->get('Authorization', 'SERVER')) { |
|
| 77 | + $headers = trim($superGlobal->get('Authorization', 'SERVER')); |
|
| 78 | + } else if (null !== $superGlobal->get('HTTP_AUTHORIZATION', 'SERVER')) { //Nginx or fast CGI |
|
| 79 | + $headers = trim($superGlobal->get('HTTP_AUTHORIZATION', 'SERVER')); |
|
| 80 | + } else if (function_exists('apache_request_headers') === true) { |
|
| 81 | + $requestHeaders = (array) apache_request_headers(); |
|
| 82 | + // Server-side fix for bug in old Android versions (a nice side-effect of this fix means we don't care about capitalization for Authorization) |
|
| 83 | + $requestHeaders = array_combine(array_map('ucwords', array_keys($requestHeaders)), array_values($requestHeaders)); |
|
| 84 | + //print_r($requestHeaders); |
|
| 85 | + if (isset($requestHeaders['Authorization']) === true) { |
|
| 86 | + $headers = trim($requestHeaders['Authorization']); |
|
| 87 | + } |
|
| 88 | + } |
|
| 89 | 89 | |
| 90 | - return $headers; |
|
| 90 | + return $headers; |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | function get_bearer_token() { |
@@ -104,8 +104,8 @@ discard block |
||
| 104 | 104 | |
| 105 | 105 | function get_bearer_data($jwt) { |
| 106 | 106 | // split the jwt |
| 107 | - $tokenParts = explode('.', $jwt); |
|
| 108 | - $payload = base64_decode($tokenParts[1]); |
|
| 107 | + $tokenParts = explode('.', $jwt); |
|
| 108 | + $payload = base64_decode($tokenParts[1]); |
|
| 109 | 109 | |
| 110 | 110 | // HEADER: Get the access token from the header |
| 111 | 111 | if (empty($payload) === false) { |