feat: Prefill server name in federation test
This commit is contained in:
parent
cbcf4300df
commit
fb9d4c30f4
9 changed files with 24 additions and 12 deletions
|
@ -21,6 +21,7 @@ crate-type = [
|
|||
|
||||
[dependencies]
|
||||
conduwuit-build-metadata.workspace = true
|
||||
conduwuit-service.workspace = true
|
||||
|
||||
askama = "0.14.0"
|
||||
|
||||
|
|
|
@ -1,23 +1,34 @@
|
|||
use askama::Template;
|
||||
use axum::{
|
||||
Router,
|
||||
extract::State,
|
||||
http::{StatusCode, header},
|
||||
response::{Html, IntoResponse, Response},
|
||||
routing::get,
|
||||
};
|
||||
use conduwuit_build_metadata::{GIT_REMOTE_COMMIT_URL, GIT_REMOTE_WEB_URL, VERSION_EXTRA};
|
||||
use conduwuit_service::state;
|
||||
|
||||
pub fn build<S>() -> Router<()> { Router::new().route("/", get(index_handler)) }
|
||||
pub fn build() -> Router<state::State> {
|
||||
let router = Router::<state::State>::new();
|
||||
router.route("/", get(index_handler))
|
||||
}
|
||||
|
||||
async fn index_handler() -> Result<impl IntoResponse, WebError> {
|
||||
async fn index_handler(
|
||||
State(services): State<state::State>,
|
||||
) -> Result<impl IntoResponse, WebError> {
|
||||
#[derive(Debug, Template)]
|
||||
#[template(path = "index.html.j2")]
|
||||
struct Tmpl<'a> {
|
||||
nonce: &'a str,
|
||||
server_name: &'a str,
|
||||
}
|
||||
let nonce = rand::random::<u64>().to_string();
|
||||
|
||||
let template = Tmpl { nonce: &nonce };
|
||||
let template = Tmpl {
|
||||
nonce: &nonce,
|
||||
server_name: services.config.server_name.as_str(),
|
||||
};
|
||||
Ok((
|
||||
[(header::CONTENT_SECURITY_POLICY, format!("default-src 'none' 'nonce-{nonce}';"))],
|
||||
Html(template.render()?),
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
<li>Read the <a href="https://continuwuity.org/introduction">documentation</a></li>
|
||||
<li>Join the <a href="https://continuwuity.org/community">community</a></li>
|
||||
<li>Log in with a <a href="https://matrix.org/ecosystem/clients/">client</a></li>
|
||||
<li>Ensure <a href="https://federationtester.matrix.org/">federation</a> works</li>
|
||||
<li>Ensure <a href="https://federationtester.matrix.org/#{{ server_name }}">federation</a> works</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue