upd: add FriendlyCaptcha as a captcha solution
FriendlyCaptcha is a german captcha solution which is GDPR compliant and has a non-commerical free license
This commit is contained in:
parent
8824422cb5
commit
d786e96c2b
|
@ -0,0 +1,20 @@
|
||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: marie and other Sharkey contributors
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
*/
|
||||||
|
|
||||||
|
export class friendlyCaptcha1730505338000 {
|
||||||
|
name = 'friendlyCaptcha1730505338000';
|
||||||
|
|
||||||
|
async up(queryRunner) {
|
||||||
|
await queryRunner.query(`ALTER TABLE "meta" ADD "enableFC" boolean NOT NULL DEFAULT false`, undefined);
|
||||||
|
await queryRunner.query(`ALTER TABLE "meta" ADD "fcSiteKey" character varying(1024)`, undefined);
|
||||||
|
await queryRunner.query(`ALTER TABLE "meta" ADD "fcSecretKey" character varying(1024)`, undefined);
|
||||||
|
}
|
||||||
|
|
||||||
|
async down(queryRunner) {
|
||||||
|
await queryRunner.query(`ALTER TABLE "meta" DROP COLUMN "fcSecretKey"`, undefined);
|
||||||
|
await queryRunner.query(`ALTER TABLE "meta" DROP COLUMN "fcSiteKey"`, undefined);
|
||||||
|
await queryRunner.query(`ALTER TABLE "meta" DROP COLUMN "enableFC"`, undefined);
|
||||||
|
}
|
||||||
|
}
|
|
@ -10,6 +10,7 @@ import { bindThis } from '@/decorators.js';
|
||||||
type CaptchaResponse = {
|
type CaptchaResponse = {
|
||||||
success: boolean;
|
success: boolean;
|
||||||
'error-codes'?: string[];
|
'error-codes'?: string[];
|
||||||
|
'errors'?: string[];
|
||||||
};
|
};
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
|
@ -73,6 +74,35 @@ export class CaptchaService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@bindThis
|
||||||
|
public async verifyFriendlyCaptcha(secret: string, response: string | null | undefined): Promise<void> {
|
||||||
|
if (response == null) {
|
||||||
|
throw new Error('recaptcha-failed: no response provided');
|
||||||
|
}
|
||||||
|
|
||||||
|
const result = await this.httpRequestService.send('https://api.friendlycaptcha.com/api/v1/siteverify', {
|
||||||
|
method: 'POST',
|
||||||
|
body: JSON.stringify({
|
||||||
|
secret: secret,
|
||||||
|
solution: response,
|
||||||
|
}),
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (result.status !== 200) {
|
||||||
|
throw new Error('frc-failed: frc didn\'t return 200 OK');
|
||||||
|
}
|
||||||
|
|
||||||
|
const resp = await result.json() as CaptchaResponse;
|
||||||
|
|
||||||
|
if (resp.success !== true) {
|
||||||
|
const errorCodes = resp['errors'] ? resp['errors'].join(', ') : '';
|
||||||
|
throw new Error(`frc-failed: ${errorCodes}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// https://codeberg.org/Gusted/mCaptcha/src/branch/main/mcaptcha.go
|
// https://codeberg.org/Gusted/mCaptcha/src/branch/main/mcaptcha.go
|
||||||
@bindThis
|
@bindThis
|
||||||
public async verifyMcaptcha(secret: string, siteKey: string, instanceHost: string, response: string | null | undefined): Promise<void> {
|
public async verifyMcaptcha(secret: string, siteKey: string, instanceHost: string, response: string | null | undefined): Promise<void> {
|
||||||
|
|
|
@ -98,6 +98,8 @@ export class MetaEntityService {
|
||||||
recaptchaSiteKey: instance.recaptchaSiteKey,
|
recaptchaSiteKey: instance.recaptchaSiteKey,
|
||||||
enableTurnstile: instance.enableTurnstile,
|
enableTurnstile: instance.enableTurnstile,
|
||||||
turnstileSiteKey: instance.turnstileSiteKey,
|
turnstileSiteKey: instance.turnstileSiteKey,
|
||||||
|
enableFC: instance.enableFC,
|
||||||
|
fcSiteKey: instance.fcSiteKey,
|
||||||
swPublickey: instance.swPublicKey,
|
swPublickey: instance.swPublicKey,
|
||||||
themeColor: instance.themeColor,
|
themeColor: instance.themeColor,
|
||||||
mascotImageUrl: instance.mascotImageUrl ?? '/assets/ai.png',
|
mascotImageUrl: instance.mascotImageUrl ?? '/assets/ai.png',
|
||||||
|
|
|
@ -269,6 +269,23 @@ export class MiMeta {
|
||||||
})
|
})
|
||||||
public turnstileSecretKey: string | null;
|
public turnstileSecretKey: string | null;
|
||||||
|
|
||||||
|
@Column('boolean', {
|
||||||
|
default: false,
|
||||||
|
})
|
||||||
|
public enableFC: boolean;
|
||||||
|
|
||||||
|
@Column('varchar', {
|
||||||
|
length: 1024,
|
||||||
|
nullable: true,
|
||||||
|
})
|
||||||
|
public fcSiteKey: string | null;
|
||||||
|
|
||||||
|
@Column('varchar', {
|
||||||
|
length: 1024,
|
||||||
|
nullable: true,
|
||||||
|
})
|
||||||
|
public fcSecretKey: string | null;
|
||||||
|
|
||||||
// chaptcha系を追加した際にはnodeinfoのレスポンスに追加するのを忘れないようにすること
|
// chaptcha系を追加した際にはnodeinfoのレスポンスに追加するのを忘れないようにすること
|
||||||
|
|
||||||
@Column('enum', {
|
@Column('enum', {
|
||||||
|
|
|
@ -127,6 +127,14 @@ export const packedMetaLiteSchema = {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
optional: false, nullable: true,
|
optional: false, nullable: true,
|
||||||
},
|
},
|
||||||
|
enableFC: {
|
||||||
|
type: 'boolean',
|
||||||
|
optional: false, nullable: false,
|
||||||
|
},
|
||||||
|
fcSiteKey: {
|
||||||
|
type: 'string',
|
||||||
|
optional: false, nullable: true,
|
||||||
|
},
|
||||||
enableAchievements: {
|
enableAchievements: {
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
optional: false, nullable: true,
|
optional: false, nullable: true,
|
||||||
|
|
|
@ -121,6 +121,7 @@ export class NodeinfoServerService {
|
||||||
enableRecaptcha: meta.enableRecaptcha,
|
enableRecaptcha: meta.enableRecaptcha,
|
||||||
enableMcaptcha: meta.enableMcaptcha,
|
enableMcaptcha: meta.enableMcaptcha,
|
||||||
enableTurnstile: meta.enableTurnstile,
|
enableTurnstile: meta.enableTurnstile,
|
||||||
|
enableFC: meta.enableFC,
|
||||||
maxNoteTextLength: this.config.maxNoteLength,
|
maxNoteTextLength: this.config.maxNoteLength,
|
||||||
maxRemoteNoteTextLength: this.config.maxRemoteNoteLength,
|
maxRemoteNoteTextLength: this.config.maxRemoteNoteLength,
|
||||||
maxCwLength: this.config.maxCwLength,
|
maxCwLength: this.config.maxCwLength,
|
||||||
|
|
|
@ -118,6 +118,7 @@ export class ApiServerService {
|
||||||
'hcaptcha-response'?: string;
|
'hcaptcha-response'?: string;
|
||||||
'g-recaptcha-response'?: string;
|
'g-recaptcha-response'?: string;
|
||||||
'turnstile-response'?: string;
|
'turnstile-response'?: string;
|
||||||
|
'frc-captcha-solution'?: string;
|
||||||
}
|
}
|
||||||
}>('/signup', (request, reply) => this.signupApiService.signup(request, reply));
|
}>('/signup', (request, reply) => this.signupApiService.signup(request, reply));
|
||||||
|
|
||||||
|
|
|
@ -72,6 +72,7 @@ export class SignupApiService {
|
||||||
'g-recaptcha-response'?: string;
|
'g-recaptcha-response'?: string;
|
||||||
'turnstile-response'?: string;
|
'turnstile-response'?: string;
|
||||||
'm-captcha-response'?: string;
|
'm-captcha-response'?: string;
|
||||||
|
'frc-captcha-solution'?: string;
|
||||||
}
|
}
|
||||||
}>,
|
}>,
|
||||||
reply: FastifyReply,
|
reply: FastifyReply,
|
||||||
|
@ -104,6 +105,12 @@ export class SignupApiService {
|
||||||
throw new FastifyReplyError(400, err);
|
throw new FastifyReplyError(400, err);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.meta.enableFC && this.meta.fcSecretKey) {
|
||||||
|
await this.captchaService.verifyFriendlyCaptcha(this.meta.fcSecretKey, body['frc-captcha-solution']).catch(err => {
|
||||||
|
throw new FastifyReplyError(400, err);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const username = body['username'];
|
const username = body['username'];
|
||||||
|
|
|
@ -73,6 +73,14 @@ export const meta = {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
optional: false, nullable: true,
|
optional: false, nullable: true,
|
||||||
},
|
},
|
||||||
|
enableFC: {
|
||||||
|
type: 'boolean',
|
||||||
|
optional: false, nullable: false,
|
||||||
|
},
|
||||||
|
fcSiteKey: {
|
||||||
|
type: 'string',
|
||||||
|
optional: false, nullable: true,
|
||||||
|
},
|
||||||
swPublickey: {
|
swPublickey: {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
optional: false, nullable: true,
|
optional: false, nullable: true,
|
||||||
|
@ -219,6 +227,10 @@ export const meta = {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
optional: false, nullable: true,
|
optional: false, nullable: true,
|
||||||
},
|
},
|
||||||
|
fcSecretKey: {
|
||||||
|
type: 'string',
|
||||||
|
optional: false, nullable: true,
|
||||||
|
},
|
||||||
sensitiveMediaDetection: {
|
sensitiveMediaDetection: {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
optional: false, nullable: false,
|
optional: false, nullable: false,
|
||||||
|
@ -600,6 +612,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
recaptchaSiteKey: instance.recaptchaSiteKey,
|
recaptchaSiteKey: instance.recaptchaSiteKey,
|
||||||
enableTurnstile: instance.enableTurnstile,
|
enableTurnstile: instance.enableTurnstile,
|
||||||
turnstileSiteKey: instance.turnstileSiteKey,
|
turnstileSiteKey: instance.turnstileSiteKey,
|
||||||
|
enableFC: instance.enableFC,
|
||||||
|
fcSiteKey: instance.fcSiteKey,
|
||||||
swPublickey: instance.swPublicKey,
|
swPublickey: instance.swPublicKey,
|
||||||
themeColor: instance.themeColor,
|
themeColor: instance.themeColor,
|
||||||
mascotImageUrl: instance.mascotImageUrl,
|
mascotImageUrl: instance.mascotImageUrl,
|
||||||
|
@ -634,6 +648,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
mcaptchaSecretKey: instance.mcaptchaSecretKey,
|
mcaptchaSecretKey: instance.mcaptchaSecretKey,
|
||||||
recaptchaSecretKey: instance.recaptchaSecretKey,
|
recaptchaSecretKey: instance.recaptchaSecretKey,
|
||||||
turnstileSecretKey: instance.turnstileSecretKey,
|
turnstileSecretKey: instance.turnstileSecretKey,
|
||||||
|
fcSecretKey: instance.fcSecretKey,
|
||||||
sensitiveMediaDetection: instance.sensitiveMediaDetection,
|
sensitiveMediaDetection: instance.sensitiveMediaDetection,
|
||||||
sensitiveMediaDetectionSensitivity: instance.sensitiveMediaDetectionSensitivity,
|
sensitiveMediaDetectionSensitivity: instance.sensitiveMediaDetectionSensitivity,
|
||||||
setSensitiveFlagAutomatically: instance.setSensitiveFlagAutomatically,
|
setSensitiveFlagAutomatically: instance.setSensitiveFlagAutomatically,
|
||||||
|
|
|
@ -81,6 +81,9 @@ export const paramDef = {
|
||||||
enableTurnstile: { type: 'boolean' },
|
enableTurnstile: { type: 'boolean' },
|
||||||
turnstileSiteKey: { type: 'string', nullable: true },
|
turnstileSiteKey: { type: 'string', nullable: true },
|
||||||
turnstileSecretKey: { type: 'string', nullable: true },
|
turnstileSecretKey: { type: 'string', nullable: true },
|
||||||
|
enableFC: { type: 'boolean' },
|
||||||
|
fcSiteKey: { type: 'string', nullable: true },
|
||||||
|
fcSecretKey: { type: 'string', nullable: true },
|
||||||
sensitiveMediaDetection: { type: 'string', enum: ['none', 'all', 'local', 'remote'] },
|
sensitiveMediaDetection: { type: 'string', enum: ['none', 'all', 'local', 'remote'] },
|
||||||
sensitiveMediaDetectionSensitivity: { type: 'string', enum: ['medium', 'low', 'high', 'veryLow', 'veryHigh'] },
|
sensitiveMediaDetectionSensitivity: { type: 'string', enum: ['medium', 'low', 'high', 'veryLow', 'veryHigh'] },
|
||||||
setSensitiveFlagAutomatically: { type: 'boolean' },
|
setSensitiveFlagAutomatically: { type: 'boolean' },
|
||||||
|
@ -383,6 +386,18 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
set.turnstileSecretKey = ps.turnstileSecretKey;
|
set.turnstileSecretKey = ps.turnstileSecretKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ps.enableFC !== undefined) {
|
||||||
|
set.enableFC = ps.enableFC;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ps.fcSiteKey !== undefined) {
|
||||||
|
set.fcSiteKey = ps.fcSiteKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ps.fcSecretKey !== undefined) {
|
||||||
|
set.fcSecretKey = ps.fcSecretKey;
|
||||||
|
}
|
||||||
|
|
||||||
if (ps.enableBotTrending !== undefined) {
|
if (ps.enableBotTrending !== undefined) {
|
||||||
set.enableBotTrending = ps.enableBotTrending;
|
set.enableBotTrending = ps.enableBotTrending;
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,12 +123,14 @@ describe('2要素認証', () => {
|
||||||
password: string,
|
password: string,
|
||||||
'g-recaptcha-response'?: string | null,
|
'g-recaptcha-response'?: string | null,
|
||||||
'hcaptcha-response'?: string | null,
|
'hcaptcha-response'?: string | null,
|
||||||
|
'frc-captcha-solution'?: string | null,
|
||||||
} => {
|
} => {
|
||||||
return {
|
return {
|
||||||
username,
|
username,
|
||||||
password,
|
password,
|
||||||
'g-recaptcha-response': null,
|
'g-recaptcha-response': null,
|
||||||
'hcaptcha-response': null,
|
'hcaptcha-response': null,
|
||||||
|
'frc-captcha-solution': null,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
http-equiv="Content-Security-Policy"
|
http-equiv="Content-Security-Policy"
|
||||||
content="default-src 'self' https://newassets.hcaptcha.com/ https://challenges.cloudflare.com/ http://localhost:7493/;
|
content="default-src 'self' https://newassets.hcaptcha.com/ https://challenges.cloudflare.com/ http://localhost:7493/;
|
||||||
worker-src 'self';
|
worker-src 'self';
|
||||||
script-src 'self' 'unsafe-eval' https://*.hcaptcha.com https://challenges.cloudflare.com https://esm.sh;
|
script-src 'self' 'unsafe-eval' https://*.hcaptcha.com https://challenges.cloudflare.com https://esm.sh https://cdn.jsdelivr.net;
|
||||||
style-src 'self' 'unsafe-inline';
|
style-src 'self' 'unsafe-inline';
|
||||||
img-src 'self' data: blob: www.google.com xn--931a.moe localhost:3000 localhost:5173 127.0.0.1:5173 127.0.0.1:3000;
|
img-src 'self' data: blob: www.google.com xn--931a.moe localhost:3000 localhost:5173 127.0.0.1:5173 127.0.0.1:3000;
|
||||||
media-src 'self' localhost:3000 localhost:5173 127.0.0.1:5173 127.0.0.1:3000;
|
media-src 'self' localhost:3000 localhost:5173 127.0.0.1:5173 127.0.0.1:3000;
|
||||||
|
|
|
@ -27,9 +27,12 @@ export type Captcha = {
|
||||||
execute(id: string): void;
|
execute(id: string): void;
|
||||||
reset(id?: string): void;
|
reset(id?: string): void;
|
||||||
getResponse(id: string): string;
|
getResponse(id: string): string;
|
||||||
|
WidgetInstance(container: string | Node, options: {
|
||||||
|
readonly [_ in 'sitekey' | 'doneCallback' | 'errorCallback' | 'puzzleEndpoint']?: unknown;
|
||||||
|
}): void;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type CaptchaProvider = 'hcaptcha' | 'recaptcha' | 'turnstile' | 'mcaptcha';
|
export type CaptchaProvider = 'hcaptcha' | 'recaptcha' | 'turnstile' | 'mcaptcha' | 'fc';
|
||||||
|
|
||||||
type CaptchaContainer = {
|
type CaptchaContainer = {
|
||||||
readonly [_ in CaptchaProvider]?: Captcha;
|
readonly [_ in CaptchaProvider]?: Captcha;
|
||||||
|
@ -60,6 +63,7 @@ const variable = computed(() => {
|
||||||
case 'recaptcha': return 'grecaptcha';
|
case 'recaptcha': return 'grecaptcha';
|
||||||
case 'turnstile': return 'turnstile';
|
case 'turnstile': return 'turnstile';
|
||||||
case 'mcaptcha': return 'mcaptcha';
|
case 'mcaptcha': return 'mcaptcha';
|
||||||
|
case 'fc': return 'friendlyChallenge';
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -70,6 +74,7 @@ const src = computed(() => {
|
||||||
case 'hcaptcha': return 'https://js.hcaptcha.com/1/api.js?render=explicit&recaptchacompat=off';
|
case 'hcaptcha': return 'https://js.hcaptcha.com/1/api.js?render=explicit&recaptchacompat=off';
|
||||||
case 'recaptcha': return 'https://www.recaptcha.net/recaptcha/api.js?render=explicit';
|
case 'recaptcha': return 'https://www.recaptcha.net/recaptcha/api.js?render=explicit';
|
||||||
case 'turnstile': return 'https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit';
|
case 'turnstile': return 'https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit';
|
||||||
|
case 'fc': return 'https://cdn.jsdelivr.net/npm/friendly-challenge@0.9.18/widget.min.js';
|
||||||
case 'mcaptcha': return null;
|
case 'mcaptcha': return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -110,6 +115,14 @@ async function requestRender() {
|
||||||
key: props.sitekey,
|
key: props.sitekey,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
} else if (variable.value === 'friendlyChallenge' && captchaEl.value instanceof Element) {
|
||||||
|
new captcha.value.WidgetInstance(captchaEl.value, {
|
||||||
|
sitekey: props.sitekey,
|
||||||
|
doneCallback: callback,
|
||||||
|
errorCallback: callback,
|
||||||
|
});
|
||||||
|
// The following line is needed so that the design gets applied without it the captcha will look broken
|
||||||
|
captchaEl.value.className = 'frc-captcha';
|
||||||
} else {
|
} else {
|
||||||
window.setTimeout(requestRender, 1);
|
window.setTimeout(requestRender, 1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,6 +70,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
<MkCaptcha v-if="instance.enableMcaptcha" ref="mcaptcha" v-model="mCaptchaResponse" :class="$style.captcha" provider="mcaptcha" :sitekey="instance.mcaptchaSiteKey" :instanceUrl="instance.mcaptchaInstanceUrl"/>
|
<MkCaptcha v-if="instance.enableMcaptcha" ref="mcaptcha" v-model="mCaptchaResponse" :class="$style.captcha" provider="mcaptcha" :sitekey="instance.mcaptchaSiteKey" :instanceUrl="instance.mcaptchaInstanceUrl"/>
|
||||||
<MkCaptcha v-if="instance.enableRecaptcha" ref="recaptcha" v-model="reCaptchaResponse" :class="$style.captcha" provider="recaptcha" :sitekey="instance.recaptchaSiteKey"/>
|
<MkCaptcha v-if="instance.enableRecaptcha" ref="recaptcha" v-model="reCaptchaResponse" :class="$style.captcha" provider="recaptcha" :sitekey="instance.recaptchaSiteKey"/>
|
||||||
<MkCaptcha v-if="instance.enableTurnstile" ref="turnstile" v-model="turnstileResponse" :class="$style.captcha" provider="turnstile" :sitekey="instance.turnstileSiteKey"/>
|
<MkCaptcha v-if="instance.enableTurnstile" ref="turnstile" v-model="turnstileResponse" :class="$style.captcha" provider="turnstile" :sitekey="instance.turnstileSiteKey"/>
|
||||||
|
<MkCaptcha v-if="instance.enableFC" ref="fc" v-model="fcResponse" :class="$style.captcha" provider="fc" :sitekey="instance.fcSiteKey"/>
|
||||||
<MkButton type="submit" :disabled="shouldDisableSubmitting" large gradate rounded data-cy-signup-submit style="margin: 0 auto;">
|
<MkButton type="submit" :disabled="shouldDisableSubmitting" large gradate rounded data-cy-signup-submit style="margin: 0 auto;">
|
||||||
<template v-if="submitting">
|
<template v-if="submitting">
|
||||||
<MkLoading :em="true" :colored="false"/>
|
<MkLoading :em="true" :colored="false"/>
|
||||||
|
@ -112,6 +113,7 @@ const host = toUnicode(config.host);
|
||||||
const hcaptcha = ref<Captcha | undefined>();
|
const hcaptcha = ref<Captcha | undefined>();
|
||||||
const recaptcha = ref<Captcha | undefined>();
|
const recaptcha = ref<Captcha | undefined>();
|
||||||
const turnstile = ref<Captcha | undefined>();
|
const turnstile = ref<Captcha | undefined>();
|
||||||
|
const fc = ref<Captcha | undefined>();
|
||||||
|
|
||||||
const username = ref<string>('');
|
const username = ref<string>('');
|
||||||
const password = ref<string>('');
|
const password = ref<string>('');
|
||||||
|
@ -128,6 +130,7 @@ const hCaptchaResponse = ref<string | null>(null);
|
||||||
const mCaptchaResponse = ref<string | null>(null);
|
const mCaptchaResponse = ref<string | null>(null);
|
||||||
const reCaptchaResponse = ref<string | null>(null);
|
const reCaptchaResponse = ref<string | null>(null);
|
||||||
const turnstileResponse = ref<string | null>(null);
|
const turnstileResponse = ref<string | null>(null);
|
||||||
|
const fcResponse = ref<string | null>(null);
|
||||||
const usernameAbortController = ref<null | AbortController>(null);
|
const usernameAbortController = ref<null | AbortController>(null);
|
||||||
const emailAbortController = ref<null | AbortController>(null);
|
const emailAbortController = ref<null | AbortController>(null);
|
||||||
|
|
||||||
|
@ -137,6 +140,7 @@ const shouldDisableSubmitting = computed((): boolean => {
|
||||||
instance.enableMcaptcha && !mCaptchaResponse.value ||
|
instance.enableMcaptcha && !mCaptchaResponse.value ||
|
||||||
instance.enableRecaptcha && !reCaptchaResponse.value ||
|
instance.enableRecaptcha && !reCaptchaResponse.value ||
|
||||||
instance.enableTurnstile && !turnstileResponse.value ||
|
instance.enableTurnstile && !turnstileResponse.value ||
|
||||||
|
instance.enableFC && !fcResponse.value ||
|
||||||
instance.emailRequiredForSignup && emailState.value !== 'ok' ||
|
instance.emailRequiredForSignup && emailState.value !== 'ok' ||
|
||||||
usernameState.value !== 'ok' ||
|
usernameState.value !== 'ok' ||
|
||||||
passwordRetypeState.value !== 'match';
|
passwordRetypeState.value !== 'match';
|
||||||
|
@ -266,6 +270,7 @@ async function onSubmit(): Promise<void> {
|
||||||
'm-captcha-response': mCaptchaResponse.value,
|
'm-captcha-response': mCaptchaResponse.value,
|
||||||
'g-recaptcha-response': reCaptchaResponse.value,
|
'g-recaptcha-response': reCaptchaResponse.value,
|
||||||
'turnstile-response': turnstileResponse.value,
|
'turnstile-response': turnstileResponse.value,
|
||||||
|
'frc-captcha-solution': fcResponse.value,
|
||||||
});
|
});
|
||||||
if (instance.emailRequiredForSignup) {
|
if (instance.emailRequiredForSignup) {
|
||||||
os.alert({
|
os.alert({
|
||||||
|
@ -297,6 +302,7 @@ async function onSubmit(): Promise<void> {
|
||||||
hcaptcha.value?.reset?.();
|
hcaptcha.value?.reset?.();
|
||||||
recaptcha.value?.reset?.();
|
recaptcha.value?.reset?.();
|
||||||
turnstile.value?.reset?.();
|
turnstile.value?.reset?.();
|
||||||
|
fc.value?.reset?.();
|
||||||
|
|
||||||
os.alert({
|
os.alert({
|
||||||
type: 'error',
|
type: 'error',
|
||||||
|
|
|
@ -17,12 +17,12 @@
|
||||||
<meta
|
<meta
|
||||||
http-equiv="Content-Security-Policy"
|
http-equiv="Content-Security-Policy"
|
||||||
content="default-src 'self' https://newassets.hcaptcha.com/ https://challenges.cloudflare.com/ http://localhost:7493/;
|
content="default-src 'self' https://newassets.hcaptcha.com/ https://challenges.cloudflare.com/ http://localhost:7493/;
|
||||||
worker-src 'self';
|
worker-src 'self' blob:;
|
||||||
script-src 'self' 'unsafe-eval' https://*.hcaptcha.com https://challenges.cloudflare.com https://esm.sh;
|
script-src 'self' 'unsafe-eval' https://*.hcaptcha.com https://challenges.cloudflare.com https://esm.sh https://cdn.jsdelivr.net;
|
||||||
style-src 'self' 'unsafe-inline';
|
style-src 'self' 'unsafe-inline';
|
||||||
img-src 'self' data: blob: www.google.com xn--931a.moe localhost:3000 localhost:5173 127.0.0.1:5173 127.0.0.1:3000 activitypub.software secure.gravatar.com avatars.githubusercontent.com;
|
img-src 'self' data: blob: www.google.com xn--931a.moe localhost:3000 localhost:5173 127.0.0.1:5173 127.0.0.1:3000 activitypub.software secure.gravatar.com avatars.githubusercontent.com;
|
||||||
media-src 'self' localhost:3000 localhost:5173 127.0.0.1:5173 127.0.0.1:3000;
|
media-src 'self' localhost:3000 localhost:5173 127.0.0.1:5173 127.0.0.1:3000;
|
||||||
connect-src 'self' localhost:3000 localhost:5173 127.0.0.1:5173 127.0.0.1:3000 https://newassets.hcaptcha.com https://api.listenbrainz.org;
|
connect-src 'self' localhost:3000 localhost:5173 127.0.0.1:5173 127.0.0.1:3000 https://newassets.hcaptcha.com https://api.listenbrainz.org https://api.friendlycaptcha.com;
|
||||||
frame-src *;"
|
frame-src *;"
|
||||||
/>
|
/>
|
||||||
<meta property="og:site_name" content="[DEV BUILD] Misskey" />
|
<meta property="og:site_name" content="[DEV BUILD] Misskey" />
|
||||||
|
|
|
@ -11,6 +11,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
<template v-else-if="botProtectionForm.savedState.provider === 'mcaptcha'" #suffix>mCaptcha</template>
|
<template v-else-if="botProtectionForm.savedState.provider === 'mcaptcha'" #suffix>mCaptcha</template>
|
||||||
<template v-else-if="botProtectionForm.savedState.provider === 'recaptcha'" #suffix>reCAPTCHA</template>
|
<template v-else-if="botProtectionForm.savedState.provider === 'recaptcha'" #suffix>reCAPTCHA</template>
|
||||||
<template v-else-if="botProtectionForm.savedState.provider === 'turnstile'" #suffix>Turnstile</template>
|
<template v-else-if="botProtectionForm.savedState.provider === 'turnstile'" #suffix>Turnstile</template>
|
||||||
|
<template v-else-if="botProtectionForm.savedState.provider === 'fc'" #suffix>FriendlyCaptcha</template>
|
||||||
<template v-else #suffix>{{ i18n.ts.none }} ({{ i18n.ts.notRecommended }})</template>
|
<template v-else #suffix>{{ i18n.ts.none }} ({{ i18n.ts.notRecommended }})</template>
|
||||||
<template v-if="botProtectionForm.modified.value" #footer>
|
<template v-if="botProtectionForm.modified.value" #footer>
|
||||||
<MkFormFooter :form="botProtectionForm"/>
|
<MkFormFooter :form="botProtectionForm"/>
|
||||||
|
@ -23,6 +24,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
<option value="mcaptcha">mCaptcha</option>
|
<option value="mcaptcha">mCaptcha</option>
|
||||||
<option value="recaptcha">reCAPTCHA</option>
|
<option value="recaptcha">reCAPTCHA</option>
|
||||||
<option value="turnstile">Turnstile</option>
|
<option value="turnstile">Turnstile</option>
|
||||||
|
<option value="fc">FriendlyCaptcha</option>
|
||||||
</MkRadios>
|
</MkRadios>
|
||||||
|
|
||||||
<template v-if="botProtectionForm.state.provider === 'hcaptcha'">
|
<template v-if="botProtectionForm.state.provider === 'hcaptcha'">
|
||||||
|
@ -85,6 +87,20 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
<MkCaptcha provider="turnstile" :sitekey="botProtectionForm.state.turnstileSiteKey || '1x00000000000000000000AA'"/>
|
<MkCaptcha provider="turnstile" :sitekey="botProtectionForm.state.turnstileSiteKey || '1x00000000000000000000AA'"/>
|
||||||
</FormSlot>
|
</FormSlot>
|
||||||
</template>
|
</template>
|
||||||
|
<template v-else-if="botProtectionForm.state.provider === 'fc'">
|
||||||
|
<MkInput v-model="botProtectionForm.state.fcSiteKey">
|
||||||
|
<template #prefix><i class="ti ti-key"></i></template>
|
||||||
|
<template #label>{{ i18n.ts.hcaptchaSiteKey }}</template>
|
||||||
|
</MkInput>
|
||||||
|
<MkInput v-model="botProtectionForm.state.fcSecretKey">
|
||||||
|
<template #prefix><i class="ti ti-key"></i></template>
|
||||||
|
<template #label>{{ i18n.ts.hcaptchaSecretKey }}</template>
|
||||||
|
</MkInput>
|
||||||
|
<FormSlot>
|
||||||
|
<template #label>{{ i18n.ts.preview }}</template>
|
||||||
|
<MkCaptcha provider="fc" :sitekey="botProtectionForm.state.fcSiteKey"/>
|
||||||
|
</FormSlot>
|
||||||
|
</template>
|
||||||
</div>
|
</div>
|
||||||
</MkFolder>
|
</MkFolder>
|
||||||
</template>
|
</template>
|
||||||
|
@ -115,6 +131,8 @@ const botProtectionForm = useForm({
|
||||||
? 'turnstile'
|
? 'turnstile'
|
||||||
: meta.enableMcaptcha
|
: meta.enableMcaptcha
|
||||||
? 'mcaptcha'
|
? 'mcaptcha'
|
||||||
|
: meta.enableFC
|
||||||
|
? 'fc'
|
||||||
: null,
|
: null,
|
||||||
hcaptchaSiteKey: meta.hcaptchaSiteKey,
|
hcaptchaSiteKey: meta.hcaptchaSiteKey,
|
||||||
hcaptchaSecretKey: meta.hcaptchaSecretKey,
|
hcaptchaSecretKey: meta.hcaptchaSecretKey,
|
||||||
|
@ -125,6 +143,8 @@ const botProtectionForm = useForm({
|
||||||
recaptchaSecretKey: meta.recaptchaSecretKey,
|
recaptchaSecretKey: meta.recaptchaSecretKey,
|
||||||
turnstileSiteKey: meta.turnstileSiteKey,
|
turnstileSiteKey: meta.turnstileSiteKey,
|
||||||
turnstileSecretKey: meta.turnstileSecretKey,
|
turnstileSecretKey: meta.turnstileSecretKey,
|
||||||
|
fcSiteKey: meta.fcSiteKey,
|
||||||
|
fcSecretKey: meta.fcSecretKey,
|
||||||
}, async (state) => {
|
}, async (state) => {
|
||||||
await os.apiWithDialog('admin/update-meta', {
|
await os.apiWithDialog('admin/update-meta', {
|
||||||
enableHcaptcha: state.provider === 'hcaptcha',
|
enableHcaptcha: state.provider === 'hcaptcha',
|
||||||
|
@ -140,6 +160,9 @@ const botProtectionForm = useForm({
|
||||||
enableTurnstile: state.provider === 'turnstile',
|
enableTurnstile: state.provider === 'turnstile',
|
||||||
turnstileSiteKey: state.turnstileSiteKey,
|
turnstileSiteKey: state.turnstileSiteKey,
|
||||||
turnstileSecretKey: state.turnstileSecretKey,
|
turnstileSecretKey: state.turnstileSecretKey,
|
||||||
|
enableFC: state.provider === 'fc',
|
||||||
|
fcSiteKey: state.fcSiteKey,
|
||||||
|
fcSecretKey: state.fcSecretKey,
|
||||||
});
|
});
|
||||||
fetchInstance(true);
|
fetchInstance(true);
|
||||||
});
|
});
|
||||||
|
|
|
@ -63,7 +63,7 @@ const view = ref(null);
|
||||||
const el = ref<HTMLDivElement | null>(null);
|
const el = ref<HTMLDivElement | null>(null);
|
||||||
const pageProps = ref({});
|
const pageProps = ref({});
|
||||||
const noMaintainerInformation = computed(() => isEmpty(instance.maintainerName) || isEmpty(instance.maintainerEmail));
|
const noMaintainerInformation = computed(() => isEmpty(instance.maintainerName) || isEmpty(instance.maintainerEmail));
|
||||||
const noBotProtection = computed(() => !instance.disableRegistration && !instance.enableHcaptcha && !instance.enableRecaptcha && !instance.enableTurnstile && !instance.enableMcaptcha);
|
const noBotProtection = computed(() => !instance.disableRegistration && !instance.enableHcaptcha && !instance.enableRecaptcha && !instance.enableTurnstile && !instance.enableMcaptcha && !instance.enableFC);
|
||||||
const noEmailServer = computed(() => !instance.enableEmail);
|
const noEmailServer = computed(() => !instance.enableEmail);
|
||||||
const noInquiryUrl = computed(() => isEmpty(instance.inquiryUrl));
|
const noInquiryUrl = computed(() => isEmpty(instance.inquiryUrl));
|
||||||
const thereIsUnresolvedAbuseReport = ref(false);
|
const thereIsUnresolvedAbuseReport = ref(false);
|
||||||
|
|
|
@ -5142,6 +5142,8 @@ export type components = {
|
||||||
recaptchaSiteKey: string | null;
|
recaptchaSiteKey: string | null;
|
||||||
enableTurnstile: boolean;
|
enableTurnstile: boolean;
|
||||||
turnstileSiteKey: string | null;
|
turnstileSiteKey: string | null;
|
||||||
|
enableFC: boolean;
|
||||||
|
fcSiteKey: string | null;
|
||||||
enableAchievements: boolean | null;
|
enableAchievements: boolean | null;
|
||||||
swPublickey: string | null;
|
swPublickey: string | null;
|
||||||
/** @default /assets/ai.png */
|
/** @default /assets/ai.png */
|
||||||
|
@ -5281,6 +5283,8 @@ export type operations = {
|
||||||
recaptchaSiteKey: string | null;
|
recaptchaSiteKey: string | null;
|
||||||
enableTurnstile: boolean;
|
enableTurnstile: boolean;
|
||||||
turnstileSiteKey: string | null;
|
turnstileSiteKey: string | null;
|
||||||
|
enableFC: boolean;
|
||||||
|
fcSiteKey: string | null;
|
||||||
swPublickey: string | null;
|
swPublickey: string | null;
|
||||||
/** @default /assets/ai.png */
|
/** @default /assets/ai.png */
|
||||||
mascotImageUrl: string | null;
|
mascotImageUrl: string | null;
|
||||||
|
@ -5309,6 +5313,7 @@ export type operations = {
|
||||||
mcaptchaSecretKey: string | null;
|
mcaptchaSecretKey: string | null;
|
||||||
recaptchaSecretKey: string | null;
|
recaptchaSecretKey: string | null;
|
||||||
turnstileSecretKey: string | null;
|
turnstileSecretKey: string | null;
|
||||||
|
fcSecretKey: string | null;
|
||||||
sensitiveMediaDetection: string;
|
sensitiveMediaDetection: string;
|
||||||
sensitiveMediaDetectionSensitivity: string;
|
sensitiveMediaDetectionSensitivity: string;
|
||||||
setSensitiveFlagAutomatically: boolean;
|
setSensitiveFlagAutomatically: boolean;
|
||||||
|
@ -9891,6 +9896,9 @@ export type operations = {
|
||||||
enableTurnstile?: boolean;
|
enableTurnstile?: boolean;
|
||||||
turnstileSiteKey?: string | null;
|
turnstileSiteKey?: string | null;
|
||||||
turnstileSecretKey?: string | null;
|
turnstileSecretKey?: string | null;
|
||||||
|
enableFC?: boolean;
|
||||||
|
fcSiteKey?: string | null;
|
||||||
|
fcSecretKey?: string | null;
|
||||||
/** @enum {string} */
|
/** @enum {string} */
|
||||||
sensitiveMediaDetection?: 'none' | 'all' | 'local' | 'remote';
|
sensitiveMediaDetection?: 'none' | 'all' | 'local' | 'remote';
|
||||||
/** @enum {string} */
|
/** @enum {string} */
|
||||||
|
|
Loading…
Reference in New Issue