Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/axum-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ workspace = true
[dependencies]
axum.workspace = true
axum-extra.workspace = true
base64ct.workspace = true
chrono.workspace = true
data-encoding = "2.8.0"
headers.workspace = true
http.workspace = true
icu_locid = "1.5.0"
Expand Down
8 changes: 4 additions & 4 deletions crates/axum-utils/src/csrf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Please see LICENSE in the repository root for full details.

use base64ct::{Base64UrlUnpadded, Encoding};
use chrono::{DateTime, Duration, Utc};
use data_encoding::{BASE64URL_NOPAD, DecodeError};
use mas_storage::Clock;
use rand::{Rng, RngCore, distributions::Standard, prelude::Distribution as _};
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -35,7 +35,7 @@ pub enum CsrfError {

/// Failed to decode the token
#[error("could not decode CSRF token")]
Decode(#[from] DecodeError),
Decode(#[from] base64ct::Error),
}

/// A CSRF token
Expand Down Expand Up @@ -68,7 +68,7 @@ impl CsrfToken {
/// Get the value to include in HTML forms
#[must_use]
pub fn form_value(&self) -> String {
BASE64URL_NOPAD.encode(&self.token[..])
Base64UrlUnpadded::encode_string(&self.token[..])
}

/// Verifies that the value got from an HTML form matches this token
Expand All @@ -77,7 +77,7 @@ impl CsrfToken {
///
/// Returns an error if the value in the form does not match this token
pub fn verify_form_value(&self, form_value: &str) -> Result<(), CsrfError> {
let form_value = BASE64URL_NOPAD.decode(form_value.as_bytes())?;
let form_value = Base64UrlUnpadded::decode_vec(form_value)?;
if self.token[..] == form_value {
Ok(())
} else {
Expand Down
2 changes: 1 addition & 1 deletion crates/oauth2-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ repository.workspace = true
workspace = true

[dependencies]
base64ct.workspace = true
serde.workspace = true
serde_json.workspace = true
language-tags = { version = "0.3.2", features = ["serde"] }
url.workspace = true
serde_with = { version = "3.12.0", features = ["chrono"] }
chrono.workspace = true
sha2 = "0.10.8"
data-encoding = "2.8.0"
thiserror.workspace = true

mas-iana.workspace = true
Expand Down
4 changes: 2 additions & 2 deletions crates/oauth2-types/src/pkce.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

use std::borrow::Cow;

use data_encoding::BASE64URL_NOPAD;
use base64ct::{Base64UrlUnpadded, Encoding};
use mas_iana::oauth::PkceCodeChallengeMethod;
use serde::{Deserialize, Serialize};
use sha2::{Digest, Sha256};
Expand Down Expand Up @@ -98,7 +98,7 @@ impl CodeChallengeMethodExt for PkceCodeChallengeMethod {
let mut hasher = Sha256::new();
hasher.update(verifier.as_bytes());
let hash = hasher.finalize();
let verifier = BASE64URL_NOPAD.encode(&hash);
let verifier = Base64UrlUnpadded::encode_string(&hash);
verifier.into()
}
_ => return Err(CodeChallengeError::UnknownChallengeMethod),
Expand Down
Loading