Skip to main content

hyprstream_core/auth/
id_token_verify.rs

1//! External IdP id_token verification with multi-algorithm JWKS support.
2//!
3//! Verifies JWT signatures from external OIDC providers (Keycloak, Auth0, etc.)
4//! using keys fetched from the provider's JWKS endpoint. Supports RS256, ES256,
5//! and EdDSA (Ed25519) algorithms.
6
7use anyhow::{anyhow, Context, Result};
8use base64::{engine::general_purpose::URL_SAFE_NO_PAD, Engine};
9use jsonwebtoken::{Algorithm, DecodingKey, Validation};
10use serde_json::Value;
11
12/// Verification result for an external id_token.
13#[derive(Debug)]
14pub struct VerifiedIdToken {
15    /// Decoded claims from the verified id_token.
16    pub claims: Value,
17}
18
19/// Verify an external id_token against the provider's JWKS.
20///
21/// Fetches the JWKS from the given URI, selects the appropriate key (by `kid`
22/// if present in the JWT header), and verifies the signature. Returns the
23/// decoded claims on success.
24///
25/// # Arguments
26///
27/// * `token` — The raw JWT string (id_token from the external provider).
28/// * `jwks_uri` — The provider's JWKS endpoint URL.
29/// * `expected_issuer` — The expected `iss` claim value (provider's issuer URL).
30/// * `expected_audience` — The expected `aud` claim value (client_id).
31/// * `http` — HTTP client for fetching the JWKS.
32pub async fn verify_id_token(
33    token: &str,
34    jwks_uri: &str,
35    expected_issuer: &str,
36    expected_audience: &str,
37    http: &reqwest::Client,
38) -> Result<VerifiedIdToken> {
39    // Fetch JWKS (256KB response limit to prevent resource exhaustion)
40    let jwks_response = http
41        .get(jwks_uri)
42        .timeout(std::time::Duration::from_secs(10))
43        .send()
44        .await
45        .with_context(|| format!("Failed to fetch JWKS from {}", jwks_uri))?;
46
47    if !jwks_response.status().is_success() {
48        return Err(anyhow!(
49            "JWKS endpoint returned {}: {}",
50            jwks_response.status(),
51            jwks_uri
52        ));
53    }
54
55    let jwks_body = jwks_response
56        .bytes()
57        .await
58        .context("Failed to read JWKS response body")?;
59    if jwks_body.len() > 256 * 1024 {
60        return Err(anyhow!(
61            "JWKS response too large: {} bytes (max 256KB)",
62            jwks_body.len()
63        ));
64    }
65
66    let jwks_json: Value = serde_json::from_slice(&jwks_body).context("Invalid JWKS JSON")?;
67
68    let keys = jwks_json["keys"]
69        .as_array()
70        .ok_or_else(|| anyhow!("JWKS missing 'keys' array at {}", jwks_uri))?;
71
72    verify_id_token_with_keys(token, keys, expected_issuer, expected_audience)
73}
74
75/// Pure (HTTP-free) verification core: given the parsed JWKS `keys` array,
76/// verify an id_token's signature and claims. Exposed for tests so the
77/// overlap-rotation behaviour can be exercised without a mock server.
78///
79/// Selects every algorithm-compatible candidate and tries each until one
80/// verifies — never collapsing the published set to a positional singleton
81/// (#1183 / #1184).
82pub(crate) fn verify_id_token_with_keys(
83    token: &str,
84    keys: &[Value],
85    expected_issuer: &str,
86    expected_audience: &str,
87) -> Result<VerifiedIdToken> {
88    // Extract the JWT header to get the `kid` for key selection
89    let header = decode_jwt_header(token)?;
90
91    let kid = header.get("kid").and_then(|v| v.as_str());
92
93    // Collect every algorithm-compatible candidate. When the JWT carries a
94    // `kid` the set is the kid-matched entries; when it does not, the set is
95    // every key whose `kty`/`crv` matches the header `alg`. The verifier then
96    // tries each until one verifies — never collapsing a published key SET to
97    // a positional singleton, which would foreclose overlap rotation and
98    // PQ-hybrid rollout (#1183 / #1184).
99    let candidates = candidate_keys(keys, kid, &header);
100    if candidates.is_empty() {
101        return Err(anyhow!(
102            "No JWKS key matches {} (kid={:?})",
103            header.get("alg").and_then(|v| v.as_str()).unwrap_or(""),
104            kid,
105        ));
106    }
107    if kid.is_some() && candidates.len() != 1 {
108        return Err(anyhow!(
109            "JWKS kid {:?} is ambiguous for the token algorithm",
110            kid
111        ));
112    }
113
114    // Build a jsonwebtoken::Validation. Algorithm is taken from the JWT header
115    // (each candidate shares the header `alg` because candidate_keys filtered
116    // on kty/crv consistency).
117    let alg = algorithm_from_header(&header)?;
118    let mut validation = Validation::new(alg);
119    validation.set_issuer(&[expected_issuer]);
120    validation.set_audience(&[expected_audience]);
121    // Allow 60 seconds of clock skew (same as provider.clock_skew_seconds default)
122    validation.leeway = 60;
123
124    // Try each candidate until one verifies. A JWKS may publish several keys
125    // simultaneously (overlap rotation / PQ-hybrid); only one is the real
126    // verifier and the rest are expected misses, logged at `debug`. An unknown
127    // or unsupported entry is skipped rather than failing the whole set.
128    let mut last_err: Option<anyhow::Error> = None;
129    for jwk in &candidates {
130        let decoding_key = match build_decoding_key(jwk) {
131            Ok(k) => k,
132            Err(e) => {
133                tracing::debug!(error = %e, "id_token: skipping JWKS key (invalid key material)");
134                last_err = Some(e);
135                continue;
136            }
137        };
138        match jsonwebtoken::decode::<Value>(token, &decoding_key, &validation) {
139            Ok(decoded) => {
140                return Ok(VerifiedIdToken {
141                    claims: decoded.claims,
142                });
143            }
144            Err(e) => {
145                tracing::debug!(error = %e, "id_token: candidate key did not verify; trying next");
146                last_err = Some(anyhow!("id_token signature verification failed: {}", e));
147            }
148        }
149    }
150
151    Err(last_err.unwrap_or_else(|| {
152        anyhow!(
153            "id_token verification failed: no candidate verified ({} candidates)",
154            candidates.len()
155        )
156    }))
157}
158
159/// Decode only the JWT header (without verification) for key selection.
160fn decode_jwt_header(token: &str) -> Result<Value> {
161    let parts: Vec<&str> = token.splitn(3, '.').collect();
162    if parts.len() != 3 {
163        return Err(anyhow!("Invalid JWT format"));
164    }
165    let header_bytes = URL_SAFE_NO_PAD
166        .decode(parts[0])
167        .map_err(|e| anyhow!("Invalid base64 in JWT header: {e}"))?;
168    serde_json::from_slice(&header_bytes).map_err(|e| anyhow!("Invalid JSON in JWT header: {e}"))
169}
170
171/// Collect every algorithm-compatible JWKS candidate for a JWT header.
172///
173/// When the JWT carries a `kid`, only entries with that exact `kid` are
174/// returned (there may be several — e.g. an Ed25519 entry and a composite
175/// entry published side-by-side under the same kid). When it carries no
176/// `kid`, every entry whose `kty`/`crv` matches the header `alg` is
177/// returned. Unknown / unsupported algorithms are skipped: the caller tries
178/// each candidate and a published set is never collapsed to a positional
179/// singleton (#1183 / #1184).
180fn candidate_keys<'a>(keys: &'a [Value], kid: Option<&str>, header: &Value) -> Vec<&'a Value> {
181    let header_alg = header.get("alg").and_then(|v| v.as_str()).unwrap_or("");
182
183    keys.iter()
184        .filter(|key| {
185            let kid_matches = match kid {
186                Some(want) => key.get("kid").and_then(|v| v.as_str()) == Some(want),
187                None => true,
188            };
189            kid_matches && key_matches_algorithm(key, header_alg)
190        })
191        .collect()
192}
193
194/// Pin a JWK candidate to the JWT's declared algorithm. Key type, curve, and
195/// an explicit JWK `alg` (when present) must all agree; candidate iteration is
196/// never allowed to create an algorithm downgrade.
197fn key_matches_algorithm(key: &Value, header_alg: &str) -> bool {
198    if let Some(key_alg) = key.get("alg").and_then(|v| v.as_str()) {
199        if key_alg != header_alg {
200            return false;
201        }
202    }
203
204    let kty = key.get("kty").and_then(|v| v.as_str()).unwrap_or("");
205    let crv = key.get("crv").and_then(|v| v.as_str());
206    match header_alg {
207        "RS256" => kty == "RSA",
208        "ES256" => kty == "EC" && crv == Some("P-256"),
209        "EdDSA" => kty == "OKP" && crv == Some("Ed25519"),
210        _ => false,
211    }
212}
213
214/// Resolve the jsonwebtoken `Algorithm` from the JWT header `alg`, after
215/// [`candidate_keys`] has already filtered the JWKS to kty/crv-consistent
216/// entries.
217fn algorithm_from_header(header: &Value) -> Result<Algorithm> {
218    let alg_str = header
219        .get("alg")
220        .and_then(|v| v.as_str())
221        .ok_or_else(|| anyhow!("JWT header missing 'alg'"))?;
222    match alg_str {
223        "RS256" => Ok(Algorithm::RS256),
224        "ES256" => Ok(Algorithm::ES256),
225        "EdDSA" => Ok(Algorithm::EdDSA),
226        other => Err(anyhow!("Unsupported JWT algorithm: {}", other)),
227    }
228}
229
230/// Public alias for the algorithm-from-JWK helper. Used by client_auth.
231pub fn algorithm_for_key_pub(jwks_key: &Value) -> Result<Algorithm> {
232    let kty = jwks_key.get("kty").and_then(|v| v.as_str()).unwrap_or("");
233    match kty {
234        "RSA" => Ok(Algorithm::RS256),
235        "EC" => {
236            let crv = jwks_key.get("crv").and_then(|v| v.as_str()).unwrap_or("");
237            match crv {
238                "P-256" => Ok(Algorithm::ES256),
239                other => Err(anyhow!("Unsupported EC curve: {}", other)),
240            }
241        }
242        "OKP" => {
243            let crv = jwks_key.get("crv").and_then(|v| v.as_str()).unwrap_or("");
244            match crv {
245                "Ed25519" => Ok(Algorithm::EdDSA),
246                other => Err(anyhow!("Unsupported OKP curve: {}", other)),
247            }
248        }
249        other => Err(anyhow!("Unsupported JWKS key type: {}", other)),
250    }
251}
252
253/// Build a jsonwebtoken::DecodingKey from a JWKS key object.
254pub fn build_decoding_key(jwks_key: &Value) -> Result<DecodingKey> {
255    let kty = jwks_key.get("kty").and_then(|v| v.as_str()).unwrap_or("");
256
257    match kty {
258        "RSA" => {
259            // RSA keys use 'n' and 'e' components (base64url-encoded per RFC 7518)
260            let n = jwks_key
261                .get("n")
262                .and_then(|v| v.as_str())
263                .ok_or_else(|| anyhow!("RSA JWKS key missing 'n' field"))?;
264            let e = jwks_key
265                .get("e")
266                .and_then(|v| v.as_str())
267                .ok_or_else(|| anyhow!("RSA JWKS key missing 'e' field"))?;
268            DecodingKey::from_rsa_components(n, e)
269                .map_err(|e| anyhow!("Invalid RSA key components: {e}"))
270        }
271        "EC" => {
272            // EC keys use 'x' and 'y' components (P-256)
273            let x = jwks_key
274                .get("x")
275                .and_then(|v| v.as_str())
276                .ok_or_else(|| anyhow!("EC JWKS key missing 'x' field"))?;
277            let y = jwks_key
278                .get("y")
279                .and_then(|v| v.as_str())
280                .ok_or_else(|| anyhow!("EC JWKS key missing 'y' field"))?;
281            DecodingKey::from_ec_components(x, y)
282                .map_err(|e| anyhow!("Invalid EC key components: {e}"))
283        }
284        "OKP" => {
285            // Ed25519 keys use 'x' (the public key)
286            let x = jwks_key
287                .get("x")
288                .and_then(|v| v.as_str())
289                .ok_or_else(|| anyhow!("OKP JWKS key missing 'x' field"))?;
290            let raw = URL_SAFE_NO_PAD
291                .decode(x)
292                .map_err(|e| anyhow!("Invalid base64 in OKP 'x': {e}"))?;
293            // from_ed_der stores raw bytes — the name is misleading but
294            // equivalent to from_ed_components (both store SecretOrDer).
295            Ok(DecodingKey::from_ed_der(&raw))
296        }
297        other => Err(anyhow!("Unsupported JWKS key type: {}", other)),
298    }
299}
300
301/// Decode an external id_token without signature verification.
302///
303/// Used as a fallback when JWKS verification is not available (e.g., no
304/// configured trusted issuer). The caller must validate claims manually.
305pub fn decode_unverified(token: &str) -> Result<Value> {
306    let parts: Vec<&str> = token.splitn(3, '.').collect();
307    if parts.len() != 3 {
308        return Err(anyhow!("Invalid JWT format"));
309    }
310    let payload_bytes = URL_SAFE_NO_PAD
311        .decode(parts[1])
312        .map_err(|e| anyhow!("Invalid base64 in id_token payload: {e}"))?;
313    serde_json::from_slice(&payload_bytes)
314        .map_err(|e| anyhow!("Invalid JSON in id_token payload: {e}"))
315}
316
317#[cfg(test)]
318#[allow(clippy::unwrap_used)]
319mod tests {
320    use super::*;
321
322    #[test]
323    fn test_decode_jwt_header_eddsa() {
324        let header = serde_json::json!({"alg": "EdDSA", "typ": "JWT"});
325        let header_b64 = URL_SAFE_NO_PAD.encode(header.to_string().as_bytes());
326        let token = format!("{header_b64}.e30.Zm9v");
327        let decoded = decode_jwt_header(&token).unwrap();
328        assert_eq!(decoded["alg"], "EdDSA");
329    }
330
331    #[test]
332    fn test_decode_jwt_header_rs256() {
333        let header = serde_json::json!({"alg": "RS256", "typ": "JWT", "kid": "key-1"});
334        let header_b64 = URL_SAFE_NO_PAD.encode(header.to_string().as_bytes());
335        let token = format!("{header_b64}.e30.Zm9v");
336        let decoded = decode_jwt_header(&token).unwrap();
337        assert_eq!(decoded["alg"], "RS256");
338        assert_eq!(decoded["kid"], "key-1");
339    }
340
341    #[test]
342    fn test_algorithm_from_header_rs256() {
343        let header = serde_json::json!({"alg": "RS256"});
344        assert_eq!(algorithm_from_header(&header).unwrap(), Algorithm::RS256);
345    }
346
347    #[test]
348    fn test_algorithm_from_header_missing() {
349        let header = serde_json::json!({});
350        assert!(algorithm_from_header(&header).is_err());
351    }
352
353    #[test]
354    fn test_algorithm_from_header_unsupported() {
355        let header = serde_json::json!({"alg": "RS512"});
356        assert!(algorithm_from_header(&header).is_err());
357    }
358
359    #[test]
360    fn test_candidate_keys_by_kid() {
361        let keys = vec![
362            serde_json::json!({"kty": "RSA", "kid": "key-1", "n": "abc", "e": "AQAB"}),
363            serde_json::json!({"kty": "RSA", "kid": "key-2", "n": "def", "e": "AQAB"}),
364        ];
365        let header = serde_json::json!({"alg": "RS256", "kid": "key-2"});
366        let found = candidate_keys(&keys, Some("key-2"), &header);
367        assert_eq!(found.len(), 1);
368        assert_eq!(found[0]["kid"], "key-2");
369    }
370
371    #[test]
372    fn test_candidate_keys_no_kid_returns_all_alg_compatible() {
373        // Two simultaneously published RSA keys (overlap rotation). Without a
374        // `kid`, the verifier MUST retain BOTH candidates so it can try each —
375        // collapsing to "the first one" forecloses overlap rotation and
376        // PQ-hybrid rollout (#1183 / #1184).
377        let keys = vec![
378            serde_json::json!({"kty": "RSA", "kid": "key-1", "n": "abc", "e": "AQAB"}),
379            serde_json::json!({"kty": "RSA", "kid": "key-2", "n": "def", "e": "AQAB"}),
380        ];
381        let header = serde_json::json!({"alg": "RS256"});
382        let found = candidate_keys(&keys, None, &header);
383        assert_eq!(found.len(), 2);
384    }
385
386    #[test]
387    fn test_candidate_keys_skips_unknown_alg() {
388        // An unsupported/unknown algorithm entry MUST be skipped rather than
389        // fail the whole set — a PQ-capable verifier ignores what it does not
390        // recognize while a classical verifier keeps working against the
391        // classical entry.
392        let keys = vec![
393            serde_json::json!({"kty": "AKP", "alg": "ML-DSA-65-Ed25519", "kid": "pq"}),
394            serde_json::json!({"kty": "RSA", "kid": "classic", "n": "abc", "e": "AQAB"}),
395        ];
396        let header = serde_json::json!({"alg": "RS256"});
397        let found = candidate_keys(&keys, None, &header);
398        assert_eq!(found.len(), 1);
399        assert_eq!(found[0]["kid"], "classic");
400    }
401
402    #[test]
403    fn test_candidate_keys_no_kid_no_match() {
404        let keys = vec![serde_json::json!({"kty": "EC", "kid": "ec-1", "x": "a", "y": "b"})];
405        let header = serde_json::json!({"alg": "RS256"});
406        let found = candidate_keys(&keys, None, &header);
407        assert!(found.is_empty());
408    }
409
410    /// Build an EdDSA JWT signed with `signing_key`. The header carries the
411    /// given optional `kid`. Used by the overlap-rotation tests so they can
412    /// sign with arbitrary Ed25519 keys without a PEM/DER round-trip.
413    fn sign_eddsa_jwt(
414        signing_key: &ed25519_dalek::SigningKey,
415        claims: &serde_json::Value,
416        kid: Option<&str>,
417    ) -> String {
418        use ed25519_dalek::Signer;
419        let mut header = serde_json::json!({"alg": "EdDSA", "typ": "JWT"});
420        if let Some(k) = kid {
421            header["kid"] = serde_json::Value::String(k.to_owned());
422        }
423        let header_b64 = URL_SAFE_NO_PAD.encode(serde_json::to_vec(&header).unwrap());
424        let payload_b64 = URL_SAFE_NO_PAD.encode(serde_json::to_vec(claims).unwrap());
425        let signing_input = format!("{header_b64}.{payload_b64}");
426        let sig = signing_key.sign(signing_input.as_bytes());
427        let sig_b64 = URL_SAFE_NO_PAD.encode(sig.to_bytes());
428        format!("{signing_input}.{sig_b64}")
429    }
430
431    fn jwks_ed25519(entries: &[(&str, &ed25519_dalek::VerifyingKey)]) -> Vec<Value> {
432        entries
433            .iter()
434            .map(|(kid, vk)| {
435                serde_json::json!({
436                    "kty": "OKP", "crv": "Ed25519", "alg": "EdDSA",
437                    "kid": kid,
438                    "x": URL_SAFE_NO_PAD.encode(vk.as_bytes()),
439                })
440            })
441            .collect()
442    }
443
444    /// #1184: a kid-less id_token signed by the SECOND of two simultaneously
445    /// published Ed25519 keys must verify against the JWKS set. The previous
446    /// implementation returned `keys.first()` and would fail for the non-first
447    /// signer; reverting this hunk to "try only the first candidate" makes
448    /// this test fail.
449    #[test]
450    fn id_token_kid_less_signer_is_non_first_published_key() -> anyhow::Result<()> {
451        let sk_a = ed25519_dalek::SigningKey::from_bytes(&[0xA0; 32]);
452        let sk_b = ed25519_dalek::SigningKey::from_bytes(&[0xB0; 32]);
453
454        // Publish BOTH keys (overlap window): lead first, drain second.
455        let keys = jwks_ed25519(&[
456            ("lead", &sk_a.verifying_key()),
457            ("drain", &sk_b.verifying_key()),
458        ]);
459
460        // Sign with the SECOND (drain) key — no `kid` in the header.
461        let claims = serde_json::json!({
462            "iss": "https://idp.example.com",
463            "aud": "client-42",
464            "sub": "user-1",
465            "exp": (jsonwebtoken::get_current_timestamp() + 300),
466        });
467        let token = sign_eddsa_jwt(&sk_b, &claims, None);
468
469        let verified =
470            verify_id_token_with_keys(&token, &keys, "https://idp.example.com", "client-42")?;
471        assert_eq!(verified.claims["sub"], "user-1");
472        Ok(())
473    }
474
475    /// #1184 overlap: while both keys are published, a token signed by either
476    /// verifies (first AND non-first), and a token signed by an UNKNOWN key
477    /// that is not in the set is rejected.
478    #[test]
479    fn id_token_overlap_both_signers_accepted_unknown_rejected() -> anyhow::Result<()> {
480        let sk_lead = ed25519_dalek::SigningKey::from_bytes(&[0x11; 32]);
481        let sk_drain = ed25519_dalek::SigningKey::from_bytes(&[0x22; 32]);
482        let sk_unknown = ed25519_dalek::SigningKey::from_bytes(&[0x99; 32]);
483
484        let keys = jwks_ed25519(&[
485            ("lead", &sk_lead.verifying_key()),
486            ("drain", &sk_drain.verifying_key()),
487        ]);
488
489        let claims = serde_json::json!({
490            "iss": "https://idp.example.com",
491            "aud": "client-42",
492            "sub": "user-1",
493            "exp": (jsonwebtoken::get_current_timestamp() + 300),
494        });
495
496        // First (lead) signer — accepted.
497        let token_lead = sign_eddsa_jwt(&sk_lead, &claims, None);
498        let v =
499            verify_id_token_with_keys(&token_lead, &keys, "https://idp.example.com", "client-42")?;
500        assert_eq!(v.claims["sub"], "user-1");
501
502        // Non-first (drain) signer — accepted.
503        let token_drain = sign_eddsa_jwt(&sk_drain, &claims, None);
504        let v =
505            verify_id_token_with_keys(&token_drain, &keys, "https://idp.example.com", "client-42")?;
506        assert_eq!(v.claims["sub"], "user-1");
507
508        // Unknown signer (not in the published set) — rejected.
509        let token_bad = sign_eddsa_jwt(&sk_unknown, &claims, None);
510        let err =
511            verify_id_token_with_keys(&token_bad, &keys, "https://idp.example.com", "client-42")
512                .unwrap_err();
513        assert!(
514            err.to_string().contains("signature verification failed")
515                || err.to_string().contains("no candidate verified"),
516            "unexpected error: {err}"
517        );
518        Ok(())
519    }
520
521    /// #1184: an unsupported/unknown algorithm entry in the JWKS MUST be
522    /// skipped rather than fail the whole set — a PQ-capable verifier ignores
523    /// what it does not recognize while a classical verifier keeps working
524    /// against the classical entry.
525    #[test]
526    fn id_token_skips_unsupported_alg_and_accepts_classical() -> anyhow::Result<()> {
527        let sk = ed25519_dalek::SigningKey::from_bytes(&[0x33; 32]);
528        let vk = sk.verifying_key();
529
530        let keys = vec![
531            // Unknown composite_alg entry — must be skipped, not fatal.
532            serde_json::json!({"kty": "AKP", "alg": "ML-DSA-65-Ed25519", "kid": "pq"}),
533            // Classical Ed25519 entry — the real verifier.
534            serde_json::json!({
535                "kty": "OKP", "crv": "Ed25519", "alg": "EdDSA", "kid": "classic",
536                "x": URL_SAFE_NO_PAD.encode(vk.as_bytes()),
537            }),
538        ];
539
540        let claims = serde_json::json!({
541            "iss": "https://idp.example.com",
542            "aud": "client-42",
543            "sub": "user-1",
544            "exp": (jsonwebtoken::get_current_timestamp() + 300),
545        });
546        let token = sign_eddsa_jwt(&sk, &claims, None);
547        let v = verify_id_token_with_keys(&token, &keys, "https://idp.example.com", "client-42")?;
548        assert_eq!(v.claims["sub"], "user-1");
549        Ok(())
550    }
551
552    #[test]
553    fn test_decode_unverified_valid() {
554        let payload = serde_json::json!({"sub": "user123", "iss": "https://example.com"});
555        let payload_b64 = URL_SAFE_NO_PAD.encode(payload.to_string().as_bytes());
556        let token = format!("e30.{}.Zm9v", payload_b64);
557        let claims = decode_unverified(&token).unwrap();
558        assert_eq!(claims["sub"], "user123");
559    }
560
561    #[test]
562    fn test_decode_unverified_invalid_format() {
563        assert!(decode_unverified("not.a.jwt").is_err());
564        assert!(decode_unverified("onlytwo").is_err());
565    }
566}