move normalize_uri_path and extract_cookie to proxmox-rest-server crate
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
committed by
Thomas Lamprecht
parent
605fe2e7e7
commit
778c7d954b
@ -6,10 +6,9 @@ use std::sync::Arc;
|
||||
use pbs_tools::ticket::{self, Ticket};
|
||||
use pbs_config::{token_shadow, CachedUserInfo};
|
||||
use pbs_api_types::{Authid, Userid};
|
||||
use proxmox_rest_server::{ApiAuth, AuthError};
|
||||
use proxmox_rest_server::{ApiAuth, AuthError, extract_cookie};
|
||||
|
||||
use crate::auth_helpers::*;
|
||||
use crate::tools;
|
||||
|
||||
use hyper::header;
|
||||
use percent_encoding::percent_decode_str;
|
||||
@ -33,7 +32,7 @@ impl UserApiAuth {
|
||||
fn extract_auth_data(headers: &http::HeaderMap) -> Option<AuthData> {
|
||||
if let Some(raw_cookie) = headers.get(header::COOKIE) {
|
||||
if let Ok(cookie) = raw_cookie.to_str() {
|
||||
if let Some(ticket) = tools::extract_cookie(cookie, "PBSAuthCookie") {
|
||||
if let Some(ticket) = extract_cookie(cookie, "PBSAuthCookie") {
|
||||
let csrf_token = match headers.get("CSRFPreventionToken").map(|v| v.to_str()) {
|
||||
Some(Ok(v)) => Some(v.to_owned()),
|
||||
_ => None,
|
||||
|
@ -11,9 +11,9 @@ use hyper::{Body, Request, Response, StatusCode};
|
||||
use proxmox::api::{ApiResponseFuture, HttpError, Router, RpcEnvironment};
|
||||
use proxmox::http_err;
|
||||
|
||||
use proxmox_rest_server::normalize_uri_path;
|
||||
use proxmox_rest_server::formatter::*;
|
||||
|
||||
use crate::tools;
|
||||
use crate::server::WorkerTask;
|
||||
|
||||
/// Hyper Service implementation to handle stateful H2 connections.
|
||||
@ -44,7 +44,7 @@ impl <E: RpcEnvironment + Clone> H2Service<E> {
|
||||
|
||||
let method = parts.method.clone();
|
||||
|
||||
let (path, components) = match tools::normalize_uri_path(parts.uri.path()) {
|
||||
let (path, components) = match normalize_uri_path(parts.uri.path()) {
|
||||
Ok((p,c)) => (p, c),
|
||||
Err(err) => return future::err(http_err!(BAD_REQUEST, "{}", err)).boxed(),
|
||||
};
|
||||
|
@ -36,13 +36,13 @@ use pbs_tools::stream::AsyncReaderStream;
|
||||
use pbs_api_types::{Authid, Userid};
|
||||
use proxmox_rest_server::{
|
||||
ApiConfig, FileLogger, FileLogOptions, AuthError, RestEnvironment, CompressionMethod,
|
||||
extract_cookie, normalize_uri_path,
|
||||
};
|
||||
use proxmox_rest_server::formatter::*;
|
||||
|
||||
use pbs_config::CachedUserInfo;
|
||||
|
||||
use crate::auth_helpers::*;
|
||||
use crate::tools;
|
||||
|
||||
extern "C" {
|
||||
fn tzset();
|
||||
@ -645,7 +645,7 @@ async fn handle_static_file_download(
|
||||
|
||||
fn extract_lang_header(headers: &http::HeaderMap) -> Option<String> {
|
||||
if let Some(Ok(cookie)) = headers.get("COOKIE").map(|v| v.to_str()) {
|
||||
return tools::extract_cookie(cookie, "PBSLangCookie");
|
||||
return extract_cookie(cookie, "PBSLangCookie");
|
||||
}
|
||||
None
|
||||
}
|
||||
@ -669,7 +669,7 @@ async fn handle_request(
|
||||
) -> Result<Response<Body>, Error> {
|
||||
let (parts, body) = req.into_parts();
|
||||
let method = parts.method.clone();
|
||||
let (path, components) = tools::normalize_uri_path(parts.uri.path())?;
|
||||
let (path, components) = normalize_uri_path(parts.uri.path())?;
|
||||
|
||||
let comp_len = components.len();
|
||||
|
||||
|
Reference in New Issue
Block a user