mirror of
https://github.com/HeyPuter/puter.git
synced 2026-05-03 16:10:31 +00:00
feat: record signup metadata for abuse prevention
Docker Image CI / build-and-push-image (push) Waiting to run
Maintain Release Merge PR / update-release-pr (push) Waiting to run
release-please / release-please (push) Waiting to run
test / test (18.x) (push) Waiting to run
test / test (20.x) (push) Waiting to run
test / test (22.x) (push) Waiting to run
Docker Image CI / build-and-push-image (push) Waiting to run
Maintain Release Merge PR / update-release-pr (push) Waiting to run
release-please / release-please (push) Waiting to run
test / test (18.x) (push) Waiting to run
test / test (20.x) (push) Waiting to run
test / test (22.x) (push) Waiting to run
This commit is contained in:
@@ -207,7 +207,14 @@ module.exports = eggspress(['/signup'], {
|
||||
if(pseudo_user === undefined){
|
||||
insert_res = await db.write(
|
||||
`INSERT INTO user
|
||||
(username, email, clean_email, password, uuid, referrer, email_confirm_code, email_confirm_token, free_storage, referred_by, audit_metadata) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
||||
(
|
||||
username, email, clean_email, password, uuid, referrer,
|
||||
email_confirm_code, email_confirm_token, free_storage,
|
||||
referred_by, audit_metadata, signup_ip, signup_ip_forwarded,
|
||||
signup_user_agent, signup_origin, signup_server
|
||||
)
|
||||
VALUES
|
||||
(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
||||
[
|
||||
// username
|
||||
req.body.username,
|
||||
@@ -231,7 +238,18 @@ module.exports = eggspress(['/signup'], {
|
||||
referred_by_user ? referred_by_user.id : null,
|
||||
// audit_metadata
|
||||
JSON.stringify(audit_metadata),
|
||||
]);
|
||||
// signup_ip
|
||||
req.connection.remoteAddress,
|
||||
// signup_ip_fwd
|
||||
req.headers['x-forwarded-for'],
|
||||
// signup_user_agent
|
||||
req.headers['user-agent'],
|
||||
// signup_origin
|
||||
req.headers['origin'],
|
||||
// signup_server
|
||||
config.server_id,
|
||||
]
|
||||
);
|
||||
|
||||
// record activity
|
||||
db.write(
|
||||
|
||||
@@ -138,6 +138,9 @@ class SqliteDatabaseAccessService extends BaseDatabaseAccessService {
|
||||
[28, [
|
||||
'0031_audit-meta.sql',
|
||||
]],
|
||||
[29, [
|
||||
'0032_signup_metadata.sql',
|
||||
]],
|
||||
];
|
||||
|
||||
// Database upgrade logic
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
-- Store IP and request data as TEXT (for JSON strings)
|
||||
ALTER TABLE `user` ADD COLUMN `signup_ip` TEXT DEFAULT NULL;
|
||||
ALTER TABLE `user` ADD COLUMN `signup_ip_forwarded` TEXT DEFAULT NULL;
|
||||
ALTER TABLE `user` ADD COLUMN `signup_user_agent` TEXT DEFAULT NULL;
|
||||
ALTER TABLE `user` ADD COLUMN `signup_origin` TEXT DEFAULT NULL;
|
||||
ALTER TABLE `user` ADD COLUMN `signup_server` TEXT DEFAULT NULL;
|
||||
|
||||
-- Add indexes for columns likely to be searched
|
||||
CREATE INDEX idx_user_signup_ip ON user(signup_ip);
|
||||
CREATE INDEX idx_user_signup_ip_forwarded ON user(signup_ip_forwarded);
|
||||
CREATE INDEX idx_user_signup_user_agent ON user(signup_user_agent);
|
||||
CREATE INDEX idx_user_signup_origin ON user(signup_origin);
|
||||
CREATE INDEX idx_user_signup_server ON user(signup_server);
|
||||
Reference in New Issue
Block a user