1
0
mirror of https://github.com/matrix-org/matrix-authentication-service.git synced 2025-11-20 12:02:22 +03:00

Disallow Ulid generation without explicit timestamp and rng

This commit is contained in:
Quentin Gliech
2022-10-21 18:58:52 +02:00
parent 559181c2c3
commit f1aa42fae4
5 changed files with 34 additions and 7 deletions

View File

@@ -109,6 +109,7 @@ pub(crate) async fn post(
State(policy_factory): State<Arc<PolicyFactory>>,
Json(body): Json<ClientMetadata>,
) -> Result<impl IntoResponse, RouteError> {
let (clock, mut rng) = crate::rng_and_clock()?;
info!(?body, "Client registration");
// Validate the body
@@ -127,10 +128,12 @@ pub(crate) async fn post(
let mut txn = pool.begin().await?;
// Let's generate a random client ID
let client_id = Ulid::new();
let client_id = Ulid::from_datetime_with_source(clock.now().into(), &mut rng);
insert_client(
&mut txn,
&mut rng,
&clock,
client_id,
metadata.redirect_uris(),
None,