Cargo Format

This commit is contained in:
William Brown 2019-02-05 12:38:17 +10:00
parent f22562a0ba
commit 1caf2f86e3
4 changed files with 23 additions and 28 deletions

View file

@ -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| {

View file

@ -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<AuthResult, OperationError>;
@ -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")),
}
}
}

View file

@ -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<String>),
@ -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,
}

View file

@ -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;