-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit a021bc8
Showing
6 changed files
with
3,644 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: Test and Publish | ||
on: | ||
push: | ||
branches: | ||
- master | ||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: stable | ||
override: true | ||
- uses: actions-rs/cargo@v1 | ||
with: | ||
command: test | ||
all-features: true | ||
args: --verbose | ||
publish: | ||
needs: test | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: stable | ||
override: true | ||
- uses: actions-rs/cargo@v1 | ||
with: | ||
command: publish | ||
token: ${{ secrets.CRATES_IO_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/target | ||
/Cargo.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
[package] | ||
name = "ntex-helmet" | ||
version = "0.1.0" | ||
edition = "2021" | ||
authors = ["Daniel Kovacs <[email protected]>"] | ||
description = "HTTP security headers middleware for ntex-web" | ||
readme = "README.md" | ||
license = "MIT" | ||
homepage = "https://github.com/danielkov/ntex-helmet" | ||
repository = "https://github.com/danielkov/ntex-helmet" | ||
keywords = ["ntex", "ntex-web", "helmet", "security", "middleware"] | ||
categories = ["web-programming", "http", "middleware"] | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
ntex = "0.7" | ||
|
||
[dev-dependencies] | ||
ntex = { version = "0.7", features=["tokio"] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# `ntex-helmet` - Security Middleware for `ntex` web framework | ||
|
||
[![crate](https://img.shields.io/crates/v/ntex-helmet.svg)](https://crates.io/crates/ntex-helmet) | ||
[![docs](https://docs.rs/ntex-helmet/badge.svg)](https://docs.rs/ntex-helmet) | ||
|
||
`ntex-helmet` is a security middleware for the `ntex` web framework. It's based on the [helmet](https://helmetjs.github.io/) middleware for Node.js. | ||
|
||
It works by setting HTTP headers for you. These headers can help protect your app from some well-known web vulnerabilities: | ||
|
||
- [Cross-Origin-Embedder-Policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cross-Origin-Embedder-Policy) | ||
- [Cross-Origin-Opener-Policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cross-Origin-Opener-Policy) | ||
- [Cross-Origin-Resource-Policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cross-Origin-Resource-Policy) | ||
- [Origin-Agent-Cluster](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Origin-Agent-Cluster) | ||
- [Referrer-Policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Referrer-Policy) | ||
- [Strict-Transport-Security](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Strict-Transport-Security) | ||
- [X-Content-Type-Options](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Content-Type-Options) | ||
- [X-DNS-Prefetch-Control](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-DNS-Prefetch-Control) | ||
- [X-Download-Options](<https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/compatibility/ms537628(v=vs.85)?redirectedfrom=MSDN>) | ||
- [X-Frame-Options](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options) | ||
- [X-Permitted-Cross-Domain-Policies](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Permitted-Cross-Domain-Policies) | ||
- [X-XSS-Protection](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-XSS-Protection) | ||
- [X-Powered-By](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Powered-By) | ||
- [Content-Security-Policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy) | ||
|
||
## Usage | ||
|
||
Add this to your `Cargo.toml`: | ||
|
||
```toml | ||
[dependencies] | ||
ntex-helmet = "0.1" | ||
``` | ||
|
||
## Example | ||
|
||
```rust | ||
use ntex::web::{self, App, HttpResponse}; | ||
use ntex_helmet::Helmet; | ||
|
||
#[ntex::main] | ||
fn main() { | ||
let app = App::new() | ||
.wrap(Helmet::default()) | ||
.service(web::resource("/").to(|| HttpResponse::Ok())); | ||
|
||
// ... | ||
} | ||
``` | ||
|
||
## License | ||
|
||
This project is licensed under the [MIT license](LICENSE). |
Oops, something went wrong.