Compare commits

..

21 Commits

Author SHA1 Message Date
Aravinth Manivannan
cadc15a7a1 fix: copy OpenAPI build from build container to final container
fixes: https://github.com/mCaptcha/mCaptcha/issues/59
2023-01-17 03:54:54 +05:30
Aravinth Manivannan
c1f6ce3ae2 Merge pull request #52 from Gusted/close-register-page
Hide register page when registrations are closed
2022-11-07 13:39:34 +05:30
Gusted
864549cb4c Fix copyright 2022-11-06 19:42:22 +01:00
Gusted
5713d4b1ae Hide register page when registrations are closed
- Improve UX for "private" instances.
2022-10-24 22:47:07 +02:00
Aravinth Manivannan
ac502b7c08 Merge pull request #51 from Gusted/fix-compiling
Fix compiling
2022-10-24 21:22:34 +05:30
Gusted
8dc690ca01 Remove redunant format 2022-10-24 16:22:10 +02:00
Gusted
a4f9c92b32 Update cargo 2022-10-22 21:53:18 +02:00
Gusted
8826f6df8f Fix compiling
- I made some mistakes while checking my two previous PRs(Seems like I
don't understand Rust that great after all).
- Do the url encoding only on the password part, not only the whole URL.
- Fix `temporary value dropped while borrowed` compile error.
2022-10-22 21:28:58 +02:00
Aravinth Manivannan
af35fdb48e Merge pull request #46 from Gusted/relax-port-env
Allow `PORT` environment to be not set
2022-10-18 15:51:22 +05:30
Gusted
9fd8ffd666 Add more logging for configuration/env 2022-10-17 19:49:42 +02:00
Aravinth Manivannan
521abd82d6 Merge pull request #47 from Gusted/encode-url-postgres
Encode connection URL to database
2022-10-17 15:42:02 +05:30
Gusted
021f2fe5b4 Encode connection URL to database
- If you have a database password that contains characters like `#` or `*`, sqlx
will error about a InvalidPort, this is due to not encoding the url.
[See issue on sqlx](https://github.com/launchbadge/sqlx/issues/1624).
- Removed useless statements.
2022-10-16 23:37:24 +02:00
Gusted
b3e0ff6769 Allow PORT environment to be not set
- It's quite weird to require the `PORT` environment to be set, when it
already can be set via the config file.
2022-10-16 23:07:10 +02:00
Aravinth Manivannan
97abca2520 Merge pull request #45 from DarianAnjuhal/master
feat: open mail link with target=_blank
2022-10-12 15:28:13 +05:30
Daniel Antlinger
96a6c98c10 feat: open mail link with target=_blank 2022-10-12 11:50:55 +02:00
realaravinth
9d285573d7 fix: typo in widget 2022-09-26 16:40:40 +05:30
Aravinth Manivannan
d506d291c3 Merge pull request #43 from DarianAnjuhal/master
feat: open links from widget in new pages target=_blank
2022-09-07 23:31:56 +05:30
Daniel Antlinger
223e8fb8c2 feat: open links from widget in new pages target=_blank 2022-09-07 14:05:25 +02:00
realaravinth
2abf57d16b fix: set correct upload dir 2022-08-15 18:01:41 +05:30
realaravinth
b3ee57d042 fix: configure gpg key 2022-08-15 17:37:48 +05:30
realaravinth
8c65edd257 fix: upload path 2022-08-15 17:25:22 +05:30
10 changed files with 81 additions and 26 deletions

View File

@@ -82,7 +82,7 @@ jobs:
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: configure GPG key
if: (github.ref == 'refs/heads/master' || github.event_name == 'push') && github.repository == 'realaravinth/dumbserve'
if: (github.ref == 'refs/heads/master' || github.event_name == 'push') && github.repository == 'mCaptcha/mCaptcha'
run: echo -n "$RELEASE_BOT_GPG_SIGNING_KEY" | gpg --batch --import --pinentry-mode loopback
env:
RELEASE_BOT_GPG_SIGNING_KEY: ${{ secrets.RELEASE_BOT_GPG_SIGNING_KEY }}

4
Cargo.lock generated
View File

@@ -3386,9 +3386,9 @@ dependencies = [
[[package]]
name = "urlencoding"
version = "2.1.0"
version = "2.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "68b90931029ab9b034b300b797048cf23723400aa757e8a2bfb9d748102f9821"
checksum = "e8db7427f936968176eaa7cdf81b7f98b980b18495ec28f1b5791ac3bfe3eea9"
[[package]]
name = "utf-8"

View File

@@ -38,6 +38,7 @@ COPY --from=cacher /src/target target
#COPY --from=cacher /src/db/db-migrations/target /src/db/db-migrations/target
#COPY --from=cacher /src/utils/cache-bust/target /src/utils/cache-bust/target
COPY --from=frontend /src/static/cache/bundle/ /src/static/cache/bundle/
COPY --from=frontend /src/docs/openapi/dist/ /src/docs/openapi/dist/
RUN cargo --version
RUN make cache-bust
RUN cargo build --release

View File

@@ -73,9 +73,6 @@ impl Connect for ConnectionOptions {
if fresh.disable_logging {
connect_options.disable_statement_logging();
}
sqlx::mysql::MySqlConnectOptions::from_str(&fresh.url)
.unwrap()
.disable_statement_logging();
fresh
.pool_options
.connect_with(connect_options)

View File

@@ -73,9 +73,6 @@ impl Connect for ConnectionOptions {
if fresh.disable_logging {
connect_options.disable_statement_logging();
}
sqlx::postgres::PgConnectOptions::from_str(&fresh.url)
.unwrap()
.disable_statement_logging();
fresh
.pool_options
.connect_with(connect_options)

View File

@@ -97,14 +97,15 @@ delete_dir() {
}
upload_dist() {
delete_dir $1
upload_dir="mCaptcha/$1"
delete_dir $upload_dir
pushd $TMP_DIR
for file in $TARBALL $TARBALL.asc $TARBALL.sha256
do
curl -v \
-F upload=@$file \
"$DUMBSERVE_HOST/api/v1/files/upload?path=$1/"
"$DUMBSERVE_HOST/api/v1/files/upload?path=$upload_dir"
done
popd
}

View File

@@ -14,8 +14,8 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
use std::env;
use std::path::Path;
use std::{env, fs};
use config::{Config, ConfigError, Environment, File};
use derive_more::Display;
@@ -152,25 +152,34 @@ impl Settings {
.expect("unable to set capatcha.enable_stats default config");
if let Ok(path) = env::var("MCAPTCHA_CONFIG") {
s.merge(File::with_name(&path))?;
let absolute_path = Path::new(&path).canonicalize().unwrap();
log::info!(
"Loading config file from {}",
absolute_path.to_str().unwrap()
);
s.merge(File::with_name(absolute_path.to_str().unwrap()))?;
} else if Path::new(CURRENT_DIR).exists() {
let absolute_path = fs::canonicalize(CURRENT_DIR).unwrap();
log::info!(
"Loading config file from {}",
absolute_path.to_str().unwrap()
);
// merging default config from file
s.merge(File::with_name(CURRENT_DIR))?;
s.merge(File::with_name(absolute_path.to_str().unwrap()))?;
} else if Path::new(ETC).exists() {
log::info!("{}", format!("Loading config file from {}", ETC));
s.merge(File::with_name(ETC))?;
} else {
log::warn!("configuration file not found");
log::warn!("Configuration file not found");
}
s.merge(Environment::with_prefix("MCAPTCHA").separator("_"))?;
check_url(&s);
match env::var("PORT") {
Ok(val) => {
s.set("server.port", val).unwrap();
}
Err(e) => warn!("couldn't interpret PORT: {}", e),
if let Ok(val) = env::var("PORT") {
s.set("server.port", val).unwrap();
log::info!("Overriding [server].port with environment variable");
}
match env::var("DATABASE_URL") {
@@ -180,6 +189,7 @@ impl Settings {
let database_type = DBType::from_url(&url).unwrap();
s.set("database.database_type", database_type.to_string())
.unwrap();
log::info!("Overriding [database].url and [database].database_type with environment variable");
}
Err(e) => {
set_database_url(&mut s);
@@ -215,8 +225,11 @@ fn set_database_url(s: &mut Config) {
r"postgres://{}:{}@{}:{}/{}",
s.get::<String>("database.username")
.expect("Couldn't access database username"),
s.get::<String>("database.password")
.expect("Couldn't access database password"),
urlencoding::encode(
s.get::<String>("database.password")
.expect("Couldn't access database password")
.as_str()
),
s.get::<String>("database.hostname")
.expect("Couldn't access database hostname"),
s.get::<String>("database.port")

View File

@@ -8,6 +8,16 @@
class="auth__logo" alt="mcaptcha logo" />
<. if !crate::SETTINGS.allow_registration { .>
<table class="reg-closed__table">
<thead class="reg-closed__table-heading">
<tr><th colspan="4" class="reg-closed__table-title-text">Registration closed</th></tr>
</thead>
<tbody class="reg-closed__body">
<tr><td class="reg-closed__body-text">This mCaptcha instance is closed for registrations.</td></tr>
</tbody>
</table>
<. } else {.>
<form
method="POST"
action="<.= crate::V1_API_ROUTES.auth.register .>"
@@ -73,5 +83,6 @@
<a href="<.= crate::PAGES.auth.login .>" class="auth__secondary-action__link">Log in</a>
</p>
<. include!("../demo-user-banner.html"); .>
<. } .>
</div>
<. include!("../../components/footers.html"); .>

View File

@@ -0,0 +1,32 @@
/*
* Copyright (C) 2022 Gusted <postmaster@gusted.xyz>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
@import '../../components/table/main';
.reg-closed__table {
@include table;
margin: auto;
}
.reg-closed__table-title-text {
@include table__title-text;
}
.reg-closed__body-text {
display: block;
margin: 0.5em 0;
}

View File

@@ -19,11 +19,12 @@
<span id="widget__verification-text--before">I'm not a robot</span>
<span id="widget__verification-text--during">Processing...</span>
<span id="widget__verification-text--after">Verified!</span>
<span id="widget__verification-text--error">Something wen't wrong</span>
<span id="widget__verification-text--error">Something went wrong</span>
</label>
<div class="widget__mcaptcha-details">
<a href="<.= crate::PKG_HOMEPAGE .>"
class="widget__mcaptcha-logo-container"
target="_blank"
>
<img
class="widget__mcaptcha-logo"
@@ -33,12 +34,14 @@
<p class="widget__mcaptcha-brand-name">mCaptcha</p>
</a>
<div class="widget__mcaptcha-info-container">
<a class="widget__mcaptcha-info-link"
href="<.= crate::PKG_HOMEPAGE .><.= crate::PAGES.privacy .>">
<a class="widget__mcaptcha-info-link"
target="_blank"
href="<.= crate::PKG_HOMEPAGE .><.= crate::PAGES.privacy .>">
Privacy
</a>
<a class="widget__mcaptcha-info-link"
href="<.= crate::PKG_HOMEPAGE .><.= crate::PAGES.security .>">
target="_blank"
href="<.= crate::PKG_HOMEPAGE .><.= crate::PAGES.security .>">
Terms
</a>
</div>