[PR #306] [MERGED] Introduce API keys and enable remote control API #1373

Closed
opened 2025-12-29 02:29:51 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/juanfont/headscale/pull/306
Author: @kradalby
Created: 2/2/2022
Status: Merged
Merged: 2/15/2022
Merged by: @kradalby

Base: mainHead: apiwork


📝 Commits (10+)

  • 9dc2058 Add api key data model and helpers
  • 70d82ea Add migration for new data model
  • b8e9024 Add proto model for api key
  • b1a9b1a Generate code from proto
  • f9137f3 Create helper functions around gRPC interface
  • b4259fc Add helper function for colouring expiries
  • 1fd57a3 Add apikeys command to create, list and expire
  • 6e14fdf More reusable stuff in cli
  • 05db1b7 Formatting and improving logs for config loading
  • e8e573d Add apikeys command integration test

📊 Changes

34 files changed (+2450 additions, -373 deletions)

View changed files

📝 CHANGELOG.md (+3 -0)
api_key.go (+164 -0)
api_key_test.go (+89 -0)
📝 app.go (+176 -133)
cmd/headscale/cli/api_key.go (+183 -0)
📝 cmd/headscale/cli/preauthkeys.go (+1 -1)
cmd/headscale/cli/pterm_style.go (+19 -0)
📝 cmd/headscale/cli/utils.go (+39 -15)
📝 cmd/headscale/headscale.go (+1 -1)
📝 cmd/headscale/headscale_test.go (+5 -1)
📝 config-example.yaml (+13 -0)
📝 db.go (+5 -0)
📝 dns.go (+9 -2)
📝 dns_test.go (+5 -1)
📝 docs/README.md (+1 -0)
docs/remote-cli.md (+100 -0)
gen/go/headscale/v1/apikey.pb.go (+559 -0)
📝 gen/go/headscale/v1/device.pb.go (+4 -3)
📝 gen/go/headscale/v1/headscale.pb.go (+230 -193)
📝 gen/go/headscale/v1/headscale.pb.gw.go (+227 -0)

...and 14 more files

📄 Description

This PR resolves #221, adding API key support to headscale allowing user to control headscale with the binary from a remote workstation.

While this PR "activates" the HTTP API, it has not been tested at all.

Test help would be appreciated :)

  • read the CONTRIBUTING guidelines
  • raised a GitHub issue or discussed it on the projects chat beforehand
  • added unit tests
  • added integration tests
  • updated documentation if needed
  • updated CHANGELOG.md

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/juanfont/headscale/pull/306 **Author:** [@kradalby](https://github.com/kradalby) **Created:** 2/2/2022 **Status:** ✅ Merged **Merged:** 2/15/2022 **Merged by:** [@kradalby](https://github.com/kradalby) **Base:** `main` ← **Head:** `apiwork` --- ### 📝 Commits (10+) - [`9dc2058`](https://github.com/juanfont/headscale/commit/9dc20580c781e24206bdfcebb14761e07621bc6b) Add api key data model and helpers - [`70d82ea`](https://github.com/juanfont/headscale/commit/70d82ea18489a7875dff5668f6dce5335a5cc3fa) Add migration for new data model - [`b8e9024`](https://github.com/juanfont/headscale/commit/b8e9024845d4b86f4d8a525522bb7c9226e60f8b) Add proto model for api key - [`b1a9b1a`](https://github.com/juanfont/headscale/commit/b1a9b1ada1c49023ae72a2210089dd486f1524ef) Generate code from proto - [`f9137f3`](https://github.com/juanfont/headscale/commit/f9137f3bb0d8c89ff7b39aad91afecb30c6bc567) Create helper functions around gRPC interface - [`b4259fc`](https://github.com/juanfont/headscale/commit/b4259fcd7933ee4423f98fe508c023dd4bcf2273) Add helper function for colouring expiries - [`1fd57a3`](https://github.com/juanfont/headscale/commit/1fd57a3375ac20590e1a588ffb7122976107ffd0) Add apikeys command to create, list and expire - [`6e14fdf`](https://github.com/juanfont/headscale/commit/6e14fdf0d3efa431b076180bdab465fb2e102641) More reusable stuff in cli - [`05db1b7`](https://github.com/juanfont/headscale/commit/05db1b710935d0b5e1b09f52b2cf2ed88b40f810) Formatting and improving logs for config loading - [`e8e573d`](https://github.com/juanfont/headscale/commit/e8e573de627323620b64ebd13435ba0d6faa2a8a) Add apikeys command integration test ### 📊 Changes **34 files changed** (+2450 additions, -373 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+3 -0) ➕ `api_key.go` (+164 -0) ➕ `api_key_test.go` (+89 -0) 📝 `app.go` (+176 -133) ➕ `cmd/headscale/cli/api_key.go` (+183 -0) 📝 `cmd/headscale/cli/preauthkeys.go` (+1 -1) ➕ `cmd/headscale/cli/pterm_style.go` (+19 -0) 📝 `cmd/headscale/cli/utils.go` (+39 -15) 📝 `cmd/headscale/headscale.go` (+1 -1) 📝 `cmd/headscale/headscale_test.go` (+5 -1) 📝 `config-example.yaml` (+13 -0) 📝 `db.go` (+5 -0) 📝 `dns.go` (+9 -2) 📝 `dns_test.go` (+5 -1) 📝 `docs/README.md` (+1 -0) ➕ `docs/remote-cli.md` (+100 -0) ➕ `gen/go/headscale/v1/apikey.pb.go` (+559 -0) 📝 `gen/go/headscale/v1/device.pb.go` (+4 -3) 📝 `gen/go/headscale/v1/headscale.pb.go` (+230 -193) 📝 `gen/go/headscale/v1/headscale.pb.gw.go` (+227 -0) _...and 14 more files_ </details> ### 📄 Description <!-- Please tick if the following things apply. You… --> This PR resolves #221, adding API key support to `headscale` allowing user to control headscale with the binary from a remote workstation. While this PR "activates" the HTTP API, it has not been tested at all. Test help would be appreciated :) - [x] read the [CONTRIBUTING guidelines](README.md#user-content-contributing) - [x] raised a GitHub issue or discussed it on the projects chat beforehand - [x] added unit tests - [x] added integration tests - [x] updated documentation if needed - [x] updated CHANGELOG.md <!-- If applicable, please reference the issue using `Fixes #XXX` and add tests to cover your new code. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-29 02:29:51 +01:00
adam closed this issue 2025-12-29 02:29:51 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/headscale#1373