Read Token signing key from environment
This commit is contained in:
16
src/main.rs
16
src/main.rs
@@ -12,7 +12,7 @@ use rayon::prelude::*;
|
||||
use serde::Serialize;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use crate::data::{Claims, CreateAccountRequest, Token};
|
||||
use crate::data::{secret_key, Claims, CreateAccountRequest, Token};
|
||||
use crate::database::{create_user, get_user, user_exists};
|
||||
use crate::files::{is_valid_path, list_files};
|
||||
use crate::video::*;
|
||||
@@ -48,7 +48,7 @@ async fn login(creds: Json<LoginRequest>) -> impl Responder {
|
||||
let token = encode(
|
||||
&Header::default(),
|
||||
&claims,
|
||||
&EncodingKey::from_secret("secret_token".as_ref()),
|
||||
&EncodingKey::from_secret(secret_key().as_bytes()),
|
||||
)
|
||||
.unwrap();
|
||||
HttpResponse::Ok().json(Token { token: &token })
|
||||
@@ -139,7 +139,11 @@ async fn generate_video(_claims: Claims, body: web::Json<ThumbnailRequest>) -> i
|
||||
}
|
||||
|
||||
#[get("/video/stream")]
|
||||
async fn stream_video(request: HttpRequest, _: Claims, path: web::Query<ThumbnailRequest>) -> impl Responder {
|
||||
async fn stream_video(
|
||||
request: HttpRequest,
|
||||
_: Claims,
|
||||
path: web::Query<ThumbnailRequest>,
|
||||
) -> impl Responder {
|
||||
let playlist = &path.path;
|
||||
println!("Playlist: {}", playlist);
|
||||
|
||||
@@ -151,7 +155,11 @@ async fn stream_video(request: HttpRequest, _: Claims, path: web::Query<Thumbnai
|
||||
}
|
||||
|
||||
#[get("/video/{path}")]
|
||||
async fn get_video_part(request: HttpRequest, _: Claims , path: web::Path<ThumbnailRequest>) -> impl Responder {
|
||||
async fn get_video_part(
|
||||
request: HttpRequest,
|
||||
_: Claims,
|
||||
path: web::Path<ThumbnailRequest>,
|
||||
) -> impl Responder {
|
||||
let part = &path.path;
|
||||
println!("Video part: {}", part);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user