Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/denver-code/auth-extension-sqlite
Simple CoreX extension for Authorization with SQLite as a database
https://github.com/denver-code/auth-extension-sqlite
Last synced: 4 days ago
JSON representation
Simple CoreX extension for Authorization with SQLite as a database
- Host: GitHub
- URL: https://github.com/denver-code/auth-extension-sqlite
- Owner: denver-code
- Created: 2025-01-30T23:28:07.000Z (16 days ago)
- Default Branch: main
- Last Pushed: 2025-01-30T23:40:31.000Z (16 days ago)
- Last Synced: 2025-01-31T00:24:52.577Z (16 days ago)
- Language: Rust
- Homepage:
- Size: 0 Bytes
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Auth Extension for CoreX-API with SQLite
## Usage
Add dependency to your `Cargo.toml` file
```toml
auth-extension-sqlite = { git = "https://github.com/denver-code/auth-extension-sqlite" }
```Create a new instance of the extension:
```rust
let auth_extension = create_auth_extension()
.await
.expect("Failed to create auth extension");
```
And then register it with the CoreX instance:
```rust
core.register_extension(auth_extension);
```This method slightly differs from the other extensions as it requires an async function to create the extension at first and then register it with the CoreX instance.
Full example:
```rust
use auth_extension_sqlite::create_auth_extension;
use corex_api::CoreX;#[tokio::main]
async fn main() {
let host = "0.0.0.0".to_string();
let port = 3000;
let mut core = CoreX::new(host, port);let auth_extension = create_auth_extension()
.await
.expect("Failed to create auth extension");core.register_extension(auth_extension);
core.run().await;
}```
## API
The extension provides the following API:
- POST `/register` - Register a new user
```json
{
"username": "username",
"password": "password"
}
```
- POST `/login` - Login a user
```json
{
"username": "username",
"password": "password"
}
```