mirror of
https://github.com/amtoaer/bili-sync.git
synced 2026-07-12 16:11:32 +08:00
feat: 迁移所有配置到数据库,并支持运行时重载 (#364)
This commit is contained in:
@@ -7,10 +7,12 @@ use utoipa::Modify;
|
||||
use utoipa::openapi::security::{ApiKey, ApiKeyValue, SecurityScheme};
|
||||
|
||||
use crate::api::wrapper::ApiResponse;
|
||||
use crate::config::CONFIG;
|
||||
use crate::config::VersionedConfig;
|
||||
|
||||
pub async fn auth(headers: HeaderMap, request: Request, next: Next) -> Result<Response, StatusCode> {
|
||||
if request.uri().path().starts_with("/api/") && get_token(&headers) != CONFIG.auth_token {
|
||||
if request.uri().path().starts_with("/api/")
|
||||
&& get_token(&headers).is_none_or(|token| token != VersionedConfig::get().load().auth_token)
|
||||
{
|
||||
return Ok(ApiResponse::unauthorized(()).into_response());
|
||||
}
|
||||
Ok(next.run(request).await)
|
||||
|
||||
Reference in New Issue
Block a user