Repository navigation
lib/api: Allow Bearer authentication style with API key - #9002
Merged
Merged
Conversation
Currently, historically, we look for the `X-API-Key` header to authenticate with an API key. There's nothing wrong with this, but in some scenarios it's easier to produce an `Authorization` header with a `Bearer $token` content, which is nowadays more common. This change adds support for both, so that we will accept an API key either in our custom header or as a bearer token.
acolomb
reviewed
Jul 25, 2023
| t.Fatal("Getting /rest/system/config with API key should succeed, not", resp.Status) | ||
| } | ||
|
|
||
| // Calling on /rest with the API key as a bearer token should succeed |
Member
There was a problem hiding this comment.
Should have tests for wrong API keys? As this changes what is accepted, we should make sure nothing creeps in later that accepts too much.
Member
Author
There was a problem hiding this comment.
Added, and also improved & modernized the tests a little
AudriusButkevicius
approved these changes
Jul 26, 2023
calmh
added a commit
to syncthing/docs
that referenced
this pull request
Jul 26, 2023
calmh
added a commit
to calmh/syncthing
that referenced
this pull request
Jul 27, 2023
* main: cmd/strelaysrv: Handle accept error with debug set (fixes syncthing#9001) (syncthing#9004) lib/api: Fix data race in TestCSRFRequired (syncthing#9006) gui: Show full error for failed items (syncthing#9005) lib/api: Allow `Bearer` authentication style with API key (syncthing#9002)
calmh
added a commit
to calmh/syncthing
that referenced
this pull request
Aug 3, 2023
* main: build: Increase Go version to 1.20.7 lib/config: Allow sharing already encrypted folder with untrusted devices (fixes syncthing#8965) (syncthing#9012) gui: Use case-insensive and backslash-agnostic versions filter (fixes syncthing#7973) (syncthing#8995) gui, man, authors: Update docs, translations, and contributors build: Run govulncheck (fixes syncthing#8983) build: Run build & tests on main branch nightly build: Send test logs to Grafana Loki for statistics all: Refactor the protocol/model interface a bit (ref syncthing#8981) (syncthing#9007) lib/connections: Fix building with `-tags noquic` (syncthing#9009) gui: Fix tooltips on buttons inside button groups (ref syncthing#7984) (syncthing#9008) cmd/strelaysrv: Handle accept error with debug set (fixes syncthing#9001) (syncthing#9004) lib/api: Fix data race in TestCSRFRequired (syncthing#9006) gui: Show full error for failed items (syncthing#9005) lib/api: Allow `Bearer` authentication style with API key (syncthing#9002)
This file contains hidden or 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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Currently, historically, we look for the
X-API-Keyheader to authenticate with an API key. There's nothing wrong with this, but in some scenarios it's easier to produce anAuthorizationheader with aBearer $tokencontent, which is nowadays more common. This change adds support for both, so that we will accept an API key either in our custom header or as a bearer token.