
Security News
Crates.io Users Targeted by Phishing Emails
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
@celastrina/captcha
Advanced tools
@celastrina/captcha is a CAPTCHA add-on for @celastrina/http. @celastrina/captcha comes out-of-the-box with full support for Google reCAPTCHA v2 and v3.
Fundamentally, @celastrina/captcha integrates with the core Sentry by adding a new Authenticator which takes a captcha token and attempts to authenticate a caller as "human". Upon success, the caller will be enrolled in a role you configure, to which, the services you want protected can be secured with that role using a Permission.
The following example code creates a v3 Google reCAPTCHA instance:
const {LOG_LEVEL, CelastrinaError, Configuration, Permission} = require(“@celastrina/core”);
const {HTTPAddOn, JSONHTTPContext, JSONHTTPFunction} = require(“@celastrina/http”);
const {CaptchaAddOn, GoogleReCaptchaActionV3} = require(“@celastrina/captcha”);
class MyFirstFunction extends JSONHTTPFunction {
constructor(config) {
super(config);
}
async get(context) {
context.log(“This can only be reached by a human!”, LOG_LEVEL.INFO, “MyFirstFunction._get(context)”);
context.send({name: “sample”, message: "Welcome human person."}); // Return whatever object you’d like
}
}
const _config = new Configuration(“MyFirstFunction”);
const _httpconfig = new HTTPAddOn();
const _captchaconfig = new CaptchaAddOn();
_config.addOn(_httpconfig);
_config.addOn(_captchaconfig);
_captchaconfig.captch = new GoogleReCaptchaActionV3("your_google_site_secret");
_config.permissions.addPermission(new Permission("get", ["human"], new MatchAny()));
module.exports = new MyFirstFunction (_config);
The above code secures the HTTP GET method for this function with a role named "human". The "human" role is a default role assigned by the CaptchaAddOn. The GoogleReCaptchaActionV3 defaults to an acceptability score of .8 or better and defaults to no google actions. All the attributes are configurable to meet your needs.
WARNING: The code example above has a secret in code/configuration, please do not do this. Either load from a secure App Setting or preferably use core JSON configuration and Azure Key Vault.
@celastrina/captcha introduces a new configuration type when using JSON based configuration:
{
"configurations": [
{
"$object": {"contentType": "application/vnd.celastrinajs.config+json;Captcha"},
"captcha": {
"$object": {"contentType": "application/vnd.celastrinajs.attribute+json;GoogleReCaptcha"},
"version": "v2",
"secret" : "some_secret_value",
"url": "https://www.google.com/recaptcha/api/siteverify",
"timeout": 5000,
"parameter": {"$object": {"contentType": "application/vnd.celastrinajs.attribute+json;HTTPParameter"},
"parameter": "header"},
"name": "x-celastrinajs-captcha-token",
"assumeHumanOnTimeout": true
},
"assignments": ["human"]
}
]
}
{
"configurations": [
{
"$object": {"contentType": "application/vnd.celastrinajs.config+json;Captcha"},
"captcha": {
"$object": {"contentType": "application/vnd.celastrinajs.attribute+json;GoogleReCaptcha"},
"version": "v3",
"secret" : "some_secret_value",
"url": "https://www.google.com/recaptcha/api/siteverify",
"timeout": 5000,
"parameter": {"$object": {"contentType": "application/vnd.celastrinajs.attribute+json;HTTPParameter"},
"parameter": "header"},
"name": "x-celastrinajs-captcha-token",
"score": .75,
"actions": ["some_google_captcha_action"],
"assumeHumanOnTimeout": true
},
"assignments": ["human"]
}
]
}
This module depends on Celastrina Add-On @celastrina/http.
For more information please visit @celastrina/captcha wiki on Github.
FAQs
Captcha Functions for Celastrina HTTP Add-On.
We found that @celastrina/captcha demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.