Skip to content

Authenticate jsha to use Google Search Console #1768

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
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
4 changes: 4 additions & 0 deletions src/web/routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ pub(super) fn build_routes() -> Routes {
// https://developers.google.com/search/reference/robots_txt#handling-http-result-codes
// https://support.google.com/webmasters/answer/183668?hl=en
routes.static_resource("/robots.txt", PermanentRedirect("/-/static/robots.txt"));
routes.static_resource(
"/googleb54494ba4d52c200.html",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where does this string come from? I clicked on the "verification flow" link in the webmaster docs, but didn't see anything that looked relevant.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you visit https://search.google.com/search-console/welcome from a logged-in Google Account, and click the "URL Prefix" box, enter "https://docs.rs", and hit "continue," you'll get a similar string.

super::sitemap::google_search_console_handler,
);
routes.static_resource("/favicon.ico", PermanentRedirect("/-/static/favicon.ico"));
routes.internal_page("/sitemap.xml", super::sitemap::sitemapindex_handler);
routes.internal_page(
Expand Down
10 changes: 10 additions & 0 deletions src/web/sitemap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,16 @@ pub fn about_handler(req: &mut Request) -> IronResult<Response> {
.into_response(req)
}

// This authenticates @jsha (https://github.com/jsha) to use the Google Search Console
// https://support.google.com/webmasters/answer/9128668?visit_id=637926083810327397-791277710&rd=2
// for docs.rs. Removing this handler will de-authenticate. Additional handlers can be
// added for additional users.
pub fn google_search_console_handler(_req: &mut Request) -> IronResult<Response> {
Ok(Response::with(
"google-site-verification: googleb54494ba4d52c200.html".to_string(),
))
}

#[cfg(test)]
mod tests {
use crate::test::{assert_success, wrapper};
Expand Down