oauth-provider-rs

Crates.iooauth-provider-rs
lib.rsoauth-provider-rs
version0.1.0-alpha.7
created_at2025-07-09 17:19:25.936789+00
updated_at2025-07-12 01:17:30.644841+00
descriptionA Rust implementation of an OAuth 2.0 provider with DynamoDB storage support
homepagehttps://github.com/akihito/oauth-mcp-server
repositoryhttps://github.com/akihito/oauth-mcp-server
max_upload_size
id1745196
size571,454
4kk11 (4kk11)

documentation

https://docs.rs/oauth-provider-rs

README

OAuth Provider RS

Crates.io Documentation License: MIT

A production-ready Rust implementation of an OAuth 2.0 provider with multiple storage backends.

Features

  • 🔐 OAuth 2.0 Authorization Code Flow with PKCE - Secure authorization flow
  • 🗄️ Multiple Storage Backends - DynamoDB, In-Memory, and BTreeMap storage
  • 🔧 Client Management - Registration, validation, and lifecycle management
  • 🎫 Token Management - JWT-based tokens with configurable TTL
  • 🚀 Axum Integration - Ready-to-use HTTP handlers and middleware
  • 📊 Metadata Endpoint - OpenID Connect Discovery support
  • 🔒 PKCE Support - Enhanced security for public clients

Installation

Add this to your Cargo.toml:

[dependencies]
oauth-provider-rs = "0.1.0-alpha.1"

Quick Start

Basic Usage with In-Memory Storage

use oauth_provider_rs::storage::{DefaultOAuthStorageFactory, OAuthStorageFactory};
use std::collections::HashMap;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let factory = DefaultOAuthStorageFactory;
    let mut config = HashMap::new();
    config.insert("storage_type".to_string(), "memory".to_string());
    
    let storage = factory.create_storage(&config).await?;
    
    // Use the storage for OAuth operations
    Ok(())
}

DynamoDB Storage

For production use with DynamoDB:

use oauth_provider_rs::storage::{DefaultOAuthStorageFactory, OAuthStorageFactory};
use std::collections::HashMap;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let factory = DefaultOAuthStorageFactory;
    let mut config = HashMap::new();
    config.insert("storage_type".to_string(), "dynamodb".to_string());
    config.insert("table_name".to_string(), "oauth-storage".to_string());
    
    let storage = factory.create_storage(&config).await?;
    Ok(())
}

HTTP Integration with Axum

use oauth_provider_rs::http_integration::OAuthRouterExt;
use axum::Router;

let app = Router::new()
    .oauth_routes(storage);

Storage Backends

In-Memory Storage

Perfect for development and testing:

  • Fast and simple
  • No external dependencies
  • Data is lost on restart

DynamoDB Storage

Production-ready with AWS DynamoDB:

  • Persistent storage
  • TTL support for automatic cleanup
  • Scalable and reliable

BTreeMap Storage

File-based storage for small applications:

  • Persistent between restarts
  • Single-file storage
  • Good for small-scale deployments

Testing

# Run unit tests
cargo test

# Run with DynamoDB integration tests (requires AWS credentials)
cargo test --features integration-tests

License

This project is licensed under the MIT License - see the LICENSE file for details.

Commit count: 0

cargo fmt