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
95 changes: 86 additions & 9 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,13 @@ dioxus-html = "0.7.0-rc.3"
dioxus-server = "0.7.0-rc.3"
futures = "0.3.31"
http = "1.2.0"
jsonwebtoken = "10.3.0"
leptos = "0.8.3"
leptos_actix = "0.8.3"
leptos_axum = "0.8.3"
leptos_meta = "0.8.3"
leptos_router = "0.8.3"
rand = "0.10.0"
regex = "1.12.2"
sea-orm = "1.1.2"
sea-orm-migration = "1.1.2"
Expand Down
3 changes: 2 additions & 1 deletion examples/axum/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ version.workspace = true
axum.workspace = true
shield.workspace = true
shield-axum = { workspace = true, features = ["utoipa"] }
shield-memory = { workspace = true, features = ["method-oidc"] }
shield-email = { workspace = true, features = ["sender-tracing"] }
shield-memory = { workspace = true, features = ["method-email", "method-oidc"] }
shield-oidc = { workspace = true, features = ["native-tls"] }
time = "0.3.47"
tokio = { workspace = true, features = ["macros", "rt-multi-thread"] }
Expand Down
54 changes: 32 additions & 22 deletions examples/axum/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use std::sync::Arc;
use axum::{Json, middleware::from_fn, routing::get};
use shield::{Shield, ShieldOptions};
use shield_axum::{AuthRoutes, ShieldLayer, auth_required};
use shield_email::{EmailMethod, EmailOptions, TracingSender};
use shield_memory::{MemoryStorage, User};
use shield_oidc::{Keycloak, OidcMethod, OidcOptions};
use time::Duration;
Expand Down Expand Up @@ -34,28 +35,37 @@ async fn main() {
let storage = MemoryStorage::new();
let shield = Shield::new(
storage.clone(),
vec![Arc::new(
OidcMethod::new(storage)
.with_providers([Keycloak::builder(
"keycloak",
"http://localhost:18080/realms/Shield",
"client1",
)
.client_secret("xcpQsaGbRILTljPtX4npjmYMBjKrariJ")
.redirect_url(format!(
"http://localhost:{}/api/auth/oidc/sign-in-callback/keycloak",
addr.port()
))
.build()])
.with_options(
OidcOptions::builder()
.redirect_origins([
Url::parse(&format!("http://localhost:{}", addr.port())).unwrap(),
Url::parse("http://localhost:5173").unwrap(),
])
.build(),
),
)],
vec![
Arc::new(EmailMethod::new(
EmailOptions::builder()
.secret("secret")
.sender(TracingSender)
.build(),
storage.clone(),
)),
Arc::new(
OidcMethod::new(storage)
.with_providers([Keycloak::builder(
"keycloak",
"http://localhost:18080/realms/Shield",
"client1",
)
.client_secret("xcpQsaGbRILTljPtX4npjmYMBjKrariJ")
.redirect_url(format!(
"http://localhost:{}/api/auth/oidc/sign-in-callback/keycloak",
addr.port()
))
.build()])
.with_options(
OidcOptions::builder()
.redirect_origins([
Url::parse(&format!("http://localhost:{}", addr.port())).unwrap(),
Url::parse("http://localhost:5173").unwrap(),
])
.build(),
),
),
],
ShieldOptions::default(),
);
let shield_layer = ShieldLayer::new(shield.clone());
Expand Down
5 changes: 5 additions & 0 deletions examples/dioxus-axum/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ version.workspace = true
server = [
"dep:axum",
"dep:shield-dioxus-axum",
"dep:shield-email",
"dep:shield-memory",
"dep:shield-oidc",
"dep:tokio",
"dep:tower-sessions",
"dioxus/server",
"shield-dioxus/server",
"shield-memory/method-email",
"shield-memory/method-oidc",
]
web = ["dioxus/web"]
Expand All @@ -33,6 +35,9 @@ shield.workspace = true
shield-bootstrap = { workspace = true, features = ["dioxus"] }
shield-dioxus.workspace = true
shield-dioxus-axum = { workspace = true, optional = true }
shield-email = { workspace = true, features = [
"sender-tracing",
], optional = true }
shield-memory = { workspace = true, optional = true }
shield-oidc = { workspace = true, features = ["native-tls"], optional = true }
tokio = { workspace = true, features = [
Expand Down
Loading
Loading