Skip to content

Commit ed4b1cf

Browse files
committed
Merge branch 'rename-brave-key' into staging
2 parents 2e5fc58 + 0e11165 commit ed4b1cf

9 files changed

Lines changed: 29 additions & 29 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ View API documentation at http://localhost:8080/swagger/index.html.
3535
| LOG_LEVEL | No | Logging level (default: info) |
3636
| OPAQUE_FAKE_RECORD | No | Use OPAQUE fake record to prevent client enumeration attacks |
3737
| VERIFY_FRONTEND_URL | No | Frontend URL to use in verification emails |
38-
| BRAVE_SERVICES_KEY | No | Comma-separated list of services keys to check against (via the `Brave-Key` header) for all requests |
38+
| BRAVE_SERVICES_KEY | No | Comma-separated list of services keys to check against (via the `BraveServiceKey` header) for all requests |
3939
| WEBHOOK_KEYS | No | A list of URLs and corresponding API keys for sending account event webhooks, delimited by a comma. Each entry should use the following format: `webhook url=webhook api key` |
4040
| DEV_ENDPOINTS_ENABLED | No | Enable the development-only endpoints |
4141
| ALLOWED_ORIGINS | No | List of allowed origins for CORS, separated by comma |

controllers/accounts.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ func checkVerificationStatusAndIntent(w http.ResponseWriter, r *http.Request, ve
255255
// @Accept json
256256
// @Produce json
257257
// @Param Authorization header string false "Bearer + verification token (optional if newAccountEmail is provided)"
258-
// @Param Brave-Key header string false "Brave services key (if one is configured)"
258+
// @Param BraveServiceKey header string false "Brave services key (if one is configured)"
259259
// @Param request body RegistrationRequest true "Registration request"
260260
// @Success 200 {object} RegistrationResponse
261261
// @Failure 400 {object} util.ErrorResponse
@@ -405,7 +405,7 @@ func (ac *AccountsController) postPasswordSetup(ctx context.Context, accountID u
405405
// @Accept json
406406
// @Produce json
407407
// @Param Authorization header string true "Bearer + verification token"
408-
// @Param Brave-Key header string false "Brave services key (if one is configured)"
408+
// @Param BraveServiceKey header string false "Brave services key (if one is configured)"
409409
// @Param request body RegistrationRecord true "Registration record"
410410
// @Success 200 {object} PasswordFinalizeResponse
411411
// @Failure 400 {object} util.ErrorResponse
@@ -485,7 +485,7 @@ func (ac *AccountsController) SetupPasswordFinalize(w http.ResponseWriter, r *ht
485485
// @Accept json
486486
// @Produce json
487487
// @Param Authorization header string true "Bearer + verification token"
488-
// @Param Brave-Key header string false "Brave services key (if one is configured)"
488+
// @Param BraveServiceKey header string false "Brave services key (if one is configured)"
489489
// @Param request body services.TwoFAAuthRequest true "2FA verification request"
490490
// @Success 200 {object} RegistrationFinalize2FAResponse
491491
// @Failure 400 {object} util.ErrorResponse
@@ -562,7 +562,7 @@ func (ac *AccountsController) SetupPasswordFinalize2FA(w http.ResponseWriter, r
562562
// @Accept json
563563
// @Produce json
564564
// @Param Authorization header string true "Bearer + auth token"
565-
// @Param Brave-Key header string false "Brave services key (if one is configured)"
565+
// @Param BraveServiceKey header string false "Brave services key (if one is configured)"
566566
// @Param request body TwoFAInitRequest true "2FA initialization request"
567567
// @Success 200 {object} TwoFAInitResponse
568568
// @Failure 400 {object} util.ErrorResponse
@@ -618,7 +618,7 @@ func (ac *AccountsController) SetupTOTPInit(w http.ResponseWriter, r *http.Reque
618618
// @Accept json
619619
// @Produce json
620620
// @Param Authorization header string true "Bearer + auth token"
621-
// @Param Brave-Key header string false "Brave services key (if one is configured)"
621+
// @Param BraveServiceKey header string false "Brave services key (if one is configured)"
622622
// @Param request body TwoFAFinalizeRequest true "2FA finalization request"
623623
// @Success 200 {object} TwoFAFinalizeResponse
624624
// @Failure 400 {object} util.ErrorResponse
@@ -681,7 +681,7 @@ func (ac *AccountsController) SetupTOTPFinalize(w http.ResponseWriter, r *http.R
681681
// @Tags Accounts
682682
// @Produce json
683683
// @Param Authorization header string true "Bearer + auth token"
684-
// @Param Brave-Key header string false "Brave services key (if one is configured)"
684+
// @Param BraveServiceKey header string false "Brave services key (if one is configured)"
685685
// @Success 204 "No Content"
686686
// @Failure 401 {object} util.ErrorResponse
687687
// @Failure 403 {object} util.ErrorResponse
@@ -715,7 +715,7 @@ func (ac *AccountsController) DeleteAccount(w http.ResponseWriter, r *http.Reque
715715
// @Tags Accounts
716716
// @Produce json
717717
// @Param Authorization header string true "Bearer + auth token"
718-
// @Param Brave-Key header string false "Brave services key (if one is configured)"
718+
// @Param BraveServiceKey header string false "Brave services key (if one is configured)"
719719
// @Success 200 {object} datastore.TwoFADetails
720720
// @Failure 401 {object} util.ErrorResponse
721721
// @Failure 500 {object} util.ErrorResponse
@@ -738,7 +738,7 @@ func (ac *AccountsController) GetTwoFASettings(w http.ResponseWriter, r *http.Re
738738
// @Tags Accounts
739739
// @Produce json
740740
// @Param Authorization header string true "Bearer + auth token"
741-
// @Param Brave-Key header string false "Brave services key (if one is configured)"
741+
// @Param BraveServiceKey header string false "Brave services key (if one is configured)"
742742
// @Success 204 "No Content"
743743
// @Failure 401 {object} util.ErrorResponse
744744
// @Failure 500 {object} util.ErrorResponse
@@ -760,7 +760,7 @@ func (ac *AccountsController) DisableTOTP(w http.ResponseWriter, r *http.Request
760760
// @Tags Accounts
761761
// @Produce json
762762
// @Param Authorization header string true "Bearer + auth token"
763-
// @Param Brave-Key header string false "Brave services key (if one is configured)"
763+
// @Param BraveServiceKey header string false "Brave services key (if one is configured)"
764764
// @Success 200 {object} RecoveryKeyResponse
765765
// @Failure 401 {object} util.ErrorResponse
766766
// @Failure 500 {object} util.ErrorResponse
@@ -786,7 +786,7 @@ func (ac *AccountsController) RegenerateRecoveryKey(w http.ResponseWriter, r *ht
786786
// @Tags Accounts
787787
// @Produce json
788788
// @Param Authorization header string true "Bearer + auth token"
789-
// @Param Brave-Key header string false "Brave services key (if one is configured)"
789+
// @Param BraveServiceKey header string false "Brave services key (if one is configured)"
790790
// @Success 204 "No Content"
791791
// @Failure 401 {object} util.ErrorResponse
792792
// @Failure 500 {object} util.ErrorResponse

controllers/auth.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ func (ac *AuthController) Router(authMiddleware func(http.Handler) http.Handler,
232232
// @Tags Auth
233233
// @Produce json
234234
// @Param Authorization header string true "Bearer + auth token"
235-
// @Param Brave-Key header string false "Brave services key (if one is configured)"
235+
// @Param BraveServiceKey header string false "Brave services key (if one is configured)"
236236
// @Success 200 {object} ValidateTokenResponse
237237
// @Failure 401 {object} util.ErrorResponse
238238
// @Failure 403 {object} util.ErrorResponse
@@ -272,7 +272,7 @@ func (ac *AuthController) Validate(w http.ResponseWriter, r *http.Request) {
272272
// @Accept json
273273
// @Produce json
274274
// @Param request body LoginInitRequest true "login init request"
275-
// @Param Brave-Key header string false "Brave services key (if one is configured)"
275+
// @Param BraveServiceKey header string false "Brave services key (if one is configured)"
276276
// @Success 200 {object} LoginInitResponse
277277
// @Failure 400 {object} util.ErrorResponse
278278
// @Failure 401 {object} util.ErrorResponse
@@ -366,7 +366,7 @@ func (ac *AuthController) createSessionAndToken(accountID uuid.UUID, userAgent s
366366
// @Accept json
367367
// @Produce json
368368
// @Param Authorization header string true "Bearer + login state token"
369-
// @Param Brave-Key header string false "Brave services key (if one is configured)"
369+
// @Param BraveServiceKey header string false "Brave services key (if one is configured)"
370370
// @Param request body LoginFinalizeRequest true "login finalize request"
371371
// @Success 200 {object} LoginFinalizeResponse
372372
// @Failure 400 {object} util.ErrorResponse
@@ -443,7 +443,7 @@ func (ac *AuthController) LoginFinalize(w http.ResponseWriter, r *http.Request)
443443
// @Accept json
444444
// @Produce json
445445
// @Param Authorization header string true "Bearer + login state token"
446-
// @Param Brave-Key header string false "Brave services key (if one is configured)"
446+
// @Param BraveServiceKey header string false "Brave services key (if one is configured)"
447447
// @Param request body services.TwoFAAuthRequest true "2FA verification request"
448448
// @Success 200 {object} LoginFinalize2FAResponse
449449
// @Failure 400 {object} util.ErrorResponse
@@ -555,7 +555,7 @@ func (ac *AuthController) CreateServiceToken(w http.ResponseWriter, r *http.Requ
555555
// @Description Logs out the current session by deleting it
556556
// @Tags Auth
557557
// @Param Authorization header string true "Bearer + auth token"
558-
// @Param Brave-Key header string false "Brave services key (if one is configured)"
558+
// @Param BraveServiceKey header string false "Brave services key (if one is configured)"
559559
// @Success 204 "No Content"
560560
// @Failure 401 {object} util.ErrorResponse
561561
// @Failure 500 {object} util.ErrorResponse

controllers/sessions.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func NewSessionsController(datastore *datastore.Datastore) *SessionsController {
2727
// @Tags Sessions
2828
// @Produce json
2929
// @Param Authorization header string true "Bearer + auth token"
30-
// @Param Brave-Key header string false "Brave services key (if one is configured)"
30+
// @Param BraveServiceKey header string false "Brave services key (if one is configured)"
3131
// @Success 200 {array} datastore.Session
3232
// @Failure 401 {object} util.ErrorResponse
3333
// @Failure 500 {object} util.ErrorResponse
@@ -49,7 +49,7 @@ func (sc *SessionsController) ListSessions(w http.ResponseWriter, r *http.Reques
4949
// @Description Deletes a specific session by ID
5050
// @Tags Sessions
5151
// @Param Authorization header string true "Bearer + auth token"
52-
// @Param Brave-Key header string false "Brave services key (if one is configured)"
52+
// @Param BraveServiceKey header string false "Brave services key (if one is configured)"
5353
// @Param id path string true "Session ID (UUID)"
5454
// @Success 204 "No Content"
5555
// @Failure 400 {object} util.ErrorResponse

controllers/user_keys.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ func (uc *UserKeysController) Router(authMiddleware func(http.Handler) http.Hand
9696
// @Accept json
9797
// @Produce json
9898
// @Param Authorization header string true "Bearer + auth token"
99-
// @Param Brave-Key header string false "Brave services key (if one is configured)"
99+
// @Param BraveServiceKey header string false "Brave services key (if one is configured)"
100100
// @Success 200 {array} UserKey
101101
// @Failure 401 {object} util.ErrorResponse
102102
// @Failure 403 {object} util.ErrorResponse
@@ -125,7 +125,7 @@ func (uc *UserKeysController) ListKeys(w http.ResponseWriter, r *http.Request) {
125125
// @Accept json
126126
// @Produce json
127127
// @Param Authorization header string true "Bearer + auth token"
128-
// @Param Brave-Key header string false "Brave services key (if one is configured)"
128+
// @Param BraveServiceKey header string false "Brave services key (if one is configured)"
129129
// @Param service path string true "Service name"
130130
// @Param keyName path string true "Key name"
131131
// @Success 200 {object} UserKey
@@ -158,7 +158,7 @@ func (uc *UserKeysController) GetKey(w http.ResponseWriter, r *http.Request) {
158158
// @Accept json
159159
// @Produce json
160160
// @Param Authorization header string true "Bearer + auth token"
161-
// @Param Brave-Key header string false "Brave services key (if one is configured)"
161+
// @Param BraveServiceKey header string false "Brave services key (if one is configured)"
162162
// @Param key body UserKeyStoreRequest true "Key to save"
163163
// @Success 204 "Key saved"
164164
// @Failure 400 {object} util.ErrorResponse

controllers/verification.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ func (vc *VerificationController) Router(verificationAuthMiddleware func(http.Ha
128128
// @Accept json
129129
// @Produce json
130130
// @Param Authorization header string false "Bearer + auth token (required for change_password intent)"
131-
// @Param Brave-Key header string false "Brave services key (if one is configured)"
131+
// @Param BraveServiceKey header string false "Brave services key (if one is configured)"
132132
// @Param request body VerifyInitRequest true "Verification request params"
133133
// @Success 200 {object} VerifyInitResponse
134134
// @Failure 400 {object} util.ErrorResponse
@@ -301,7 +301,7 @@ func (vc *VerificationController) VerifyComplete(w http.ResponseWriter, r *http.
301301
// @Accept json
302302
// @Produce json
303303
// @Param Authorization header string true "Bearer + verification token"
304-
// @Param Brave-Key header string false "Brave services key (if one is configured)"
304+
// @Param BraveServiceKey header string false "Brave services key (if one is configured)"
305305
// @Param request body VerifyResultRequest true "Auth token request params"
306306
// @Success 200 {object} VerifyResultResponse
307307
// @Failure 400 {object} util.ErrorResponse

middleware/auth.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const (
2222
ContextVerification = contextKey("verification")
2323

2424
braveServicesKeyEnv = "BRAVE_SERVICES_KEY"
25-
braveServicesKeyHeader = "brave-key"
25+
braveServicesKeyHeader = "braveservicekey"
2626
)
2727

2828
func AuthMiddleware(jwtService *services.JWTService, ds *datastore.Datastore, minSessionVersion int, enforceAccountsServiceName bool, required bool) func(http.Handler) http.Handler {

middleware/auth_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,13 @@ func (suite *MiddlewareTestSuite) TestServicesKeyMiddleware() {
152152

153153
// Test valid key
154154
req := httptest.NewRequest("GET", "/", nil)
155-
req.Header.Set("brave-key", testKey)
155+
req.Header.Set("braveservicekey", testKey)
156156
resp := util.ExecuteTestRequest(req, mw(handler))
157157
suite.Equal(http.StatusOK, resp.Code)
158158

159159
// Test invalid key
160160
req = httptest.NewRequest("GET", "/", nil)
161-
req.Header.Set("brave-key", "wrong-key")
161+
req.Header.Set("braveservicekey", "wrong-key")
162162
resp = util.ExecuteTestRequest(req, mw(handler))
163163
suite.Equal(http.StatusUnauthorized, resp.Code)
164164

@@ -173,13 +173,13 @@ func (suite *MiddlewareTestSuite) TestServicesKeyMiddleware() {
173173

174174
// Test first valid key
175175
req = httptest.NewRequest("GET", "/", nil)
176-
req.Header.Set("brave-key", "test-key1")
176+
req.Header.Set("braveservicekey", "test-key1")
177177
resp = util.ExecuteTestRequest(req, mw(handler))
178178
suite.Equal(http.StatusOK, resp.Code)
179179

180180
// Test second valid key
181181
req = httptest.NewRequest("GET", "/", nil)
182-
req.Header.Set("brave-key", "test-key2")
182+
req.Header.Set("braveservicekey", "test-key2")
183183
resp = util.ExecuteTestRequest(req, mw(handler))
184184
suite.Equal(http.StatusOK, resp.Code)
185185

misc/test-client-rust/src/util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub fn make_request(
3434
request_builder = request_builder.header("Authorization", format!("Bearer {token}"));
3535
}
3636
if let Some(key) = args.services_key.as_ref() {
37-
request_builder = request_builder.header("brave-key", key)
37+
request_builder = request_builder.header("braveservicekey", key)
3838
}
3939

4040
let response = request_builder.send().expect("Failed to send request");

0 commit comments

Comments
 (0)