route permission change

This commit is contained in:
Paul Zinselmeyer 2023-12-19 12:13:48 +01:00
parent 29c0fdc1ee
commit 2cc33cc3e8

View file

@ -7,7 +7,7 @@ use duration_str::{deserialize_option_duration, parse_std};
use jwt::JwtApplication; use jwt::JwtApplication;
use prometheus_client::{ use prometheus_client::{
encoding::EncodeLabelSet, encoding::EncodeLabelSet,
metrics::{counter::Counter, family::Family, gauge::Gauge, histogram::Histogram}, metrics::{counter::Counter, family::Family, gauge::Gauge},
registry::{Registry, Unit}, registry::{Registry, Unit},
}; };
use sailfish::TemplateOnce; use sailfish::TemplateOnce;
@ -15,7 +15,7 @@ use std::{
borrow::Borrow, borrow::Borrow,
env, env,
str::FromStr, str::FromStr,
sync::{atomic::AtomicU64, Arc}, sync::Arc,
time::{Duration, SystemTime, UNIX_EPOCH}, time::{Duration, SystemTime, UNIX_EPOCH},
}; };
use tower_http::services::ServeDir; use tower_http::services::ServeDir;
@ -25,8 +25,7 @@ use tower_sessions::{cookie::SameSite, MemoryStore, SessionManagerLayer};
use axum::{ use axum::{
async_trait, async_trait,
body::{Body, HttpBody}, body::Body,
debug_handler,
error_handling::HandleErrorLayer, error_handling::HandleErrorLayer,
extract::{FromRef, FromRequest, Multipart, Path, Query, State}, extract::{FromRef, FromRequest, Multipart, Path, Query, State},
http::{ http::{
@ -34,11 +33,10 @@ use axum::{
HeaderMap, HeaderValue, Request, StatusCode, Uri, HeaderMap, HeaderValue, Request, StatusCode, Uri,
}, },
response::{Html, IntoResponse, Redirect, Response}, response::{Html, IntoResponse, Redirect, Response},
routing::{get, post}, routing::{delete, get, post},
BoxError, Router, BoxError, Router,
}; };
use bytes::Bytes;
use chacha20::{ use chacha20::{
cipher::{KeyIvInit, StreamCipher}, cipher::{KeyIvInit, StreamCipher},
ChaCha20, ChaCha20,
@ -210,10 +208,10 @@ async fn main() {
let app = Router::new() let app = Router::new()
.route("/", get(get_index)) .route("/", get(get_index))
.route("/:id", post(upload_bin).put(upload_bin).delete(delete_bin)) .route("/:id", delete(delete_bin))
.route("/:id/delete", get(delete_bin_interactive).post(delete_bin)) .route("/:id/delete", get(delete_bin_interactive).post(delete_bin))
.layer(oidc_login_service) .layer(oidc_login_service)
.route("/:id", get(get_item)) .route("/:id", get(get_item).post(upload_bin).put(upload_bin))
.route("/metrics", get(metrics)) .route("/metrics", get(metrics))
.nest_service("/static", ServeDir::new("static")) .nest_service("/static", ServeDir::new("static"))
.with_state(state) .with_state(state)