commit 3bf950d61c236e78d0b0d7862e8403a1013bbef6 Author: Techiesplash <94077364+Techiesplash@users.noreply.github.com> Date: Fri Aug 2 23:44:57 2024 -0700 Initial diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..4962f1d --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "accounter" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/README.md b/README.md new file mode 100644 index 0000000..b45d138 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# Accounter + +Attempts to provide an agnostic, no-bullshit framework for accounts and authentication. \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..dd59ab0 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,36 @@ +pub enum AuthError { + InvalidToken +} + +pub struct Permission { + pub namespace: String, + pub name: String, +} + +impl Permission { + fn new(namespace: String, name: String) -> Self { + Self { + namespace, + name + } + } +} + +pub trait AuthUser { + type Id; + fn id(&self) -> Self::UserId; + fn delete(mut self) -> Self::Id; +} + +pub trait AuthSession { + fn user(&self) -> AU; + fn has_permission(&self, permission: &Permission) -> bool; + fn grant_permission(&self, permission: &Permission, state: bool); +} + +pub trait AuthProvider> { + type Token; + fn valid_token(&self, token: Self::Token) -> bool; + fn session_from_token(&self, token: Self::Token) -> Result; + fn session_from_id(id: AU::Id) -> Result; +} \ No newline at end of file diff --git a/tests/demo.rs b/tests/demo.rs new file mode 100644 index 0000000..e69de29