Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 115 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ bon = "3.3.2"
chrono = "0.4.39"
console_error_panic_hook = "0.1.2"
dioxus = "0.7.0-rc.0"
dioxus-server = { version = "0.7.0-rc.0" }
dioxus-html = "0.7.0-rc.0"
dioxus-server = "0.7.0-rc.0"
futures = "0.3.31"
http = "1.2.0"
leptos = "0.8.3"
Expand Down Expand Up @@ -53,6 +54,7 @@ shield-sea-orm = { path = "./packages/storage/shield-sea-orm", version = "0.0.4"
shield-sqlx = { path = "./packages/storage/shield-sqlx", version = "0.0.4" }
shield-tower = { path = "./packages/integrations/shield-tower", version = "0.0.4" }
shield-webauthn = { path = "./packages/methods/shield-webauthn", version = "0.0.4" }
shield-workos = { path = "./packages/methods/shield-workos", version = "0.0.4" }
thiserror = "2.0.7"
tokio = "1.42.0"
tower-layer = "0.3.3"
Expand Down
20 changes: 13 additions & 7 deletions packages/core/shield/src/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,20 @@ use crate::{
pub struct ActionForms {
pub id: String,
pub name: String,
pub forms: Vec<ActionProviderForm>,
pub method_forms: Vec<ActionMethodForm>,
}

// TODO: Think of a better name.
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct ActionMethodForm {
pub id: String,
pub provider_forms: Vec<ActionProviderForm>,
}

// TODO: Think of a better name.
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct ActionProviderForm {
pub method_id: String,
pub provider_id: Option<String>,
pub id: Option<String>,
pub form: Form,
}

Expand All @@ -34,7 +40,7 @@ pub trait Action<P: Provider>: ErasedAction + Send + Sync {
Ok(true)
}

fn form(&self, provider: P) -> Form;
fn forms(&self, provider: P) -> Vec<Form>;

async fn call(
&self,
Expand All @@ -56,7 +62,7 @@ pub trait ErasedAction: Send + Sync {
session: Session,
) -> Result<bool, ShieldError>;

fn erased_form(&self, provider: Box<dyn Any + Send + Sync>) -> Form;
fn erased_forms(&self, provider: Box<dyn Any + Send + Sync>) -> Vec<Form>;

async fn erased_call(
&self,
Expand All @@ -83,8 +89,8 @@ macro_rules! erased_action {
self.condition(provider.downcast_ref().expect("TODO"), session)
}

fn erased_form(&self, provider: Box<dyn std::any::Any + Send + Sync>) -> $crate::Form {
self.form(*provider.downcast().expect("TODO"))
fn erased_forms(&self, provider: Box<dyn std::any::Any + Send + Sync>) -> Vec<$crate::Form> {
self.forms(*provider.downcast().expect("TODO"))
}

async fn erased_call(
Expand Down
2 changes: 2 additions & 0 deletions packages/core/shield/src/actions.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
mod sign_in;
mod sign_in_callback;
mod sign_out;
mod sign_up;

pub use sign_in::*;
pub use sign_in_callback::*;
pub use sign_out::*;
pub use sign_up::*;
6 changes: 3 additions & 3 deletions packages/core/shield/src/actions/sign_out.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ impl SignOutAction {
}))
}

pub fn form<P: Provider>(_provider: P) -> Form {
Form {
pub fn forms<P: Provider>(_provider: P) -> Vec<Form> {
vec![Form {
inputs: vec![Input {
name: "submit".to_owned(),
label: None,
r#type: InputType::Submit(InputTypeSubmit {}),
value: Some(Self::name()),
}],
}
}]
}
}
14 changes: 14 additions & 0 deletions packages/core/shield/src/actions/sign_up.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const ACTION_ID: &str = "sign-up";
const ACTION_NAME: &str = "Sign up";

pub struct SignUpAction;

impl SignUpAction {
pub fn id() -> String {
ACTION_ID.to_owned()
}

pub fn name() -> String {
ACTION_NAME.to_owned()
}
}
Loading