|
1 | | -// Copyright 2024 New Vector Ltd. |
| 1 | +// Copyright 2024, 2025 New Vector Ltd. |
2 | 2 | // Copyright 2021-2024 The Matrix.org Foundation C.I.C. |
3 | 3 | // |
4 | 4 | // SPDX-License-Identifier: AGPL-3.0-only |
5 | 5 | // Please see LICENSE in the repository root for full details. |
6 | 6 |
|
7 | | -use base64ct::{Base64Url, Encoding}; |
| 7 | +use base64ct::{Base64UrlUnpadded, Encoding}; |
8 | 8 | use chrono::{DateTime, Utc}; |
9 | 9 | use crc::{CRC_32_ISO_HDLC, Crc}; |
10 | 10 | use mas_iana::oauth::OAuthTokenTypeHint; |
@@ -353,7 +353,7 @@ impl PartialEq<OAuthTokenTypeHint> for TokenType { |
353 | 353 | /// We won't bother to decode them fully, but we can check to see if the first |
354 | 354 | /// constraint is the `location` constraint. |
355 | 355 | fn is_likely_synapse_macaroon(token: &str) -> bool { |
356 | | - let Ok(decoded) = Base64Url::decode_vec(token) else { |
| 356 | + let Ok(decoded) = Base64UrlUnpadded::decode_vec(token) else { |
357 | 357 | return false; |
358 | 358 | }; |
359 | 359 | decoded.get(4..13) == Some(b"location ") |
@@ -443,8 +443,8 @@ mod tests { |
443 | 443 | "MDAxYmxvY2F0aW9uIGxpYnJlcHVzaC5uZXQKMDAx" |
444 | 444 | )); |
445 | 445 |
|
446 | | - // Whilst this is a macaroon, it's not a Synapse macaroon |
447 | | - assert!(!is_likely_synapse_macaroon( |
| 446 | + // This is a valid macaroon (even though Synapse did not generate this one) |
| 447 | + assert!(is_likely_synapse_macaroon( |
448 | 448 | "MDAxY2xvY2F0aW9uIGh0dHA6Ly9teWJhbmsvCjAwMjZpZGVudGlmaWVyIHdlIHVzZWQgb3VyIHNlY3JldCBrZXkKMDAyZnNpZ25hdHVyZSDj2eApCFJsTAA5rhURQRXZf91ovyujebNCqvD2F9BVLwo" |
449 | 449 | )); |
450 | 450 |
|
|
0 commit comments