diff --git a/src/lib/core.rs b/src/lib/core.rs index f99ad071c..5e0a80ff2 100644 --- a/src/lib/core.rs +++ b/src/lib/core.rs @@ -11,10 +11,12 @@ use futures::{future, Future, Stream}; use super::config::Configuration; // SearchResult -use super::event::{DeleteEvent, ModifyEvent, CreateEvent, SearchEvent, AuthEvent}; +use super::event::{AuthEvent, CreateEvent, DeleteEvent, ModifyEvent, SearchEvent}; use super::filter::Filter; use super::log; -use super::proto_v1::{DeleteRequest, ModifyRequest, CreateRequest, SearchRequest, AuthRequest, AuthResponse}; +use super::proto_v1::{ + AuthRequest, AuthResponse, CreateRequest, DeleteRequest, ModifyRequest, SearchRequest, +}; use super::server; struct AppState { @@ -152,16 +154,13 @@ fn auth( req.session().set("counter", counter).unwrap(); }; - // We probably need to know if we allocate the cookie, that this is a // new session, and in that case, anything *except* authrequest init is // invalid. let res = state .qe - .send( - AuthEvent::from_request(obj), - ) + .send(AuthEvent::from_request(obj)) .from_err() .and_then(|res| match res { Ok(event_result) => { @@ -264,7 +263,6 @@ pub fn create_server_core(config: Configuration) { .resource("/v1/search", |r| { r.method(http::Method::POST).with_async(search) }) - // This is one of the times we need cookies :) // curl -b /tmp/cookie.jar -c /tmp/cookie.jar --header "Content-Type: application/json" --request POST --data '{ "state" : { "Init": ["Anonymous", []] }}' http://127.0.0.1:8080/v1/auth .resource("/v1/auth", |r| { diff --git a/src/lib/event.rs b/src/lib/event.rs index ae9e35ea2..280d35825 100644 --- a/src/lib/event.rs +++ b/src/lib/event.rs @@ -1,6 +1,9 @@ use super::filter::Filter; use super::proto_v1::Entry as ProtoEntry; -use super::proto_v1::{CreateRequest, Response, SearchRequest, SearchResponse, AuthRequest, AuthResponse, AuthStatus, DeleteRequest, ModifyRequest}; +use super::proto_v1::{ + AuthRequest, AuthResponse, AuthStatus, CreateRequest, DeleteRequest, ModifyRequest, Response, + SearchRequest, SearchResponse, +}; use actix::prelude::*; use entry::{Entry, EntryCommitted, EntryInvalid, EntryNew, EntryValid}; use error::OperationError; @@ -195,8 +198,7 @@ impl ModifyEvent { } #[derive(Debug)] -pub struct AuthEvent { -} +pub struct AuthEvent {} impl Message for AuthEvent { type Result = Result; @@ -206,16 +208,14 @@ impl AuthEvent { pub fn from_request(request: AuthRequest) -> Self { AuthEvent {} } - } -pub struct AuthResult { -} +pub struct AuthResult {} impl AuthResult { pub fn response(self) -> AuthResponse { AuthResponse { - status: AuthStatus::Begin(String::from("hello")) + status: AuthStatus::Begin(String::from("hello")), } } } diff --git a/src/lib/proto_v1.rs b/src/lib/proto_v1.rs index 263226832..7c11cec2c 100644 --- a/src/lib/proto_v1.rs +++ b/src/lib/proto_v1.rs @@ -92,8 +92,6 @@ pub struct ModifyRequest { // On loginSuccess, we send a cookie, and that allows the token to be // generated. The cookie can be shared between servers. - - #[derive(Debug, Serialize, Deserialize)] pub enum AuthState { Init(String, Vec), @@ -107,7 +105,7 @@ pub enum AuthState { // Request auth for identity X with roles Y? #[derive(Debug, Serialize, Deserialize)] pub struct AuthRequest { - pub state: AuthState + pub state: AuthState, } // Respond with the list of auth types and nonce, etc. @@ -115,18 +113,17 @@ pub struct AuthRequest { #[derive(Debug, Serialize, Deserialize)] pub enum AuthStatus { Begin(String), // uuid of this session. - // Continue, // Keep going, here are the things you could still provide ... - // Go away, you made a mistake somewhere. - // Provide reason? - // Denied(String), - // Welcome friend. - // On success provide entry "self", for group assertions? - // We also provide the "cookie"/token? - // Success(String, Entry), + // Continue, // Keep going, here are the things you could still provide ... + // Go away, you made a mistake somewhere. + // Provide reason? + // Denied(String), + // Welcome friend. + // On success provide entry "self", for group assertions? + // We also provide the "cookie"/token? + // Success(String, Entry), } #[derive(Debug, Serialize, Deserialize)] pub struct AuthResponse { pub status: AuthStatus, } - diff --git a/src/lib/server.rs b/src/lib/server.rs index fb8ee49df..cd88bd407 100644 --- a/src/lib/server.rs +++ b/src/lib/server.rs @@ -13,8 +13,8 @@ use constants::{JSON_ANONYMOUS_V1, JSON_SYSTEM_INFO_V1}; use entry::{Entry, EntryCommitted, EntryInvalid, EntryNew, EntryValid}; use error::{OperationError, SchemaError}; use event::{ - CreateEvent, DeleteEvent, ExistsEvent, ModifyEvent, OpResult, SearchEvent, SearchResult, - AuthEvent, AuthResult, + AuthEvent, AuthResult, CreateEvent, DeleteEvent, ExistsEvent, ModifyEvent, OpResult, + SearchEvent, SearchResult, }; use filter::Filter; use log::EventLog;