| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Ecluse.Core.Security.Authority
Description
Textual extraction of the host[:port] authority an outbound request dials.
These are comparison extractors, not an RFC 3986 parser: a value with no recognisable
authority yields the empty string or Nothing, which every guard treats as not-allowed. The
SSRF gates in Ecluse.Core.Security.Host consume the extracted HostPort, so the parsing
here carries no policy of its own.
Synopsis
- data HostPort = HostPort {}
- hostAddress :: Text -> Text
- hostPortAddress :: Text -> Maybe HostPort
- hostPortAddressWithDefault :: Word16 -> Text -> Maybe HostPort
- splitHostPort :: Text -> Maybe (Text, Text)
- data AuthorityText
- authorityText :: Text -> AuthorityText
- authorityHostPort :: AuthorityText -> Maybe HostPort
- refuseCredentialMaterial :: Text -> Text -> Either Text ()
- authorityLabel :: Text -> Text
- dialledAuthorityLabel :: Text -> Text
- credentialFreeUrl :: Text -> Text
- credentialFreeOrigin :: Text -> Text
- dialledOrigin :: Text -> Text
- credentialFreePath :: Text -> Text
The dialled authority
The authority an outbound fetch dials: a bare host with its effective port. The gate authorises the pair, so an allowlisted host at an attacker-chosen port is not authorised.
Constructors
| HostPort | |
Authority extraction
hostAddress :: Text -> Text Source #
The bare host of a URI or host[:port] authority, lower-cased and unbracketed. A value with no recognisable host yields the empty string, which the guards treat as not-allowed.
hostPortAddress :: Text -> Maybe HostPort Source #
Extract the host and effective port, defaulting to 443. Refuse absent hosts and malformed ports.
hostPortAddressWithDefault :: Word16 -> Text -> Maybe HostPort Source #
hostPortAddress with the caller's own port for a URL that writes none, for a scheme whose portless default is not the gate's 443. The authority split and the port grammar do not change.
splitHostPort :: Text -> Maybe (Text, Text) Source #
Split a host[:port] authority into its bare host and the raw ":port" remainder, empty when no port is present. The split is bracket-aware, and an unclosed opening bracket yields Nothing.
Comparing authorities
data AuthorityText Source #
The only text of a URL that hostPortAddress reads. Equal texts give equal results, so a caller may reuse one's result for the other.
Instances
| Eq AuthorityText Source # | |
Defined in Ecluse.Core.Security.Authority Methods (==) :: AuthorityText -> AuthorityText -> Bool # (/=) :: AuthorityText -> AuthorityText -> Bool # | |
authorityText :: Text -> AuthorityText Source #
The authority of a URI or bare host[:port] value, without userinfo.
authorityHostPort :: AuthorityText -> Maybe HostPort Source #
hostPortAddress from the authority text alone: hostPortAddress = authorityHostPort . authorityText.
Configured-URL refusal
refuseCredentialMaterial :: Text -> Text -> Either Text () Source #
Refuse configured URLs with userinfo, query or fragment before any check quotes the URL. Reasons never quote credentials.
Log-safe rendering
authorityLabel :: Text -> Text Source #
A host and effective port label without credential carriers, or <unresolved> for an invalid authority.
dialledAuthorityLabel :: Text -> Text Source #
A credential-free authority label using port 80 for a portless http:// URL, otherwise 443.
credentialFreeUrl :: Text -> Text Source #
Remove userinfo, query and fragment while retaining the fetched URL's scheme, authority and path.
credentialFreeOrigin :: Text -> Text Source #
The scheme and the authority as written, without userinfo.
dialledOrigin :: Text -> Text Source #
The scheme and the dialled host:port, the part of a URL that names where it was fetched from.
credentialFreePath :: Text -> Text Source #
The path a URL fetches. The query and fragment are cut first, so a slash inside them is never read as the path.