Skip to content

Commit afb8a90

Browse files
authored
chore: add oauth2 support (#130)
1.add oauth2 server and client example 2.add oauth2 impl in sse 3.add auth doc Signed-off-by: jokemanfire <[email protected]>
1 parent b1542a6 commit afb8a90

15 files changed

+2480
-7
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,10 @@ For many cases you need to manage several service in a collection, you can call
179179
let service = service.into_dyn();
180180
```
181181

182+
### OAuth Support
183+
184+
See [docs/OAUTH_SUPPORT.md](docs/OAUTH_SUPPORT.md) for details.
185+
182186
### Examples
183187

184188
See [examples](examples/README.md)

crates/rmcp/Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ tracing = { version = "0.1" }
2323
tokio-util = { version = "0.7" }
2424
pin-project-lite = "0.2"
2525
paste = { version = "1", optional = true }
26+
27+
# oauth2 support
28+
oauth2 = { version = "5.0", optional = true }
29+
2630
# for auto generate schema
2731
schemars = { version = "0.8", optional = true }
2832

@@ -70,6 +74,8 @@ transport-sse-server = [
7074
]
7175
# transport-ws = ["transport-io", "dep:tokio-tungstenite"]
7276
tower = ["dep:tower-service"]
77+
auth = ["dep:oauth2", "dep:reqwest", "dep:url"]
78+
7379
[dev-dependencies]
7480
tokio = { version = "1", features = ["full"] }
7581
schemars = { version = "0.8" }

crates/rmcp/src/transport.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ pub mod sse;
5656
#[cfg(feature = "transport-sse")]
5757
pub use sse::SseTransport;
5858

59+
#[cfg(all(feature = "transport-sse", feature = "auth"))]
60+
pub mod sse_auth;
61+
#[cfg(all(feature = "transport-sse", feature = "auth"))]
62+
pub use sse_auth::{AuthorizedSseClient, create_authorized_transport};
63+
5964
// #[cfg(feature = "tower")]
6065
// pub mod tower;
6166

@@ -64,6 +69,11 @@ pub mod sse_server;
6469
#[cfg(feature = "transport-sse-server")]
6570
pub use sse_server::SseServer;
6671

72+
#[cfg(feature = "auth")]
73+
pub mod auth;
74+
#[cfg(feature = "auth")]
75+
pub use auth::{AuthError, AuthorizationManager, AuthorizationSession, AuthorizedHttpClient};
76+
6777
// #[cfg(feature = "transport-ws")]
6878
// pub mod ws;
6979

0 commit comments

Comments
 (0)