[PR #4844] Fix SSH JWT issuer derivation for IDPs with path components #21407

Open
opened 2026-08-05 05:08:28 -04:00 by saavagebueno · 0 comments
Owner

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

State: closed
Merged: Yes


Describe your changes

Fixed SSH JWT authentication for IDPs with path-based issuers (e.g., Authentik).

The buildJWTConfig() function in conversion.go was incorrectly using OR (||) instead of AND (&&) when checking whether to derive the issuer from the token endpoint. This caused it to always override the configured AuthIssuer when deviceFlowConfig exists, even when AuthIssuer was properly set.

The deriveIssuerFromTokenEndpoint() function strips the path from URLs (returns only scheme://host/), which breaks IDPs like Authentik where the issuer includes a path component (e.g., https://auth.example.com/application/o/netbird/).

Changed: Line 372 in management/internals/shared/grpc/conversion.go

// Before
if issuer == "" || deviceFlowConfig != nil {

// After  
if issuer == "" && deviceFlowConfig != nil {

Now the issuer is only derived from the token endpoint when AuthIssuer is not already configured.

Fixes #4813

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)

Reason: This is a bug fix that corrects existing behavior. No new features or configuration options are introduced.

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

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

N/A

Summary by CodeRabbit

  • Bug Fixes
    • Modified JWT issuer derivation logic to apply only when both an empty issuer and device flow configuration are present, refining the conditions for automatic issuer resolution in authentication flows.

✏️ Tip: You can customize this high-level summary in your review settings.

**Original Pull Request:** https://github.com/netbirdio/netbird/pull/4844 **State:** closed **Merged:** Yes --- ## Describe your changes Fixed SSH JWT authentication for IDPs with path-based issuers (e.g., Authentik). The `buildJWTConfig()` function in `conversion.go` was incorrectly using OR (`||`) instead of AND (`&&`) when checking whether to derive the issuer from the token endpoint. This caused it to always override the configured `AuthIssuer` when `deviceFlowConfig` exists, even when `AuthIssuer` was properly set. The `deriveIssuerFromTokenEndpoint()` function strips the path from URLs (returns only `scheme://host/`), which breaks IDPs like Authentik where the issuer includes a path component (e.g., `https://auth.example.com/application/o/netbird/`). **Changed:** Line 372 in `management/internals/shared/grpc/conversion.go` ```go // Before if issuer == "" || deviceFlowConfig != nil { // After if issuer == "" && deviceFlowConfig != nil { ``` Now the issuer is only derived from the token endpoint when `AuthIssuer` is not already configured. ## Issue ticket number and link Fixes #4813 ## Stack <!-- branch-stack --> ### Checklist - [x] 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](https://github.com/netbirdio/netbird/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT.md). ## Documentation Select exactly one: - [ ] I added/updated documentation for this change - [x] Documentation is **not needed** for this change (explain why) **Reason:** This is a bug fix that corrects existing behavior. No new features or configuration options are introduced. ### Docs PR URL (required if "docs added" is checked) Paste the PR link from https://github.com/netbirdio/docs here: N/A <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Modified JWT issuer derivation logic to apply only when both an empty issuer and device flow configuration are present, refining the conditions for automatic issuer resolution in authentication flows. <sub>✏️ Tip: You can customize this high-level summary in your review settings.</sub> <!-- end of auto-generated comment: release notes by coderabbit.ai -->
saavagebueno added the pull-request label 2026-08-05 05:08:28 -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#21407