Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
typo3
qfq
Commits
f920fc54
Commit
f920fc54
authored
Apr 06, 2021
by
Carsten Rose
Browse files
HTTP Header: Add 'X-Api-Key'. Fix problem for token without argument name. Update doc.
parent
6c589520
Pipeline
#5104
passed with stages
in 5 minutes and 7 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Documentation-develop/REST.md
View file @
f920fc54
...
...
@@ -95,16 +95,13 @@ Details:
Header Token Authorization
==========================
Example:
Example:
:
curl -X GET -H 'Authorization: token="mySuperSecretToken"' "http://localhost/qfq/typo3conf/ext/qfq/Classes/Api/rest.php/restPerson/"
or
curl -X GET -H 'X-Api-Key: token="mySuperSecretToken"' "http://localhost/qfq/typo3conf/ext/qfq/Classes/Api/rest.php/restPerson/"
*
Access the token via
``{{Authorization:C:alnumx}}``
or
``{{X-Api-Key:C:alnumx}}``
.
*
The
string
``token
=
``
is not used at all.
*
The
argument
``token``
can be anything and
is not used at all.
Static token
------------
...
...
Documentation/Store.rst
View file @
f920fc54
...
...
@@ -202,7 +202,12 @@ Store: *CLIENT* - C
+-------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
| Authorization | Value of the HTTP Header 'Authorization'. This is typically not set. Mostly used for authentication of REST requests |
+-------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
| X-Api-Key | Value of the HTTP Header 'X-Api-Key'. This is typically not set. |
+-------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
.. tip::
Variable names are case sensitive.
.. _STORE_TYPO3:
...
...
extension/Classes/Core/Store/Client.php
View file @
f920fc54
...
...
@@ -68,8 +68,9 @@ class Client {
}
/**
* Check for Header 'Authorization' and 'X-Api-Key' - no other headers will be checked.
* Explode the given header by '='. Use the header name as key (purge string 'token' from example)
* Check for Header 'Authorization' and 'X-Api-Key' - no other headers will be copied here.
* Explode the given header by '=' or ':'. Use the header name as key (purge string 'token' from example)
* Example Header: 'Authorization: token=1234', 'Authorization: 1234', 'Authorization: token:1234'
*
* @return array
*/
...
...
@@ -88,13 +89,12 @@ class Client {
if
(
isset
(
$headers
[
$key
]))
{
$line
=
$headers
[
$key
];
// In case the key/value is separated by ':' instead of '='
$delimiter
=
(
strpos
(
$line
,
'='
)
===
false
)
?
':'
:
'='
;
// Header: 'Authorization:
Token
token=1234'
// Header: 'Authorization: token=1234'
$split
=
explode
(
$delimiter
,
$line
,
2
);
if
(
isset
(
$split
[
1
]))
{
$arr
[
$key
]
=
OnString
::
trimQuote
(
trim
(
$split
[
1
]));
}
$arr
[
$key
]
=
OnString
::
trimQuote
(
trim
(
$split
[
1
]
??
$split
[
0
]));
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment