Block pages indexing
This commit is contained in:
		@@ -28,7 +28,7 @@ Features :
 | 
				
			|||||||
  * [x] TOTP (authenticator app)
 | 
					  * [x] TOTP (authenticator app)
 | 
				
			||||||
  * [x] Using a security key (Webauthn)
 | 
					  * [x] Using a security key (Webauthn)
 | 
				
			||||||
* [ ] Fully responsive webui
 | 
					* [ ] Fully responsive webui
 | 
				
			||||||
* [ ] `robots.txt` file to prevent indexing
 | 
					* [x] `robots.txt` prevents indexing
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## Compiling
 | 
					## Compiling
 | 
				
			||||||
You will need the Rust toolchain to compile this project. To build it for production, just run:
 | 
					You will need the Rust toolchain to compile this project. To build it for production, just run:
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										2
									
								
								assets/robots.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								assets/robots.txt
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,2 @@
 | 
				
			|||||||
 | 
					User-agent: *
 | 
				
			||||||
 | 
					Disallow: /
 | 
				
			||||||
@@ -1,11 +1,17 @@
 | 
				
			|||||||
use std::path::Path;
 | 
					use std::path::Path;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use actix_web::{web, HttpResponse};
 | 
					use actix_web::{HttpResponse, web};
 | 
				
			||||||
use include_dir::{include_dir, Dir};
 | 
					use include_dir::{Dir, include_dir};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/// Assets directory
 | 
					/// Assets directory
 | 
				
			||||||
static ASSETS_DIR: Dir = include_dir!("$CARGO_MANIFEST_DIR/assets");
 | 
					static ASSETS_DIR: Dir = include_dir!("$CARGO_MANIFEST_DIR/assets");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					pub async fn robots_txt() -> HttpResponse {
 | 
				
			||||||
 | 
					    HttpResponse::Ok()
 | 
				
			||||||
 | 
					        .content_type("text/plain")
 | 
				
			||||||
 | 
					        .body(include_str!("../../assets/robots.txt"))
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
pub async fn assets_route(path: web::Path<String>) -> HttpResponse {
 | 
					pub async fn assets_route(path: web::Path<String>) -> HttpResponse {
 | 
				
			||||||
    let path: &Path = path.as_ref().as_ref();
 | 
					    let path: &Path = path.as_ref().as_ref();
 | 
				
			||||||
    match ASSETS_DIR.get_file(path) {
 | 
					    match ASSETS_DIR.get_file(path) {
 | 
				
			||||||
@@ -17,4 +23,4 @@ pub async fn assets_route(path: web::Path<String>) -> HttpResponse {
 | 
				
			|||||||
                .body(file.contents())
 | 
					                .body(file.contents())
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -104,6 +104,7 @@ async fn main() -> std::io::Result<()> {
 | 
				
			|||||||
            // main route
 | 
					            // main route
 | 
				
			||||||
            .route("/", web::get()
 | 
					            .route("/", web::get()
 | 
				
			||||||
                .to(|| async { HttpResponse::Found().append_header(("Location", "/settings")).finish() }))
 | 
					                .to(|| async { HttpResponse::Found().append_header(("Location", "/settings")).finish() }))
 | 
				
			||||||
 | 
					            .route("/robots.txt", web::get().to(assets_controller::robots_txt))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // health route
 | 
					            // health route
 | 
				
			||||||
            .service(health)
 | 
					            .service(health)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4,6 +4,10 @@
 | 
				
			|||||||
    <meta charset="utf-8">
 | 
					    <meta charset="utf-8">
 | 
				
			||||||
    <meta name="viewport" content="width=device-width, initial-scale=1">
 | 
					    <meta name="viewport" content="width=device-width, initial-scale=1">
 | 
				
			||||||
    <meta name="description" content="Auth service">
 | 
					    <meta name="description" content="Auth service">
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <!-- No indexing -->
 | 
				
			||||||
 | 
					    <meta name="robots" content="noindex, nofollow">
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <title>{{ _p.app_name }} - {{ _p.page_title }}</title>
 | 
					    <title>{{ _p.app_name }} - {{ _p.page_title }}</title>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <!-- Bootstrap core CSS -->
 | 
					    <!-- Bootstrap core CSS -->
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user