KiCad PCB EDA Suite
Loading...
Searching...
No Matches
remote_provider_utils.h File Reference
#include <vector>
#include <json_schema_validator.h>
#include <kicommon.h>
#include <wx/string.h>

Go to the source code of this file.

Classes

class  COLLECTING_JSON_ERROR_HANDLER
 Collects JSON-schema validation errors so the caller can inspect them after a validation pass. More...
 

Functions

KICOMMON_API wxString UrlEncode (const wxString &aValue)
 Percent-encode a string for use in URL query parameters (RFC 3986 unreserved characters are passed through unchanged).
 
KICOMMON_API wxString RemoteProviderJsonString (const nlohmann::json &aObject, const char *aKey)
 Extract an optional string value from a JSON object, returning an empty wxString when the key is absent or the value is not a string.
 
KICOMMON_API bool IsLoopbackHost (const wxString &aHost)
 Return true when aHost resolves to a loopback address (localhost, 127.0.0.1, or ::1).
 
KICOMMON_API bool ValidateRemoteUrlSecurity (const wxString &aUrl, bool aAllowInsecureLocalhost, wxString &aError, const wxString &aLabel)
 Validate that aUrl uses HTTPS, or HTTP on a loopback address when aAllowInsecureLocalhost is true.
 
KICOMMON_API wxString NormalizedUrlOrigin (const wxString &aUrl)
 Return a normalized scheme://host:port origin string for aUrl.
 

Function Documentation

◆ IsLoopbackHost()

KICOMMON_API bool IsLoopbackHost ( const wxString & aHost)

Return true when aHost resolves to a loopback address (localhost, 127.0.0.1, or ::1).

IPv6 bracket notation is handled.

Definition at line 64 of file remote_provider_utils.cpp.

Referenced by ValidateRemoteUrlSecurity().

◆ NormalizedUrlOrigin()

KICOMMON_API wxString NormalizedUrlOrigin ( const wxString & aUrl)

Return a normalized scheme://host:port origin string for aUrl.

Empty when the URL cannot be parsed.

Definition at line 100 of file remote_provider_utils.cpp.

Referenced by REMOTE_PROVIDER_CLIENT::ExchangeBootstrapNonce(), and REMOTE_PROVIDER_METADATA::FromJson().

◆ RemoteProviderJsonString()

◆ UrlEncode()

KICOMMON_API wxString UrlEncode ( const wxString & aValue)

Percent-encode a string for use in URL query parameters (RFC 3986 unreserved characters are passed through unchanged).

Definition at line 26 of file remote_provider_utils.cpp.

Referenced by OAUTH_SESSION::BuildAuthorizationUrl(), REMOTE_PROVIDER_CLIENT::ExchangeAuthorizationCode(), REMOTE_PROVIDER_CLIENT::RefreshAccessToken(), and REMOTE_PROVIDER_CLIENT::RevokeToken().

◆ ValidateRemoteUrlSecurity()

KICOMMON_API bool ValidateRemoteUrlSecurity ( const wxString & aUrl,
bool aAllowInsecureLocalhost,
wxString & aError,
const wxString & aLabel )

Validate that aUrl uses HTTPS, or HTTP on a loopback address when aAllowInsecureLocalhost is true.

On failure, aError is populated with a diagnostic that includes aLabel.

Definition at line 78 of file remote_provider_utils.cpp.

References _, and IsLoopbackHost().

Referenced by REMOTE_PROVIDER_CLIENT::ExchangeBootstrapNonce(), REMOTE_PROVIDER_METADATA::FromJson(), REMOTE_PROVIDER_OAUTH_SERVER_METADATA::FromJson(), and REMOTE_PROVIDER_PART_MANIFEST::FromJson().