[PR #6003] [management] Enable PAT creation during setup #24563

Closed
opened 2026-08-05 06:08:50 -04:00 by saavagebueno · 0 comments
Owner

Original Pull Request: https://github.com/netbirdio/netbird/pull/6003

State: closed
Merged: Yes


Describe your changes

Automation requires a way for the user to generate some kind of token they can use to control and populate the instance, this feature introduces the option to enable PAT creation through the /api/setup endpoint.

Now the user will be able to enable PAT creation on setup by:

  • Setting the env var NB_SETUP_PAT_ENABLED=true
  • Sending in the /setup request the property "create_pat": true
    • Optionally the admin will be able to use "pat_expire_in": 30 to specify the expiration time in days (defaults to 1)

As answer they'll receive the same response with an extra field personal_access_token with the actual token they can use to control the instance.

Stack

Checklist

  • Is it a bug fix
  • Is a typo/documentation fix
  • Is a feature enhancement
  • It is a refactor
  • Created tests that fail without the change (if possible)

By submitting this pull request, you confirm that you have read and agree to the terms of the Contributor License Agreement.

Documentation

Select exactly one:

  • I added/updated documentation for this change

  • Documentation is not needed for this change (explain why)

    OpenAPI schema/response documentation is updated in this PR; no separate docs-site PR is needed.

Docs PR URL (required if "docs added" is checked)

Paste the PR link from https://github.com/netbirdio/docs here:

https://github.com/netbirdio/docs/pull/714

Summary by CodeRabbit

  • New Features

    • Optional Personal Access Token (PAT) creation during instance setup, controlled by a server feature flag; PAT returned in the setup response when created and allowed. Response includes Cache-Control: no-store.
  • Validation

    • PAT expiration validated and constrained to configurable bounds (default 1 day, min/max enforced); invalid values return 422.
  • Reliability

    • Setup flow includes automated rollback of created resources on failures, with clearer error and rollback behaviors.
  • Documentation

    • API docs and request/response schemas updated to reflect PAT controls and response behavior.
  • Tests

    • Expanded test coverage for PAT flows, defaults, error cases, and rollback.
**Original Pull Request:** https://github.com/netbirdio/netbird/pull/6003 **State:** closed **Merged:** Yes --- ## Describe your changes Automation requires a way for the user to generate some kind of token they can use to control and populate the instance, this feature introduces the option to enable PAT creation through the `/api/setup` endpoint. Now the user will be able to enable PAT creation on setup by: - Setting the env var `NB_SETUP_PAT_ENABLED=true` - Sending in the /setup request the property `"create_pat": true` - Optionally the admin will be able to use `"pat_expire_in": 30` to specify the expiration time in days (defaults to 1) As answer they'll receive the same response with an extra field `personal_access_token` with the actual token they can use to control the instance. ## Issue ticket number and link ## Stack <!-- branch-stack --> ### Checklist - [ ] Is it a bug fix - [ ] Is a typo/documentation fix - [x] Is a feature enhancement - [ ] It is a refactor - [x] Created tests that fail without the change (if possible) > By submitting this pull request, you confirm that you have read and agree to the terms of the [Contributor License Agreement](https://github.com/netbirdio/netbird/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT.md). ## Documentation Select exactly one: - [x] I added/updated documentation for this change - [ ] Documentation is **not needed** for this change (explain why) OpenAPI schema/response documentation is updated in this PR; no separate docs-site PR is needed. ### Docs PR URL (required if "docs added" is checked) Paste the PR link from https://github.com/netbirdio/docs here: https://github.com/netbirdio/docs/pull/714 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Optional Personal Access Token (PAT) creation during instance setup, controlled by a server feature flag; PAT returned in the setup response when created and allowed. Response includes Cache-Control: no-store. * **Validation** * PAT expiration validated and constrained to configurable bounds (default 1 day, min/max enforced); invalid values return 422. * **Reliability** * Setup flow includes automated rollback of created resources on failures, with clearer error and rollback behaviors. * **Documentation** * API docs and request/response schemas updated to reflect PAT controls and response behavior. * **Tests** * Expanded test coverage for PAT flows, defaults, error cases, and rollback. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
saavagebueno added the pull-request label 2026-08-05 06:08:50 -04:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DYNR/netbird#24563