feat: Adding bearer token - #7415
Conversation
|
Hello and thanks for lending a paw to Uptime Kuma! 🐻👋 |
aminoacidity
left a comment
There was a problem hiding this comment.
thanks for guidance. have made the changes based on similar pattern.
CommanderStorm
left a comment
There was a problem hiding this comment.
I am assuming this is done despite it not having been out of draft.
LGTM, thanks
There was a problem hiding this comment.
Pull request overview
Adds first-class Bearer token authentication for monitors by introducing a dedicated bearer_token field, wiring it into request header construction, and exposing a masked token input in the monitor editor UI.
Changes:
- Add
bearer_tokencolumn to themonitortable via a Knex migration. - Backend: include
Authorization: Bearer <token>whenauth_method === "bearer"for HTTP/keyword/json-query checks and Globalping. - Frontend: add “Bearer Token” auth method option and a masked
HiddenInputbound tomonitor.bearer_token.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
src/pages/EditMonitor.vue |
Adds “Bearer Token” auth option and masked token input for multiple monitor types. |
src/lang/en.json |
Adds i18n string for “Bearer Token”. |
server/server.js |
Persists bearer_token from incoming monitor payloads. |
server/monitor-types/globalping.js |
Adds Bearer header generation and merges it into request headers. |
server/model/monitor.js |
Adds Bearer header construction for HTTP/keyword/json-query monitor requests. |
db/knex_migrations/2026-05-20-0000-add-bearer-token.js |
Introduces the new DB column via migration. |
Comments suppressed due to low confidence (2)
server/model/monitor.js:487
- Test coverage: bearer auth is new behavior in the HTTP check path, but there are no unit tests asserting the header is constructed correctly (and omitted for empty tokens) and how it interacts with custom
monitor.headers(override order). Please add/extend backend tests for the Monitor HTTP request options to coverauth_method === "bearer".
// Bearer token auth
let bearerAuthHeader = {};
if (this.auth_method === "bearer") {
bearerAuthHeader = {
Authorization: "Bearer " + this.bearer_token,
};
}
server/monitor-types/globalping.js:568
getBearerAuthHeader()unconditionally returnsAuthorization: "Bearer " + monitor.bearer_tokenwhenauth_method === "bearer". Ifbearer_tokenis missing/empty, this producesBearer undefined/Bearerand will send a broken auth header. Please guard for a non-empty token and return{}otherwise (or treat it as a configuration error).
getBearerAuthHeader(monitor) {
if (monitor.auth_method !== "bearer") {
return {};
}
return {
Authorization: "Bearer " + monitor.bearer_token,
};
| @@ -2122,6 +2125,18 @@ | |||
| </div> | |||
| </template> | |||
|
|
|||
| <template v-else-if="monitor.authMethod === 'bearer'"> | |||
| <div class="my-3"> | |||
| <label for="ws-bearer-token" class="form-label">{{ $t("Token") }}</label> | |||
| <HiddenInput | |||
| id="ws-bearer-token" | |||
| v-model="monitor.bearer_token" | |||
| autocomplete="new-password" | |||
| :placeholder="$t('Token')" | |||
| /> | |||
| </div> | |||
| if (this.auth_method === "bearer") { | ||
| bearerAuthHeader = { | ||
| Authorization: "Bearer " + this.bearer_token, | ||
| }; |
@CommanderStorm - The first contribution document said that we should'nt change from draft unless all steps are passed. On my end it showed that it was pending approval workflow and also the auto test steps were queued up and not run sucess. But yet, all changes were done and tested. |
|
@aminoacidity congrats on your first contribution to Uptime Kuma! 🐻 |
|
Nah, this is neither a "major feature", nor a significant change. But Copilot had good suggestions.. |
Yes, saw that. Just submittng the PR for the ws portion. |
Summary
Add dedicated Bearer token authentication field for HTTP monitors. Previously users had to manually add
Authorization: Bearer <token>as a custom header — this adds a first-class masked input.Changes:
bearer_tokencolumn onmonitortable (knex migration)Authorization: Bearer <token>header whenauth_method === "bearer"HiddenInputfor the tokenResolves #3963
Please follow this checklist to avoid unnecessary back and forth (click to expand)
I understand that I am responsible for and able to explain every line of code I submit.
Screenshots for Visual Changes