Skip to main content

SourceAllowlist

Struct SourceAllowlist 

Source
#[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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§source: String

Source 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

Source

pub fn new(source: impl Into<String>, redirect_hosts: Vec<String>) -> Self

Construct a new allowlist entry.

Source

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).

Source

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

Source§

fn clone(&self) -> SourceAllowlist

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SourceAllowlist

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more