Skip to content

Commit 7d4550e

Browse files
feat(workos): add index redirect and authorization URL redirect (#164)
1 parent 52f5d72 commit 7d4550e

33 files changed

Lines changed: 418 additions & 120 deletions

File tree

Cargo.lock

Lines changed: 17 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/axum/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Shield Axum Example
2+
3+
1. Start the server:
4+
5+
```shell
6+
cargo run
7+
```
8+
9+
2. Go to http://localhost:8080.

examples/axum/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ async fn main() {
2323
.init();
2424

2525
// Configuration
26-
let addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 3000);
26+
let addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8080);
2727

2828
// Initialize sessions
2929
let session_store = MemoryStore::default();

examples/dioxus-axum/.env.example

Lines changed: 0 additions & 2 deletions
This file was deleted.

examples/dioxus-axum/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ server = [
1818
"dep:shield-dioxus-axum",
1919
"dep:shield-memory",
2020
"dep:shield-oidc",
21-
"dep:shield-workos",
2221
"dep:tokio",
2322
"dep:tower-sessions",
2423
"dioxus/server",
@@ -36,7 +35,6 @@ shield-dioxus.workspace = true
3635
shield-dioxus-axum = { workspace = true, optional = true }
3736
shield-memory = { workspace = true, optional = true }
3837
shield-oidc = { workspace = true, features = ["native-tls"], optional = true }
39-
shield-workos = { workspace = true, optional = true }
4038
tokio = { workspace = true, features = ["rt-multi-thread"], optional = true }
4139
tower-sessions = { workspace = true, optional = true }
4240
tracing.workspace = true

examples/dioxus-axum/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Shield Dioxus Axum Example
2+
3+
1. Install binaries:
4+
5+
```shell
6+
cargo install --locked dioxus-cli
7+
```
8+
9+
2. Start the development server:
10+
11+
```shell
12+
dx serve --platform web
13+
```
14+
15+
3. Go to http://localhost:8080.

examples/dioxus-axum/src/main.rs

Lines changed: 15 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ async fn main() {
2727
use shield_dioxus_axum::{AxumDioxusIntegration, ShieldLayer};
2828
use shield_memory::{MemoryStorage, User};
2929
use shield_oidc::{Keycloak, OidcMethod};
30-
use shield_workos::{WorkosMethod, WorkosOauthProvider, WorkosOptions};
3130
use tokio::net::TcpListener;
3231
use tower_sessions::{Expiry, MemoryStore, SessionManagerLayer, cookie::time::Duration};
3332
use tracing::{Level, info};
@@ -46,39 +45,21 @@ async fn main() {
4645
let storage = MemoryStorage::new();
4746
let shield = Shield::new(
4847
storage.clone(),
49-
[
50-
Some(Arc::new(
51-
OidcMethod::new(storage).with_providers([Keycloak::builder(
52-
"keycloak",
53-
"http://localhost:18080/realms/Shield",
54-
"client1",
55-
)
56-
.client_secret("xcpQsaGbRILTljPtX4npjmYMBjKrariJ")
57-
.redirect_url(format!(
58-
"http://localhost:{}/api/auth/oidc/sign-in-callback/keycloak",
59-
dioxus::cli_config::devserver_raw_addr()
60-
.map(|addr| addr.port())
61-
.unwrap_or_else(|| addr.port())
62-
))
63-
.build()]),
64-
) as Arc<dyn ErasedMethod>),
65-
env::var("WORKOS_API_KEY").ok().map(|api_key| {
66-
Arc::new(
67-
WorkosMethod::from_api_key(&api_key).with_options(
68-
WorkosOptions::builder()
69-
.oauth_providers(vec![
70-
WorkosOauthProvider::AppleOAuth,
71-
WorkosOauthProvider::GoogleOAuth,
72-
WorkosOauthProvider::MicrosoftOAuth,
73-
])
74-
.build(),
75-
),
76-
) as Arc<dyn ErasedMethod>
77-
}),
78-
]
79-
.into_iter()
80-
.flatten()
81-
.collect(),
48+
vec![
49+
OidcMethod::new(storage).with_providers([Keycloak::builder(
50+
"keycloak",
51+
"http://localhost:18080/realms/Shield",
52+
"client1",
53+
)
54+
.client_secret("xcpQsaGbRILTljPtX4npjmYMBjKrariJ")
55+
.redirect_url(format!(
56+
"http://localhost:{}/api/auth/oidc/sign-in-callback/keycloak",
57+
dioxus::cli_config::devserver_raw_addr()
58+
.map(|addr| addr.port())
59+
.unwrap_or_else(|| addr.port())
60+
))
61+
.build()]),
62+
],
8263
ShieldOptions::default(),
8364
);
8465
let shield_layer = ShieldLayer::new(shield.clone());

examples/leptos-actix/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Shield Leptos Actix Example
2+
3+
1. Install binaries:
4+
5+
```shell
6+
cargo install --locked cargo-leptos
7+
```
8+
9+
2. Start the development server:
10+
11+
```shell
12+
cargo letpos watch
13+
```
14+
15+
3. Go to http://localhost:8080.

examples/leptos-axum/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Shield Leptos Axum Example
2+
3+
1. Install binaries:
4+
5+
```shell
6+
cargo install --locked cargo-leptos
7+
```
8+
9+
2. Start the development server:
10+
11+
```shell
12+
cargo letpos watch
13+
```
14+
15+
3. Go to http://localhost:8080.

examples/workos/.env.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
WORKOS_API_KEY = change
2+
WORKOS_CLIENT_ID = change

0 commit comments

Comments
 (0)