MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / validate

Method validate

nodedb/src/config/auth/config.rs:200–225  ·  view source on GitHub ↗

Validate provider config against a [`JwksPolicy`]. Fail-closed: empty `issuer` is rejected; `jwks_url` must pass the policy.

(
        &self,
        policy: &crate::control::security::jwks::url::JwksPolicy,
    )

Source from the content-addressed store, hash-verified

198 /// Validate provider config against a [`JwksPolicy`]. Fail-closed:
199 /// empty `issuer` is rejected; `jwks_url` must pass the policy.
200 pub fn validate(
201 &self,
202 policy: &crate::control::security::jwks::url::JwksPolicy,
203 ) -> crate::Result<()> {
204 if self.name.trim().is_empty() {
205 return Err(crate::Error::Config {
206 detail: "auth.jwt provider must have a non-empty name".into(),
207 });
208 }
209 if self.issuer.trim().is_empty() {
210 return Err(crate::Error::Config {
211 detail: format!(
212 "auth.jwt provider '{}' must set a non-empty `issuer`; \
213 empty issuer would disable issuer validation and allow \
214 cross-tenant token acceptance",
215 self.name
216 ),
217 });
218 }
219 policy
220 .check_url(&self.jwks_url)
221 .map_err(|e| crate::Error::Config {
222 detail: format!("auth.jwt provider '{}' has unsafe jwks_url: {e}", self.name),
223 })?;
224 Ok(())
225 }
226}
227
228impl JwtAuthConfig {

Callers

nothing calls this directly

Calls 3

check_urlMethod · 0.80
jwks_policyMethod · 0.80
is_emptyMethod · 0.45

Tested by

no test coverage detected