feat: Adding bearer token by aminoacidity · Pull Request #7415 · louislam/uptime-kuma · GitHub
Skip to content

feat: Adding bearer token - #7415

Merged
CommanderStorm merged 6 commits into
louislam:masterfrom
aminoacidity:master
May 25, 2026
Merged

feat: Adding bearer token #7415
CommanderStorm merged 6 commits into
louislam:masterfrom
aminoacidity:master

Conversation

@aminoacidity

@aminoacidity aminoacidity commented May 20, 2026

Copy link
Copy Markdown
Contributor

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:

  • New bearer_token column on monitor table (knex migration)
  • Server-side: construct Authorization: Bearer <token> header when auth_method === "bearer"
  • Frontend: "Bearer Token" option in auth method dropdown for HTTP/KW, WebSocket, and Globalping monitors, with masked
    HiddenInput for the token

Resolves #3963

Please follow this checklist to avoid unnecessary back and forth (click to expand)
  • ⚠️ If there are Breaking change (a fix or feature that alters existing functionality in a way that could cause issues) I have called them out
  • 🧠 I have disclosed any use of LLMs/AI in this contribution and reviewed all generated content.
    I understand that I am responsible for and able to explain every line of code I submit.
  • 🔍 Any UI changes adhere to visual style of this project.
  • 🛠️ I have self-reviewed and self-tested my code to ensure it works as expected.
  • 📝 I have commented my code, especially in hard-to-understand areas (e.g., using JSDoc for methods).
  • 🤖 I added or updated automated tests where appropriate.
  • 📄 Documentation updates are included (if applicable).
  • 🧰 Dependency updates are listed and explained.
  • ⚠️ CI passes and is green.

Screenshots for Visual Changes

image image

@github-actions

Copy link
Copy Markdown
Contributor

Hello and thanks for lending a paw to Uptime Kuma! 🐻👋
As this is your first contribution, please be sure to check out our Pull Request guidelines.
In particular: - Mark your PR as Draft while you’re still making changes - Mark it as Ready for review once it’s fully ready
If you have any design or process questions, feel free to ask them right here in this pull request - unclear documentation is a bug too.

@aminoacidity aminoacidity changed the title Adding bearer token feat: Adding bearer token May 20, 2026
@aminoacidity
aminoacidity marked this pull request as draft May 20, 2026 09:01
@
feat: add Bearer token authentication for HTTP monitors

Add bearer_token column, backend auth header construction, and
frontend UI with masked token input in EditMonitor.vue for HTTP,
Keyword, JSON Query, WebSocket, and Globalping monitor types.
@
@aminoacidity
aminoacidity marked this pull request as ready for review May 20, 2026 09:28
@github-actions github-actions Bot added the pr:needs review this PR needs a review by maintainers or other community members label May 20, 2026
Comment thread src/pages/EditMonitor.vue
@CommanderStorm
CommanderStorm marked this pull request as draft May 20, 2026 20:12
@aminoacidity
aminoacidity marked this pull request as ready for review May 22, 2026 03:04
@aminoacidity
aminoacidity marked this pull request as draft May 22, 2026 05:08

@aminoacidity aminoacidity left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for guidance. have made the changes based on similar pattern.

@CommanderStorm
CommanderStorm marked this pull request as ready for review May 25, 2026 02:44
Copilot AI review requested due to automatic review settings May 25, 2026 02:44

@CommanderStorm CommanderStorm left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am assuming this is done despite it not having been out of draft.
LGTM, thanks

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_token column to the monitor table via a Knex migration.
  • Backend: include Authorization: Bearer <token> when auth_method === "bearer" for HTTP/keyword/json-query checks and Globalping.
  • Frontend: add “Bearer Token” auth method option and a masked HiddenInput bound to monitor.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 cover auth_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 returns Authorization: "Bearer " + monitor.bearer_token when auth_method === "bearer". If bearer_token is missing/empty, this produces Bearer undefined/Bearer and 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,
        };

Comment thread src/pages/EditMonitor.vue
Comment on lines 2096 to +2137
@@ -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>
Comment thread server/model/monitor.js
Comment on lines +483 to +486
if (this.auth_method === "bearer") {
bearerAuthHeader = {
Authorization: "Bearer " + this.bearer_token,
};
Comment thread server/monitor-types/globalping.js
Comment thread db/knex_migrations/2026-05-20-0000-add-bearer-token.js
@aminoacidity

Copy link
Copy Markdown
Contributor Author

I am assuming this is done despite it not having been out of draft. LGTM, thanks

@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.

@CommanderStorm
CommanderStorm merged commit 68d87ca into louislam:master May 25, 2026
29 of 30 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

@aminoacidity congrats on your first contribution to Uptime Kuma! 🐻
We hope you enjoy contributing to our project and look forward to seeing more of your work in the future! If you want to see your contribution in action, please see our nightly builds here.

@CommanderStorm

Copy link
Copy Markdown
Collaborator

Nah, this is neither a "major feature", nor a significant change.

But Copilot had good suggestions..
Could you maybe do a PR to fix the websocket monitor bug?

@aminoacidity

Copy link
Copy Markdown
Contributor Author

Nah, this is neither a "major feature", nor a significant change.

But Copilot had good suggestions.. Could you maybe do a PR to fix the websocket monitor bug?

Yes, saw that. Just submittng the PR for the ws portion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr:needs review this PR needs a review by maintainers or other community members

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for Bearer Authentication header

4 participants