Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 27, 2025

Monitoring tools like Uptime-Kuma require non-expiring tokens for OAuth2 authentication. Currently all tokens expire based on sessionTimeout, breaking automated monitoring workflows.

Changes

Backend

  • Add API token storage in user model with pbkdf2 hashing
  • Add /api/users/api-tokens endpoints (POST/GET/DELETE)
  • Implement JwtOrApiTokenGuard supporting both JWT and 64-char hex API tokens
  • Update status controller to accept API token authentication

Frontend

  • Add API tokens modal in Users page (key icon)
  • Token creation with custom naming and one-time display
  • Token management UI showing creation date and last usage

Security

  • Tokens hashed with pbkdf2 before storage
  • Timing-safe comparison during validation
  • Last usage timestamp tracking

Usage

# Generate token via UI or API
POST /api/users/api-tokens
Authorization: Bearer <jwt>
{"name": "Uptime-Kuma"}

# Use persistent token for monitoring
GET /api/status/homebridge
Authorization: Bearer <64-char-hex-token>

Token authentication works alongside existing JWT auth without breaking changes.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • 224.0.0.251

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Persistent OAuth2 Token for API Monitoring (e.g., Uptime-Kuma Integration)</issue_title>
<issue_description>### Feature Description

Description

Including a closed issue #2043 with similar request/question for reference.

I would like to configure Uptime-Kuma to monitor my Homebridge instance status via the REST API endpoint: /api/status/homebridge.

Uptime-Kuma supports OAuth2 authentication, but as far as I understand, Homebridge currently expires all tokens that are created. This makes long-term monitoring difficult since tokens need to be refreshed manually.

Here’s an example of the Uptime-Kuma OAuth2 configuration screen:
Image

Request

It would be great if Homebridge provided the option to generate and copy OAuth2 tokens directly from the UI for use in third-party monitoring tools like Uptime-Kuma.

Use Case:
This would allow automated uptime and health monitoring of Homebridge instances without the need for token refresh workflows or manual intervention.

Environment

  • Homebridge version: 1.11.0
  • Homebridge UI version: 5.8.0
  • Node.js version: 22.21.0
  • Operating system: Debian 13 (trixie)</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 4 commits October 27, 2025 15:46
- Add API token storage in user records
- Create endpoints for generating/managing tokens
- Implement API token validation in authentication guard
- Add tests for token functionality

Co-authored-by: bwp91 <[email protected]>
- Create API tokens management modal component
- Add API token button to users page
- Add translations for API token UI
- All tests passing (303/303)

Co-authored-by: bwp91 <[email protected]>
- Update status controller to use JwtOrApiTokenGuard
- Import AuthModule in StatusModule
- API tokens now work with /api/status/* endpoints
- Manual testing verified API token access works
- All tests passing (303/303)

Co-authored-by: bwp91 <[email protected]>
Copilot AI changed the title [WIP] Add persistent OAuth2 token support for API monitoring Add persistent API tokens for third-party monitoring integration Oct 27, 2025
Copilot AI requested a review from bwp91 October 27, 2025 16:35
Copilot finished work on behalf of bwp91 October 27, 2025 16:35
@bwp91 bwp91 force-pushed the beta-5.8.1 branch 3 times, most recently from 974ae19 to 4120ea1 Compare October 30, 2025 01:16
@bwp91 bwp91 changed the base branch from beta-5.8.1 to beta-5.9.1 November 1, 2025 23:19
@bwp91 bwp91 force-pushed the beta-5.9.1 branch 13 times, most recently from 64dbe3a to ba0b41c Compare November 8, 2025 01:13
@bwp91 bwp91 force-pushed the beta-5.9.1 branch 3 times, most recently from 501f284 to c50905f Compare November 16, 2025 10:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants