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
56 changes: 27 additions & 29 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,59 +1,57 @@
/target
# ---> Rust
# Ignoring compiled files
/target/
/Cargo.lock

# Generated by Cargo command-line tools
# Rust build artifacts
**/*.rs.bk
*.rs.bk

# Ignoring Rust artifacts
*.rlib
*.d
*.o
*.so
*.a

# Coverage files
# Coverage and reports
/coverage/
*.profraw
*.profdata
lcov.info

# ---> GitHub Actions
# GitHub Actions runner files
.github/workflows/*.log
.github/actions/**/*.log
.github/workflows/*.bak

# Ignore secret files
.github/workflows/secrets.env
# Local environment files
.env
*.env
.pem
.env.*
!.env.example

# ---> Logs
logs
# Logs
logs/
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# ---> OS Generated
.DS_Store
Thumbs.db

# ---> Editor-specific
# Ignore files generated by common editors
# Editor and IDE files
.vscode/
.idea/
*.sublime-project
*.sublime-workspace

# ---> Temporary Files
# OS-generated files
.DS_Store
Thumbs.db

# Temporary files
*.tmp
*.tmp.*
*.swp
*.bak
*.tmp.*
*.old
*.orig

# Local databases and dumps
*.db
*.sqlite
*.sqlite3
*.sqlx

# GitHub Actions local noise
.github/workflows/*.log
.github/actions/**/*.log
.github/workflows/*.bak
.github/workflows/secrets.env
27 changes: 16 additions & 11 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@ cargo build
```

### Running the Server
Once you've built the project, you can start the server by running:
The repository now includes a runnable Actix binary for local development. It starts a mock-backed authorization server on `127.0.0.1:8080`:

```bash
cargo run
```

This development server wires the in-memory token store, mock authenticator, mock session manager, and default OIDC flow configuration. It is intended for local testing and examples, not production deployment.

### 🔧 Running Tests

RustifyAuth comes with a comprehensive suite of unit and integration tests. To execute the tests, use:
Expand All @@ -44,15 +46,17 @@ cargo test
```

### Notes
For testing purposes, the repository includes client_cert.pem, client_key.pem, custom_cert.pem, and custom_key.pem. These files are used for the Dynamic Client Registration as per RFC 7591 and are provided for local development and testing only.
For testing purposes, the repository includes `client_cert.pem`, `client_key.pem`, `custom_cert.pem`, and `custom_key.pem`. These files are used for Dynamic Client Registration per RFC 7591 and are provided for local development and testing only.

Note: The keys and certificates in this repository are not intended for production use. Please generate your own keys and certificates if you intend to use this in a live environment.

Public and Private Key Files
client_cert.pem: The client certificate used during the registration process.
client_key.pem: The private key corresponding to the client certificate.
custom_cert.pem: A custom certificate used for encrypting data.
custom_key.pem: The private key corresponding to the custom certificate.
Public and private key files:

- `client_cert.pem`: client certificate used during registration
- `client_key.pem`: private key for `client_cert.pem`
- `custom_cert.pem`: custom certificate used for encryption tests
- `custom_key.pem`: private key for `custom_cert.pem`

These keys and certificates are self-signed and intended solely for testing.

The custom_cert.srl file is a serial number file used by OpenSSL when generating certificates. It keeps track of the serial numbers of the certificates that have been signed by the Certificate Authority (CA).
Expand Down Expand Up @@ -90,10 +94,11 @@ openssl x509 -req -days 365 -in custom.csr -signkey custom_key.pem -out custom_c
### Using the Keys for Testing
These keys are used in the Dynamic Client Registration process for securing communications and authenticating clients. In your local testing environment, you can simply point to these keys in the relevant configuration files or environment variables.

### Example:
### Example

- `client_key.pem` and `client_cert.pem` are used during client registration.
- `custom_key.pem` and `custom_cert.pem` can be used for other secure communication scenarios.

client_key.pem and client_cert.pem will be used during client registration.
custom_key.pem and custom_cert.pem can be used for other secure communication scenarios.
Feel free to generate your own certificates if you prefer not to use the provided ones for testing.

Security Notice
Expand Down Expand Up @@ -128,4 +133,4 @@ For any questions or assistance, feel free to reach out:
- **Email**: [Mehrnoush.vaseghi@gmail.com](mailto:Mehrnoush.vaseghi@gmail.com)
- **GitHub Issues**: [Open an issue](https://github.com/Mehrn0ush/RustifyAuth/issues) for questions, feature requests, or feedback.

Thank you for checking out **RustifyAuth**! We look forward to your contributions and feedback.
Thank you for checking out **RustifyAuth**! We look forward to your contributions and feedback.
20 changes: 20 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,23 @@ impl OAuthConfig {
}
}
}

// OIDC configurable
#[derive(Debug, Clone)]
pub struct OidcConfig {
pub authorization_code_flow: bool,
pub implicit_flow: bool,
pub hybrid_flow: bool,
pub ciba_flow: bool,
}

impl Default for OidcConfig {
fn default() -> Self {
OidcConfig {
authorization_code_flow: true, // Enabled by default
implicit_flow: false,
hybrid_flow: false,
ciba_flow: false,
}
}
}
4 changes: 2 additions & 2 deletions src/core/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ impl TokenStore for RedisTokenStore {
let result: Option<String> = conn.get(token).map_err(|_| TokenError::InternalError)?;

if result.is_some() {
conn.del(token).map_err(|_| TokenError::InternalError)?;
let _: usize = conn.del(token).map_err(|_| TokenError::InternalError)?;
println!("Revoked refresh token in Redis: {}", token);
Ok(())
} else {
Expand All @@ -233,7 +233,7 @@ impl RedisTokenStore {
poisoned.into_inner()
});

conn.set_ex(token.clone(), "revoked", ttl).map_err(|e| {
let _: () = conn.set_ex(token.clone(), "revoked", ttl).map_err(|e| {
eprintln!("Failed to store revoked token {} in Redis: {:?}", token, e);
TokenError::InternalError
})?;
Expand Down
Loading
Loading