mirror of
https://github.com/kanidm/kanidm.git
synced 2025-02-23 20:47:01 +01:00
Cargo Format
This commit is contained in:
parent
f22562a0ba
commit
1caf2f86e3
|
@ -11,10 +11,12 @@ use futures::{future, Future, Stream};
|
||||||
use super::config::Configuration;
|
use super::config::Configuration;
|
||||||
|
|
||||||
// SearchResult
|
// SearchResult
|
||||||
use super::event::{DeleteEvent, ModifyEvent, CreateEvent, SearchEvent, AuthEvent};
|
use super::event::{AuthEvent, CreateEvent, DeleteEvent, ModifyEvent, SearchEvent};
|
||||||
use super::filter::Filter;
|
use super::filter::Filter;
|
||||||
use super::log;
|
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;
|
use super::server;
|
||||||
|
|
||||||
struct AppState {
|
struct AppState {
|
||||||
|
@ -152,16 +154,13 @@ fn auth(
|
||||||
req.session().set("counter", counter).unwrap();
|
req.session().set("counter", counter).unwrap();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// We probably need to know if we allocate the cookie, that this is a
|
// 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
|
// new session, and in that case, anything *except* authrequest init is
|
||||||
// invalid.
|
// invalid.
|
||||||
|
|
||||||
let res = state
|
let res = state
|
||||||
.qe
|
.qe
|
||||||
.send(
|
.send(AuthEvent::from_request(obj))
|
||||||
AuthEvent::from_request(obj),
|
|
||||||
)
|
|
||||||
.from_err()
|
.from_err()
|
||||||
.and_then(|res| match res {
|
.and_then(|res| match res {
|
||||||
Ok(event_result) => {
|
Ok(event_result) => {
|
||||||
|
@ -264,7 +263,6 @@ pub fn create_server_core(config: Configuration) {
|
||||||
.resource("/v1/search", |r| {
|
.resource("/v1/search", |r| {
|
||||||
r.method(http::Method::POST).with_async(search)
|
r.method(http::Method::POST).with_async(search)
|
||||||
})
|
})
|
||||||
|
|
||||||
// This is one of the times we need cookies :)
|
// 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
|
// 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| {
|
.resource("/v1/auth", |r| {
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
use super::filter::Filter;
|
use super::filter::Filter;
|
||||||
use super::proto_v1::Entry as ProtoEntry;
|
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 actix::prelude::*;
|
||||||
use entry::{Entry, EntryCommitted, EntryInvalid, EntryNew, EntryValid};
|
use entry::{Entry, EntryCommitted, EntryInvalid, EntryNew, EntryValid};
|
||||||
use error::OperationError;
|
use error::OperationError;
|
||||||
|
@ -195,8 +198,7 @@ impl ModifyEvent {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct AuthEvent {
|
pub struct AuthEvent {}
|
||||||
}
|
|
||||||
|
|
||||||
impl Message for AuthEvent {
|
impl Message for AuthEvent {
|
||||||
type Result = Result<AuthResult, OperationError>;
|
type Result = Result<AuthResult, OperationError>;
|
||||||
|
@ -206,16 +208,14 @@ impl AuthEvent {
|
||||||
pub fn from_request(request: AuthRequest) -> Self {
|
pub fn from_request(request: AuthRequest) -> Self {
|
||||||
AuthEvent {}
|
AuthEvent {}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct AuthResult {
|
pub struct AuthResult {}
|
||||||
}
|
|
||||||
|
|
||||||
impl AuthResult {
|
impl AuthResult {
|
||||||
pub fn response(self) -> AuthResponse {
|
pub fn response(self) -> AuthResponse {
|
||||||
AuthResponse {
|
AuthResponse {
|
||||||
status: AuthStatus::Begin(String::from("hello"))
|
status: AuthStatus::Begin(String::from("hello")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,8 +92,6 @@ pub struct ModifyRequest {
|
||||||
// On loginSuccess, we send a cookie, and that allows the token to be
|
// On loginSuccess, we send a cookie, and that allows the token to be
|
||||||
// generated. The cookie can be shared between servers.
|
// generated. The cookie can be shared between servers.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
pub enum AuthState {
|
pub enum AuthState {
|
||||||
Init(String, Vec<String>),
|
Init(String, Vec<String>),
|
||||||
|
@ -107,7 +105,7 @@ pub enum AuthState {
|
||||||
// Request auth for identity X with roles Y?
|
// Request auth for identity X with roles Y?
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
pub struct AuthRequest {
|
pub struct AuthRequest {
|
||||||
pub state: AuthState
|
pub state: AuthState,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Respond with the list of auth types and nonce, etc.
|
// Respond with the list of auth types and nonce, etc.
|
||||||
|
@ -115,18 +113,17 @@ pub struct AuthRequest {
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
pub enum AuthStatus {
|
pub enum AuthStatus {
|
||||||
Begin(String), // uuid of this session.
|
Begin(String), // uuid of this session.
|
||||||
// Continue, // Keep going, here are the things you could still provide ...
|
// Continue, // Keep going, here are the things you could still provide ...
|
||||||
// Go away, you made a mistake somewhere.
|
// Go away, you made a mistake somewhere.
|
||||||
// Provide reason?
|
// Provide reason?
|
||||||
// Denied(String),
|
// Denied(String),
|
||||||
// Welcome friend.
|
// Welcome friend.
|
||||||
// On success provide entry "self", for group assertions?
|
// On success provide entry "self", for group assertions?
|
||||||
// We also provide the "cookie"/token?
|
// We also provide the "cookie"/token?
|
||||||
// Success(String, Entry),
|
// Success(String, Entry),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
pub struct AuthResponse {
|
pub struct AuthResponse {
|
||||||
pub status: AuthStatus,
|
pub status: AuthStatus,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,8 +13,8 @@ use constants::{JSON_ANONYMOUS_V1, JSON_SYSTEM_INFO_V1};
|
||||||
use entry::{Entry, EntryCommitted, EntryInvalid, EntryNew, EntryValid};
|
use entry::{Entry, EntryCommitted, EntryInvalid, EntryNew, EntryValid};
|
||||||
use error::{OperationError, SchemaError};
|
use error::{OperationError, SchemaError};
|
||||||
use event::{
|
use event::{
|
||||||
CreateEvent, DeleteEvent, ExistsEvent, ModifyEvent, OpResult, SearchEvent, SearchResult,
|
AuthEvent, AuthResult, CreateEvent, DeleteEvent, ExistsEvent, ModifyEvent, OpResult,
|
||||||
AuthEvent, AuthResult,
|
SearchEvent, SearchResult,
|
||||||
};
|
};
|
||||||
use filter::Filter;
|
use filter::Filter;
|
||||||
use log::EventLog;
|
use log::EventLog;
|
||||||
|
|
Loading…
Reference in a new issue