identity-service-api: Add public key validity endpoint

This commit is contained in:
Nym Seddon 2021-02-15 20:18:54 +00:00 committed by GitHub
parent 646776b362
commit 887e8247f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 46 additions and 0 deletions

View File

@ -0,0 +1,3 @@
//! Endpoints to retrieve, update, and validate keys with an identity server.
pub mod check_public_key_validity;

View File

@ -0,0 +1,3 @@
//! Endpoint to check for valid public key with an identity server.
pub mod v2;

View File

@ -0,0 +1,39 @@
//! [GET /_matrix/identity/v2/pubkey/isvalid](https://matrix.org/docs/spec/identity_service/0.3.0#get-matrix-identity-v2-pubkey-isvalid)
use ruma_api::ruma_api;
ruma_api! {
metadata: {
description: "Check whether a long-term public key is valid. The response should always be the same, provided the key exists.",
method: GET,
name: "check_public_key_validity",
path: "/_matrix/identity/v2/pubkey/isvalid",
authentication: None,
rate_limited: false,
}
request: {
/// Base64-encoded (no padding) public key to check for validity.
#[ruma_api(query)]
pub public_key: &'a str,
}
response: {
/// Whether the public key is recognised and is currently valid.
pub valid: bool,
}
}
impl<'a> Request<'a> {
/// Create a `Request` with the given base64-encoded (unpadded) public key.
pub fn new(public_key: &'a str) -> Self {
Self { public_key }
}
}
impl Response {
/// Create a `Response` with the given bool indicating the validity of the public key.
pub fn new(valid: bool) -> Self {
Self { valid }
}
}

View File

@ -1,2 +1,3 @@
pub mod authentication; pub mod authentication;
pub mod keys;
pub mod status; pub mod status;