Working with httpauth, trying to use extractors
This commit is contained in:
@@ -5,8 +5,6 @@ extern crate diesel_migrations;
|
||||
use std::env;
|
||||
use std::collections::HashSet;
|
||||
use std::sync::Arc;
|
||||
use actix_identity::IdentityMiddleware;
|
||||
use actix_session::{SessionMiddleware, storage::{RedisActorSessionStore, CookieSessionStore}, config::BrowserSession};
|
||||
use log::{error, warn, info};
|
||||
use serenity::client::Cache;
|
||||
use serenity::framework::StandardFramework;
|
||||
@@ -20,6 +18,7 @@ use crate::bot::{commands::oai::GPTModel, handler::Handler};
|
||||
|
||||
use dotenv::dotenv;
|
||||
|
||||
mod auth;
|
||||
mod dnd;
|
||||
mod bot;
|
||||
mod db;
|
||||
@@ -113,21 +112,21 @@ async fn main() -> std::io::Result<()> {
|
||||
let port = env::var("SERVICE_PORT").unwrap_or("5000".to_string());
|
||||
|
||||
let server = match HttpServer::new(move || {
|
||||
let private_key = actix_web::cookie::Key::generate();
|
||||
// let private_key = actix_web::cookie::Key::generate();
|
||||
// let redis_host = env::var("REDIS_HOST").unwrap_or("localhost".to_string());
|
||||
// let redis_port = env::var("REDIS_PORT").unwrap_or("6379".to_string());
|
||||
let session = SessionMiddleware::builder(
|
||||
// let session = SessionMiddleware::builder(
|
||||
// RedisActorSessionStore::new(format!("{}:{}", redis_host, redis_port)),
|
||||
CookieSessionStore::default(),
|
||||
private_key
|
||||
)
|
||||
.session_lifecycle(BrowserSession::default())
|
||||
.cookie_name("auth".to_owned())
|
||||
.cookie_secure(false)
|
||||
.cookie_http_only(false)
|
||||
.cookie_domain(Some("localhost".to_owned()))
|
||||
.cookie_path("/".to_owned())
|
||||
.build();
|
||||
// CookieSessionStore::default(),
|
||||
// private_key
|
||||
// )
|
||||
// .session_lifecycle(BrowserSession::default())
|
||||
// .cookie_name("auth".to_owned())
|
||||
// .cookie_secure(false)
|
||||
// .cookie_http_only(false)
|
||||
// .cookie_domain(Some("localhost".to_owned()))
|
||||
// .cookie_path("/".to_owned())
|
||||
// .build();
|
||||
let cors = Cors::default()
|
||||
.allow_any_origin()
|
||||
.allow_any_method()
|
||||
@@ -135,13 +134,13 @@ async fn main() -> std::io::Result<()> {
|
||||
.supports_credentials()
|
||||
.max_age(3600);
|
||||
App::new()
|
||||
.wrap(IdentityMiddleware::default())
|
||||
.wrap(session)
|
||||
// .wrap(IdentityMiddleware::default())
|
||||
// .wrap(session)
|
||||
.wrap(cors)
|
||||
.app_data(web::Data::new(Arc::clone(&app_data)))
|
||||
.configure(crate::db::messages::init_routes)
|
||||
.configure(crate::db::spells::init_routes)
|
||||
.configure(crate::db::users::init_routes)
|
||||
.configure(crate::auth::init_routes)
|
||||
.configure(crate::bot::api::init_routes)
|
||||
})
|
||||
.bind(format!("{}:{}", host, port)) {
|
||||
|
||||
Reference in New Issue
Block a user