-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New API feature: allow API clients to authenticate via authentication header #1367
Merged
josecelano
merged 2 commits into
torrust:develop
from
josecelano:727-remove-api-token-from-logs
Mar 10, 2025
Merged
New API feature: allow API clients to authenticate via authentication header #1367
josecelano
merged 2 commits into
torrust:develop
from
josecelano:727-remove-api-token-from-logs
Mar 10, 2025
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f3005cc
to
ccf9880
Compare
ccf9880
to
3f915a2
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #1367 +/- ##
===========================================
- Coverage 81.37% 81.31% -0.06%
===========================================
Files 229 229
Lines 16448 16519 +71
Branches 16448 16519 +71
===========================================
+ Hits 13385 13433 +48
- Misses 2821 2840 +19
- Partials 242 246 +4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
The API allos client authentication via a `token` parameter in the URL query: ```console curl http://0.0.0.0:1212/api/v1/stats?token=MyAccessToken | jq ``` Now it's also possible to do it via Authentication Header: ```console curl -H "Authorization: Bearer MyAccessToken" http://0.0.0.0:1212/api/v1/stats | jq ``` This is to avoid leaking the token in logs, proxies, etc. For now, it's only optional and recommendable. It could be mandatory in future major API versions.
3f915a2
to
084beb2
Compare
Instead of passing the `token` via GET param. The server supports both. Since we have not released any version crate for the client yet we can use the header by deafault which is more secure.
ACK 34f2f43 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
- Developer -
Torrust Improvement Experience
API
Related to the Tracker API
Enhancement / Feature Request
Something New
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The API allows client authentication via a
token
parameter in the URL query:curl http://0.0.0.0:1212/api/v1/stats?token=MyAccessToken | jq
Now it's also possible to do it via an
Authentication Header
:curl -H "Authorization: Bearer MyAccessToken" http://0.0.0.0:1212/api/v1/stats | jq
This is to avoid leaking the token in logs, etc.
For now, it's only optional and recommendable. It could be mandatory in future major API versions.
The API client uses by default the
Authentication Header
. It could be a breaking change if you use the newer client witn an old API that does not support it. However we have not released any crate for the API client yet. And we are still using a different client in the Index.