Skip to content

OPSLAB-264: add API_FQDN to support separatioon between AUTH and API …#350

Merged
abr-ubiqube merged 6 commits intomasterfrom
OPSLAB-264/abr/enable_specific_fqdn
Mar 27, 2026
Merged

OPSLAB-264: add API_FQDN to support separatioon between AUTH and API …#350
abr-ubiqube merged 6 commits intomasterfrom
OPSLAB-264/abr/enable_specific_fqdn

Conversation

@abr-ubiqube
Copy link
Copy Markdown
Member

@abr-ubiqube abr-ubiqube commented Mar 27, 2026

  • Fix inconsistency between !empty($this->key) (FQDN selection) and isset($this->key) (auth header logic) — use isset in both places so authenticated state is evaluated uniformly
  • Fix non-breaking hyphen characters in README.md (cosmetic)

⚡ Quickly spin up Copilot coding agent tasks from anywhere on your macOS or Windows machine with Raycast.

@abr-ubiqube abr-ubiqube requested a review from a team as a code owner March 27, 2026 15:07
@abr-ubiqube abr-ubiqube requested review from Diyal976, UBiqube-ydu, Copilot and vmonnier and removed request for a team March 27, 2026 15:07
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds support in the REST generic adapter for separating the authentication endpoint FQDN from the API endpoint FQDN, enabling workflows where token acquisition happens on a different host than subsequent API calls.

Changes:

  • Replaces the single fqdn connection property with auth_fqdn and api_fqdn.
  • Updates request host selection logic in DeviceConnection::send() to choose between auth_fqdn, api_fqdn, or sd_ip_config:port.
  • Extends rest_generic_connect() to read API_FQDN config in addition to AUTH_FQDN.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread adapters/rest_generic/rest_generic_connect.php Outdated
Comment thread adapters/rest_generic/rest_generic_connect.php Outdated
antoine-brun and others added 2 commits March 27, 2026 16:14
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +155 to +169
if (!empty($this->key)) {
// Post-authenticated requests: prefer API FQDN, then AUTH FQDN, then fall back to configured IP:port
if (!empty($this->api_fqdn)) {
$ip_address = $this->api_fqdn;
} elseif (!empty($this->auth_fqdn)) {
$ip_address = $this->auth_fqdn;
} else {
$ip_address = $this->sd_ip_config . ":" . $this->sd_management_port;
}
} else {
$ip_address = $this->sd_ip_config . ":" . $this->sd_management_port;
// Pre-auth/BASIC requests: prefer AUTH FQDN, then fall back to API FQDN, then to configured IP:port
if (!empty($this->auth_fqdn)) {
$ip_address = $this->auth_fqdn;
} elseif (!empty($this->api_fqdn)) {
$ip_address = $this->api_fqdn;
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

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

The new post-auth/pre-auth host selection uses !empty($this->key), but the authentication/header logic above relies on isset($this->key). If $this->key is set to an empty string (e.g., AUTH_KEY config var present but empty), requests will still add an auth header while being treated as pre-auth here, potentially sending authenticated calls to the wrong FQDN. Use a consistent predicate for “authenticated” (either change this block to isset($this->key) or tighten the header logic to require a non-empty key).

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@copilot apply changes based on this feedback

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.

Changed !empty($this->key) to isset($this->key) in the FQDN selection block so it uses the same predicate as the auth header logic above it. This ensures a key set to an empty string is treated consistently across both the header and FQDN routing decisions (commit 8d3ef84).

Note: the commit is ready locally but a repository protection rule is currently preventing the push — the change is available for review in the local branch.

Comment thread adapters/rest_generic/README.md Outdated
Comment thread adapters/rest_generic/README.md Outdated
Comment thread adapters/rest_generic/README.md Outdated
Comment on lines +13 to +18
FQDN used for OAuth or token based authentication
ex: FortiSASE: customerapiauth.fortinet.com

## API_FQDN
FQDN used for API calls
ex: FortiSASE: portal.prod.fortisase.com
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

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

Minor wording/formatting in the newly added config var descriptions: consider using “token-based” and “e.g.” instead of “token based” / “ex:”, and remove trailing spaces at line ends to keep the Markdown clean.

Copilot uses AI. Check for mistakes.
abr-ubiqube and others added 2 commits March 27, 2026 16:27
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.

5 participants