rename guard -> mcaptcha

This commit is contained in:
realaravinth 2021-06-01 17:33:47 +05:30
parent ba39483635
commit 9e70f8f756
No known key found for this signature in database
GPG key ID: AD9F0F08E855ED88
19 changed files with 154 additions and 151 deletions

View file

@ -89,7 +89,7 @@ jobs:
DATABASE_URL: postgres://postgres:password@localhost:5432/postgres
- name: generate documentation
if: matrix.version == '1.51.0' && (github.repository == 'mCaptcha/guard')
if: matrix.version == '1.51.0' && (github.repository == 'mCaptcha/mCaptcha')
uses: actions-rs/cargo@v1
with:
command: doc
@ -100,7 +100,7 @@ jobs:
OPEN_API_DOCS: 8e77345f1597e40c2e266cb4e6dee74888918a61
- name: Deploy to GitHub Pages
if: matrix.version == '1.51.0' && (github.repository == 'mCaptcha/guard')
if: matrix.version == '1.51.0' && (github.repository == 'mCaptcha/mCaptcha')
uses: JamesIves/github-pages-deploy-action@3.7.1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

137
Cargo.lock generated
View file

@ -439,7 +439,7 @@ dependencies = [
[[package]]
name = "argon2-creds"
version = "0.2.1"
source = "git+https://github.com/realaravinth/argon2-creds#11b490b78c1b4693607b47124e1c0e4718f290f4"
source = "git+https://github.com/realaravinth/argon2-creds#bc5949a86cdc7e57a54deb08ed65bae978163f71"
dependencies = [
"ammonia",
"derive_builder 0.10.2",
@ -618,9 +618,9 @@ checksum = "b4ae4235e6dac0694637c763029ecea1a2ec9e4e06ec2729bd21ba4d9c863eb7"
[[package]]
name = "bumpalo"
version = "3.6.1"
version = "3.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "63396b8a4b9de3f4fdfb320ab6080762242f66a8ef174c49d8e19b674db4cdbe"
checksum = "9c59e7af012c713f529e7a3ee57ce9b31ddd858d4b512923602f74608b009631"
[[package]]
name = "byteorder"
@ -820,17 +820,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06ed27e177f16d65f0f0c22a213e17c696ace5dd64b14258b52f9417ccb52db4"
dependencies = [
"cfg-if 1.0.0",
"crossbeam-utils 0.8.4",
"crossbeam-utils 0.8.5",
]
[[package]]
name = "crossbeam-queue"
version = "0.3.1"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0f6cb3c7f5b8e51bc3ebb73a2327ad4abdbd119dc13223f14f961d2f38486756"
checksum = "9b10ddc024425c88c2ad148c1b0fd53f4c6d38db9697c9f1588381212fa657c9"
dependencies = [
"cfg-if 1.0.0",
"crossbeam-utils 0.8.4",
"crossbeam-utils 0.8.5",
]
[[package]]
@ -846,11 +846,10 @@ dependencies = [
[[package]]
name = "crossbeam-utils"
version = "0.8.4"
version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4feb231f0d4d6af81aed15928e58ecf5816aa62a2393e2c82f46973e92a9a278"
checksum = "d82cfc11ce7f2c3faef78d8a684447b40d503d9681acebed6cb728d45940c4db"
dependencies = [
"autocfg",
"cfg-if 1.0.0",
"lazy_static",
]
@ -1305,43 +1304,6 @@ dependencies = [
"polyval",
]
[[package]]
name = "guard"
version = "0.1.0"
dependencies = [
"actix",
"actix-cors",
"actix-http",
"actix-identity",
"actix-rt",
"actix-service",
"actix-web",
"actix-web-codegen 0.5.0-beta.2",
"argon2-creds",
"cache-buster",
"config",
"derive_builder 0.10.2",
"derive_more",
"futures",
"lazy_static",
"log",
"m_captcha",
"mime",
"mime_guess",
"pow_sha256",
"pretty_env_logger",
"rand 0.8.3",
"rust-embed",
"sailfish",
"serde 1.0.126",
"serde_json",
"serde_yaml",
"sqlx",
"url",
"validator",
"yaml-rust",
]
[[package]]
name = "h2"
version = "0.2.7"
@ -1605,9 +1567,25 @@ dependencies = [
[[package]]
name = "libc"
version = "0.2.94"
version = "0.2.95"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "18794a8ad5b29321f790b55d93dfba91e125cb1a9edbd4f8e3150acc771c1a5e"
checksum = "789da6d93f1b866ffe175afc5322a4d76c038605a1c3319bb57b06967ca98a36"
[[package]]
name = "libmcaptcha"
version = "0.1.3"
source = "git+https://github.com/mCaptcha/libmcaptcha?branch=master#b5cb68af4831047acbf6cd039ec411ea1755181c"
dependencies = [
"actix",
"derive_builder 0.9.0",
"derive_more",
"log",
"pow_sha256",
"pretty_env_logger",
"rand 0.8.3",
"serde 1.0.126",
"serde_json",
]
[[package]]
name = "linked-hash-map"
@ -1642,22 +1620,6 @@ dependencies = [
"linked-hash-map",
]
[[package]]
name = "m_captcha"
version = "0.1.3"
source = "git+https://github.com/mCaptcha/mCaptcha?branch=master#8f0f0daf1e1cb36c848cada1c24dc3799d1e31b4"
dependencies = [
"actix",
"derive_builder 0.9.0",
"derive_more",
"log",
"pow_sha256",
"pretty_env_logger",
"rand 0.8.3",
"serde 1.0.126",
"serde_json",
]
[[package]]
name = "mac"
version = "0.1.1"
@ -1714,6 +1676,43 @@ version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00"
[[package]]
name = "mcaptcha"
version = "0.1.0"
dependencies = [
"actix",
"actix-cors",
"actix-http",
"actix-identity",
"actix-rt",
"actix-service",
"actix-web",
"actix-web-codegen 0.5.0-beta.2",
"argon2-creds",
"cache-buster",
"config",
"derive_builder 0.10.2",
"derive_more",
"futures",
"lazy_static",
"libmcaptcha",
"log",
"mime",
"mime_guess",
"pow_sha256",
"pretty_env_logger",
"rand 0.8.3",
"rust-embed",
"sailfish",
"serde 1.0.126",
"serde_json",
"serde_yaml",
"sqlx",
"url",
"validator",
"yaml-rust",
]
[[package]]
name = "md-5"
version = "0.9.1"
@ -2347,7 +2346,7 @@ dependencies = [
"base64 0.13.0",
"blake2b_simd",
"constant_time_eq",
"crossbeam-utils 0.8.4",
"crossbeam-utils 0.8.5",
]
[[package]]
@ -2701,7 +2700,7 @@ dependencies = [
"crc",
"crossbeam-channel 0.5.1",
"crossbeam-queue",
"crossbeam-utils 0.8.4",
"crossbeam-utils 0.8.5",
"either",
"futures-channel",
"futures-core",
@ -3189,9 +3188,9 @@ dependencies = [
[[package]]
name = "unicode-normalization"
version = "0.1.17"
version = "0.1.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "07fbfce1c8a97d547e8b5334978438d9d6ec8c20e38f56d4a4374d181493eaef"
checksum = "33717dca7ac877f497014e10d73f3acf948c342bee31b5ca7892faf94ccc6b49"
dependencies = [
"tinyvec",
]

View file

@ -1,20 +1,20 @@
[package]
name = "guard"
name = "mcaptcha"
version = "0.1.0"
description = "mCaptcha - a PoW-based CAPTCHA system"
homepage = "https://mcaptcha.org"
repository = "https://github.com/mCaptcha/guard"
repository = "https://github.com/mCaptcha/mCaptcha"
documentation = "https://mcaptcha.org/docs/"
license = "AGPLv3 or later version"
authors = ["realaravinth <realaravinth@batsense.net>"]
edition = "2018"
default-run = "guard"
default-run = "mcaptcha"
build = "build.rs"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[[bin]]
name = "guard"
name = "mcaptcha"
path = "./src/main.rs"
[[bin]]
@ -39,8 +39,7 @@ cache-buster = { version = "0.2.0", git = "https://github.com/realaravinth/cache
futures = "0.3.14"
sqlx = { version = "0.4.0", features = [ "runtime-actix-rustls", "postgres", "time", "offline" ] }
argon2-creds = { version = "0.2", git = "https://github.com/realaravinth/argon2-creds", commit = "61f2d1d" }
argon2-creds = { version = "0.2.1", git = "https://github.com/realaravinth/argon2-creds"}
config = "0.11"
validator = { version = "0.13", features = ["derive"]}
@ -60,7 +59,7 @@ lazy_static = "1.4"
# m_captcha = { version = "0.1.2", git = "https://github.com/mCaptcha/mCaptcha" }
m_captcha = { branch = "master", git = "https://github.com/mCaptcha/mCaptcha" }
libmcaptcha = { branch = "master", git = "https://github.com/mCaptcha/libmcaptcha" }
rand = "0.8"

View file

@ -1,13 +1,16 @@
<div align="center">
<h1>mCaptcha Guard</h1>
<img width="100px" alt="mcaptcha logo" src="./docs/res/icon-trans.png" />
<h1>mCaptcha</h1>
<p>
<strong>Back-end component of mCaptcha</strong>
<strong>
Proof of work based, privacy respecting CAPTCHA system with a kickass UX.
</strong>
</p>
[![Documentation](https://img.shields.io/badge/docs-master-blue?style=flat-square)](https://mcaptcha.github.io/guard/guard/)
[![Build](https://github.com/mCaptcha/guard/actions/workflows/linux.yml/badge.svg)](https://github.com/mCaptcha/guard/actions/workflows/linux.yml)
[![dependency status](https://deps.rs/repo/github/mCaptcha/guard/status.svg?style=flat-square)](https://deps.rs/repo/github/mCaptcha/guard)
[![codecov](https://codecov.io/gh/mCaptcha/guard/branch/master/graph/badge.svg?style=flat-square)](https://codecov.io/gh/mCaptcha/guard)
[![Documentation](https://img.shields.io/badge/docs-master-blue?style=flat-square)](https://mcaptcha.github.io/mCaptcha/mCaptcha/)
[![Build](https://github.com/mCaptcha/mCaptcha/actions/workflows/linux.yml/badge.svg)](https://github.com/mCaptcha/mCaptcha/actions/workflows/linux.yml)
[![dependency status](https://deps.rs/repo/github/mCaptcha/mCaptcha/status.svg?style=flat-square)](https://deps.rs/repo/github/mCaptcha/mCaptcha)
[![codecov](https://codecov.io/gh/mCaptcha/mCaptcha/branch/master/graph/badge.svg?style=flat-square)](https://codecov.io/gh/mCaptcha/mCaptcha)
<br />
[![AGPL License](https://img.shields.io/badge/license-AGPL-blue.svg?style=flat-square)](http://www.gnu.org/licenses/agpl-3.0)
[![Chat](https://img.shields.io/badge/matrix-+mcaptcha:matrix.batsense.net-purple?style=flat-square)](https://matrix.to/#/+mcaptcha:matrix.batsense.net)
@ -20,10 +23,13 @@
**Skip to [demo](#demo)**
Guard is the back-end component of the [mCaptcha](https://mcaptcha.org)
system.
[mCaptcha](https://mcaptcha.org) is a
Your users no longer have to interact with ridiculous image-based
CAPTCHA system, wasting precious mental bandwidth. Instead, your
computer will do the work for you, [see for
yourself!](https://demo.mcaptcha.org/widget?sitekey=RnR9SvkkB2s1W9yrQSBBViJHLvuiXKo4)
---
## How does it work?
mCaptcha uses SHA256 based proof-of-work(PoW) to rate limit users.
@ -74,9 +80,9 @@ easier. One click and you are on your way.
To observe mCaptcha in action, open dev tools and
monitor console and network activity.
1. [Link to widget](https://demo.mcaptcha.org/widget?sitekey=RnR9SvkkB2s1W9yrQSBBViJHLvuiXKo4)(opens https://demo.mcaptcha.org)
1. [Link to widget](https://demo.mcaptcha.org/widget?sitekey=RnR9SvkkB2s1W9yrQSBBViJHLvuiXKo4)
2. [Video](https://github.com/mCaptcha/guard/blob/master/docs/res/widget-in-action.mp4?raw=true):
2. [Video](https://github.com/mCaptcha/mCaptcha/blob/master/docs/res/widget-in-action.mp4?raw=true):
### Demo servers are available at:
@ -97,7 +103,6 @@ Clone the repo and run the following from the root of the repo:
```bash
$ docker-compose -d up
```
It takes a while to build the image so please be patient :)

View file

@ -1,5 +1,5 @@
debug = true
source_code = "https://github.com/mCaptcha/guard"
source_code = "https://github.com/mCaptcha/mCaptcha"
[database]
# This section deals with the database location and how to access it

View file

@ -1,12 +1,12 @@
# Configuration
Guard is highly configurable.
mcaptcha is highly configurable.
Configuration is applied/merged in the following order:
1. path to configuration file passed in via `GUARD_CONFIG`
1. path to configuration file passed in via `MCAPTCHA_CONFIG`
2. `./config/default.toml`
3. `/etc/guard/config.toml`
3. `/etc/mcaptcha/config.toml`
4. environment variables.
## Setup
@ -21,37 +21,37 @@ you will be overriding the values set in the configuration files.
| Name | Value |
| ------------------------------------ | ------------------------------------------------------------- |
| `GUARD_DATEBASE_PASSWORD` | Postgres password |
| `GUARD_DATEBASE_NAME` | Postgres database name |
| `GUARD_DATEBASE_PORT` | Postgres port |
| `GUARD_DATEBASE_HOSTNAME` | Postgres hostmane |
| `GUARD_DATEBASE_USERNAME` | Postgres username |
| `GUARD_DATEBASE_POOL` | Postgres database connection pool size |
| `MCAPTCHA_DATEBASE_PASSWORD` | Postgres password |
| `MCAPTCHA_DATEBASE_NAME` | Postgres database name |
| `MCAPTCHA_DATEBASE_PORT` | Postgres port |
| `MCAPTCHA_DATEBASE_HOSTNAME` | Postgres hostmane |
| `MCAPTCHA_DATEBASE_USERNAME` | Postgres username |
| `MCAPTCHA_DATEBASE_POOL` | Postgres database connection pool size |
| `DATABSE_URL` (overrides above vars) | databse URL in `postgres://user:pass@host:port/dbname` format |
#### Server:
| Name | Value |
| ------------------------------------- | --------------------------------------------------- |
| `GUARD_SERVER_PORT` | The port on which you want guard to listen to |
| `PORT`(overrides `GUARD_SERVER_PORT`) | The port on which you want guard to listen to |
| `GUARD_SERVER_IP` | The IP address on which you want guard to listen to |
| `GUARD_SERVER_DOMAIN` | Domain under which guard will be\* |
| `GUARD_SERVER_COOKIE_SECRET` | Cookie secret, must be long and random |
| `GUARD_SERVER_ALLOW_REGISTRATION` | `bool` that controls | | registration |
| `MCAPTCHA_SERVER_PORT` | The port on which you want mcaptcha to listen to |
| `PORT`(overrides `MCAPTCHA_SERVER_PORT`) | The port on which you want mcaptcha to listen to |
| `MCAPTCHA_SERVER_IP` | The IP address on which you want mcaptcha to listen to |
| `MCAPTCHA_SERVER_DOMAIN` | Domain under which mcaptcha will be\* |
| `MCAPTCHA_SERVER_COOKIE_SECRET` | Cookie secret, must be long and random |
| `MCAPTCHA_SERVER_ALLOW_REGISTRATION` | `bool` that controls | | registration |
\* Authentication doesn't work without `GUARD_DOMAIN` set to the correct
\* Authentication doesn't work without `MCAPTCHA_DOMAIN` set to the correct
domain
### Configuration file location:
| Name | Value |
| -------------- | ------------------- |
| `GUARD_CONFIG` | Path to config file |
| `MCAPTCHA_CONFIG` | Path to config file |
### Proof of work:
| Name | Value |
| ---------------- | --------------------------------------------------------------------------------------- |
| `GUARD_POW_SALT` | Salt has to be long and random |
| `GUARD_POW_GC` | Garbage collection duration in seconds, requires tuning but 30 is a good starting point |
| `MCAPTCHA_POW_SALT` | Salt has to be long and random |
| `MCAPTCHA_POW_GC` | Garbage collection duration in seconds, requires tuning but 30 is a good starting point |

View file

@ -15,7 +15,7 @@ NOTE: We'll publish pre-built images once we reach `alpha`.
1. Build image:
```bash
$ cd guard && docker build -t mcaptcha/guard:latest .
$ cd mcaptcha && docker build -t mcaptcha/mcaptcha:latest .
```
2. Set configuration in [configuration file](../config/default.toml)
@ -29,13 +29,13 @@ docker run -p <host-machine-port>:<port-in-configuration-file> \
--add-host=database:<database-ip-addrss> \
-e RUST_LOG=debug \
-e DATABASE_URL="postgres://<db-user>:<db-password>@database:<db-port>/<db-name>" \
mcaptcha/guard:latest
mcaptcha/mcaptcha:latest
```
If you don't have a Postgres instance running, you can either install
one using a package manager or launch one with docker. A [docker-compose
configuration]('../docker-compose.yml) is available that will launch both
a database instance guard instance.
a database instance mcaptcha instance.
## With docker-compose
@ -56,7 +56,7 @@ the future.
### 1. Install postgres if you don't have it already.
### 2. Create new user for running `guard`:
### 2. Create new user for running `mcaptcha`:
```bash
$ sudo useradd -b /srv -m -s /usr/bin/zsh mcaptcha
@ -71,9 +71,9 @@ postgres=# CREATE USER mcaptcha WITH PASSWORD 'my super long password and yes y
$ createdb -O mcaptcha mcaptcha # create db 'mcaptcha' with 'mcaptcha' as owner
```
### 4. Build `guard`:
### 4. Build `mcaptcha`:
To build `guard`, you need the following dependencies:
To build `mcaptcha`, you need the following dependencies:
1. rust
2. node(`v14.16.0`)
@ -102,14 +102,14 @@ $ make dev-env && \
### 5. Install package:
```bash
$ sudo cp ./target/release/guard /usr/bin/ && \
mkdir sudo /etc/guard && \
sudo cp config/default.toml /etc/guard/config.toml
$ sudo cp ./target/release/mcaptcha /usr/bin/ && \
mkdir sudo /etc/mcaptcha && \
sudo cp config/default.toml /etc/mcaptcha/config.toml
```
### 6. Systemd service configuration:
1. Copy the following to `/etc/systemd/system/guard.service`:
1. Copy the following to `/etc/systemd/system/mcaptcha.service`:
```systemd
[Unit]
@ -118,7 +118,7 @@ Description=mCaptcha: a CAPTCHA system that gives attackers a run for their mone
[Service]
Type=simple
User=mcaptcha
ExecStart=/usr/bin/guard
ExecStart=/usr/bin/mcaptcha
Restart=on-failure
RestartSec=1
SuccessExitStatus=3 4
@ -142,6 +142,6 @@ WantedBy=multi-user.target
2. Enable service:
```bash
$ sudo systemctl daemon-reload && \
sudo systemctl enable guard && \ # Auto startup during boot
sudo systemctl start guard
sudo systemctl enable mcaptcha && \ # Auto startup during boot
sudo systemctl start mcaptcha
``

View file

@ -22,7 +22,7 @@ $ docker-compose logs -f
- from just webserver:
```bash
$ docker-compose logs -f guard
$ docker-compose logs -f mcaptcha
```
## Setting up elaborate development environment
@ -88,7 +88,7 @@ $ docker start mcaptcha-postgres
4. Set configurations:
```bash
$ cd guard # your copy of https://github.com/mCaptcha/guard
$ cd mcaptcha # your copy of https://github.com/mCaptcha/mcaptcha
$ echo 'export DATABASE_URL="postgres://postgres:password@localhost:5432/postgres"' > .env
```
@ -103,7 +103,7 @@ $ echo 'export DATABASE_URL="postgres://postgres:password@localhost:5432/postgre
However, this project ships with a utility to run migrations!
```bash
$ cd guard # your copy of https://github.com/mCaptcha/guard
$ cd mcaptcha # your copy of https://github.com/mCaptcha/mcaptcha
$ cargo run --bin tests-migrate
```
@ -114,14 +114,14 @@ That's it, you are all set!
### Compile:
```bash
$ cd guard # your copy of https://github.com/mCaptcha/guard
$ cd mcaptcha # your copy of https://github.com/mCaptcha/mcaptcha
$ make
```
### Additional commands:
```bash
guard git:(master) ✗ make help
mcaptcha git:(master) ✗ make help
docs - build documentation
run - run developer instance
test - run unit and integration tests

BIN
docs/res/icon-trans.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 142 KiB

View file

@ -70,7 +70,7 @@ async fn update_duration(
} else {
// when mCaptcha/mCaptcha #2 is fixed, this wont be necessary
Err(ServiceError::CaptchaError(
m_captcha::errors::CaptchaError::CaptchaDurationZero,
libmcaptcha::errors::CaptchaError::CaptchaDurationZero,
))
}
}

View file

@ -18,7 +18,7 @@
use actix_identity::Identity;
use actix_web::{web, HttpResponse, Responder};
use log::debug;
use m_captcha::{defense::Level, DefenseBuilder};
use libmcaptcha::{defense::Level, DefenseBuilder};
use serde::{Deserialize, Serialize};
use super::mcaptcha::add_mcaptcha_util;

View file

@ -17,7 +17,7 @@
use actix::prelude::*;
use actix_web::{web, HttpResponse, Responder};
use m_captcha::{
use libmcaptcha::{
defense::LevelBuilder, master::AddSiteBuilder, DefenseBuilder, MCaptchaBuilder,
};
use serde::{Deserialize, Serialize};
@ -85,10 +85,10 @@ pub async fn get_config(
None => Err(ServiceError::TokenNotFound),
}
}
/// Call this when [MCaptcha][m_captcha::MCaptcha] is not in master.
/// Call this when [MCaptcha][libmcaptcha::MCaptcha] is not in master.
///
/// This fn gets mcaptcha config from database, builds [Defense][m_captcha::Defense],
/// creates [MCaptcha][m_captcha::MCaptcha] and adds it to [Master][m_captcha::Defense]
/// This fn gets mcaptcha config from database, builds [Defense][libmcaptcha::Defense],
/// creates [MCaptcha][libmcaptcha::MCaptcha] and adds it to [Master][libmcaptcha::Defense]
async fn init_mcaptcha(data: &Data, key: &str) -> ServiceResult<()> {
// get levels
let levels_fut = sqlx::query_as!(
@ -151,7 +151,7 @@ async fn init_mcaptcha(data: &Data, key: &str) -> ServiceResult<()> {
mod tests {
use actix_web::http::{header, StatusCode};
use actix_web::test;
use m_captcha::pow::PoWConfig;
use libmcaptcha::pow::PoWConfig;
use super::*;
use crate::tests::*;

View file

@ -17,7 +17,7 @@
//! PoW Verification module
use actix_web::{web, HttpResponse, Responder};
use m_captcha::pow::Work;
use libmcaptcha::pow::Work;
use serde::{Deserialize, Serialize};
use crate::errors::*;
@ -54,7 +54,7 @@ pub async fn verify_pow(
mod tests {
use actix_web::http::{header, StatusCode};
use actix_web::test;
use m_captcha::pow::PoWConfig;
use libmcaptcha::pow::PoWConfig;
use super::*;
use crate::api::v1::pow::get_config::GetConfigPayload;
@ -125,7 +125,7 @@ mod tests {
format!(
"{}",
ServiceError::CaptchaError(
m_captcha::errors::CaptchaError::StringNotFound
libmcaptcha::errors::CaptchaError::StringNotFound
)
)
);
@ -137,9 +137,9 @@ mod tests {
// .await;
// assert_eq!(pow_config_resp.status(), StatusCode::OK);
// I'm not checking for errors because changing work.result triggered
// InssuficientDifficulty, which is possible becuase m_captcha calculates
// InssuficientDifficulty, which is possible becuase libmcaptcha calculates
// difficulty with the submitted result. Besides, this endpoint is merely
// propagating errors from m_captcha and m_captcha has tests covering the
// propagating errors from libmcaptcha and libmcaptcha has tests covering the
// pow aspects ¯\_(ツ)_/¯
}
}

View file

@ -17,7 +17,7 @@
//! PoW success token module
use actix_web::{web, HttpResponse, Responder};
use m_captcha::cache::messages::VerifyCaptchaResult;
use libmcaptcha::cache::messages::VerifyCaptchaResult;
use serde::{Deserialize, Serialize};
use crate::errors::*;
@ -55,8 +55,8 @@ pub async fn validate_captcha_token(
mod tests {
use actix_web::http::{header, StatusCode};
use actix_web::test;
use m_captcha::pow::PoWConfig;
use m_captcha::pow::Work;
use libmcaptcha::pow::PoWConfig;
use libmcaptcha::pow::Work;
use super::*;
use crate::api::v1::pow::get_config::GetConfigPayload;

View file

@ -17,7 +17,7 @@
use actix::prelude::*;
use argon2_creds::{Config, ConfigBuilder, PasswordPolicy};
use m_captcha::{
use libmcaptcha::{
cache::HashCache,
master::Master,
pow::ConfigBuilder as PoWConfigBuilder,

View file

@ -25,7 +25,7 @@ use actix_web::{
};
use argon2_creds::errors::CredsError;
use derive_more::{Display, Error};
use m_captcha::errors::CaptchaError;
use libmcaptcha::errors::CaptchaError;
use serde::{Deserialize, Serialize};
use url::ParseError;
use validator::ValidationErrors;

View file

@ -155,7 +155,7 @@ mod test {
assert_eq!(
&*crate::SOURCE_FILES_OF_INSTANCE,
&format!(
"https://github.com/mCaptcha/guard/tree/{}",
"https://github.com/mCaptcha/mCaptcha/tree/{}",
crate::GIT_COMMIT_HASH
)
);

View file

@ -99,9 +99,9 @@ impl Settings {
.expect("Couldn't get the number of CPUs");
const CURRENT_DIR: &str = "./config/default.toml";
const ETC: &str = "/etc/guard/config.toml";
const ETC: &str = "/etc/mcaptcha/config.toml";
if let Ok(path) = env::var("GUARD_CONFIG") {
if let Ok(path) = env::var("MCAPTCHA_CONFIG") {
s.merge(File::with_name(&path))?;
} else if Path::new(CURRENT_DIR).exists() {
// merging default config from file
@ -112,7 +112,7 @@ impl Settings {
log::warn!("configuration file not found");
}
s.merge(Environment::with_prefix("GUARD").separator("_"))?;
s.merge(Environment::with_prefix("MCAPTCHA").separator("_"))?;
check_url(&s);
@ -136,7 +136,7 @@ impl Settings {
match s.try_into() {
Ok(val) => Ok(val),
Err(e) => Err(ConfigError::Message(format!("\n\nError: {}. If it says missing fields, then please refer to https://github.com/mCaptcha/guard#configuration to learn more about how guard reads configuration\n\n", e)))?,
Err(e) => Err(ConfigError::Message(format!("\n\nError: {}. If it says missing fields, then please refer to https://github.com/mCaptcha/mcaptcha#configuration to learn more about how mcaptcha reads configuration\n\n", e)))?,
}
}
}

View file

@ -4,7 +4,7 @@ use actix_web::{
http::{header, StatusCode},
middleware as actix_middleware,
};
use m_captcha::defense::Level;
use libmcaptcha::defense::Level;
use serde::Serialize;
use super::*;