#[non_exhaustive]pub struct SourceAllowlist {
pub source: String,
pub redirect_hosts: Vec<String>,
}Expand description
docs/REDIRECT_ALLOWLIST.md §2.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.source: StringSource key. MUST match a source value in docs/SOURCES.md §1
(e.g. crossref, unpaywall, arxiv).
redirect_hosts: Vec<String>Each pattern is either a literal FQDN or a *.<suffix> glob (matches
the suffix and any subdomain — see docs/REDIRECT_ALLOWLIST.md §2.2
matching rule).
Implementations§
Source§impl SourceAllowlist
impl SourceAllowlist
Sourcepub fn new(source: impl Into<String>, redirect_hosts: Vec<String>) -> Self
pub fn new(source: impl Into<String>, redirect_hosts: Vec<String>) -> Self
Construct a new allowlist entry.
Sourcepub fn matches(&self, host: &str) -> bool
pub fn matches(&self, host: &str) -> bool
Returns true if host matches any pattern in this allowlist.
Matching is byte-level on the lowercased ASCII form of the host.
Callers MUST lowercase upstream; this method also lowercases as a
defense-in-depth measure but treats the result as ASCII (Punycode
is the caller’s responsibility per docs/REDIRECT_ALLOWLIST.md
§2.2 rule 4).
Sourcepub fn permits(&self, host: &str) -> bool
pub fn permits(&self, host: &str) -> bool
Returns true if a request to host may proceed under this
allowlist: either it is on the list, or it is a transparent DOI
resolver (is_transparent_resolver).
This, not matches, is what an adjudication site
calls. matches answers “is this host on the list”, which is a
question about the list; permits answers “may we go here”, which is
the question every gate is actually asking. Keeping them separate
means the resolver set is not silently reported as part of any
source’s expected_hosts.
The five adjudication sites – the pre-fetch OA-URL check in
orchestrator, the two redirect-policy closures, probe, and the
pre-check doiget config doctor --network runs before calling
probe – all route through here so they cannot disagree. #533 was
found because only one of them was ever walked end to end, and the
doctor’s was missed on the first pass at this very doc comment: it
said “four” while still calling matches, which would have had the
command that explains allowlist refusals reproduce #533 the moment a
resolver host entered its probe list.
Trait Implementations§
Source§impl Clone for SourceAllowlist
impl Clone for SourceAllowlist
Source§fn clone(&self) -> SourceAllowlist
fn clone(&self) -> SourceAllowlist
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more