initial commit
This commit is contained in:
commit
a726004a6c
|
@ -0,0 +1 @@
|
||||||
|
/target
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,12 @@
|
||||||
|
[package]
|
||||||
|
name = "baseauth"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
license = "MIT"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
tokio = { version = "1.29", features = ["macros", "rt-multi-thread", "sync"] }
|
||||||
|
anyhow = "1.0"
|
||||||
|
actix-web = "4"
|
|
@ -0,0 +1,20 @@
|
||||||
|
Copyright 2023 Antifallobst <antifallobst@systemausfall.org>
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
this software and associated documentation files (the “Software”), to deal in
|
||||||
|
the Software without restriction, including without limitation the rights to use,
|
||||||
|
copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
||||||
|
Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
OTHER DEALINGS IN THE SOFTWARE.
|
|
@ -0,0 +1,3 @@
|
||||||
|
# BaseAuth
|
||||||
|
Baseauth is a simple auth server, which is not meant to be usable in production environments.
|
||||||
|
|
|
@ -0,0 +1,51 @@
|
||||||
|
<mxfile host="Electron" modified="2023-08-11T20:31:32.652Z" agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/21.6.5 Chrome/114.0.5735.243 Electron/25.3.1 Safari/537.36" etag="LZHVtxH7pGb43NmuB1ME" version="21.6.5" type="device">
|
||||||
|
<diagram name="Page-1" id="bf9gt89W4ppZuEaMjzIc">
|
||||||
|
<mxGraphModel dx="1194" dy="811" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0">
|
||||||
|
<root>
|
||||||
|
<mxCell id="0" />
|
||||||
|
<mxCell id="1" parent="0" />
|
||||||
|
<mxCell id="AvzBmCR8G-xRIIPoG0sc-1" value="SQLite<br>DB" style="shape=cylinder3;whiteSpace=wrap;html=1;boundedLbl=1;backgroundOutline=1;size=15;fillColor=#008a00;strokeColor=#005700;fontColor=#ffffff;" vertex="1" parent="1">
|
||||||
|
<mxGeometry x="500" y="640" width="60" height="140" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="AvzBmCR8G-xRIIPoG0sc-2" value="Handle Thread" style="swimlane;whiteSpace=wrap;html=1;fillColor=#fa6800;fontColor=#000000;strokeColor=#C73500;" vertex="1" parent="1">
|
||||||
|
<mxGeometry x="300" y="640" width="140" height="140" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="AvzBmCR8G-xRIIPoG0sc-7" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;fillColor=#6a00ff;strokeColor=#3700CC;" edge="1" parent="AvzBmCR8G-xRIIPoG0sc-2" source="AvzBmCR8G-xRIIPoG0sc-3" target="AvzBmCR8G-xRIIPoG0sc-4">
|
||||||
|
<mxGeometry relative="1" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="AvzBmCR8G-xRIIPoG0sc-3" value="Await" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#6a00ff;fontColor=#ffffff;strokeColor=#3700CC;" vertex="1" parent="AvzBmCR8G-xRIIPoG0sc-2">
|
||||||
|
<mxGeometry x="20" y="40" width="100" height="30" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="AvzBmCR8G-xRIIPoG0sc-8" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;fillColor=#6a00ff;strokeColor=#3700CC;" edge="1" parent="AvzBmCR8G-xRIIPoG0sc-2" source="AvzBmCR8G-xRIIPoG0sc-4" target="AvzBmCR8G-xRIIPoG0sc-3">
|
||||||
|
<mxGeometry relative="1" as="geometry">
|
||||||
|
<Array as="points">
|
||||||
|
<mxPoint x="70" y="130" />
|
||||||
|
<mxPoint x="10" y="130" />
|
||||||
|
<mxPoint x="10" y="30" />
|
||||||
|
<mxPoint x="70" y="30" />
|
||||||
|
</Array>
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="AvzBmCR8G-xRIIPoG0sc-4" value="Handle" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#6a00ff;fontColor=#ffffff;strokeColor=#3700CC;" vertex="1" parent="AvzBmCR8G-xRIIPoG0sc-2">
|
||||||
|
<mxGeometry x="20" y="90" width="100" height="30" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="AvzBmCR8G-xRIIPoG0sc-6" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=-0.004;entryY=0.756;entryDx=0;entryDy=0;entryPerimeter=0;startArrow=classic;startFill=1;fillColor=#1ba1e2;strokeColor=#006EAF;" edge="1" parent="1" source="AvzBmCR8G-xRIIPoG0sc-4" target="AvzBmCR8G-xRIIPoG0sc-1">
|
||||||
|
<mxGeometry relative="1" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="AvzBmCR8G-xRIIPoG0sc-10" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=1;entryY=0.5;entryDx=0;entryDy=0;fillColor=#a20025;strokeColor=#6F0000;" edge="1" parent="1" source="AvzBmCR8G-xRIIPoG0sc-9" target="AvzBmCR8G-xRIIPoG0sc-3">
|
||||||
|
<mxGeometry relative="1" as="geometry">
|
||||||
|
<Array as="points">
|
||||||
|
<mxPoint x="470" y="695" />
|
||||||
|
</Array>
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="AvzBmCR8G-xRIIPoG0sc-9" value="Event Channel" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#a20025;fontColor=#ffffff;strokeColor=#6F0000;" vertex="1" parent="1">
|
||||||
|
<mxGeometry x="300" y="530" width="260" height="60" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="AvzBmCR8G-xRIIPoG0sc-11" value="Vertical Container" style="swimlane;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
||||||
|
<mxGeometry x="190" y="280" width="200" height="200" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
</root>
|
||||||
|
</mxGraphModel>
|
||||||
|
</diagram>
|
||||||
|
</mxfile>
|
|
@ -0,0 +1,19 @@
|
||||||
|
use actix_web::{post, App, HttpResponse, HttpServer, Responder};
|
||||||
|
|
||||||
|
#[post("/authenticate")]
|
||||||
|
async fn hello() -> impl Responder {
|
||||||
|
HttpResponse::Ok().body("Hello world!")
|
||||||
|
}
|
||||||
|
|
||||||
|
#[post("/register")]
|
||||||
|
async fn echo(req_body: String) -> impl Responder {
|
||||||
|
HttpResponse::Ok().body(req_body)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[actix_web::main]
|
||||||
|
async fn main() -> std::io::Result<()> {
|
||||||
|
HttpServer::new(|| App::new().service(hello).service(echo))
|
||||||
|
.bind(("127.0.0.1", 8080))?
|
||||||
|
.run()
|
||||||
|
.await
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
use tokio::sync::mpsc;
|
||||||
|
use anyhow::Result;
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub enum RawCall {
|
||||||
|
Register,
|
||||||
|
Authenticate,
|
||||||
|
Delete,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct Call {
|
||||||
|
call: RawCall,
|
||||||
|
tx: mpsc::Sender<Result<()>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn worker(mut rx: mpsc::Receiver<Call>) {
|
||||||
|
loop {
|
||||||
|
let call = rx.recv().await.unwrap();
|
||||||
|
|
||||||
|
println!("Received: {:#?}", call);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn start_worker() -> Result<mpsc::Sender<Call>> {
|
||||||
|
let (tx, rx) = mpsc::channel(128);
|
||||||
|
tokio::task::spawn(worker(rx));
|
||||||
|
|
||||||
|
Ok(tx)
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
mod api;
|
||||||
|
mod call;
|
||||||
|
|
||||||
|
use anyhow::Result;
|
||||||
|
|
||||||
|
#[tokio::main]
|
||||||
|
async fn main() -> Result<()> {
|
||||||
|
println!("Starting BaseAuth server v0.1");
|
||||||
|
let tx = call::start_worker().await?;
|
||||||
|
Ok(())
|
||||||
|
}
|
Loading…
Reference in New Issue