Skip to content

Commit 6c791b1

Browse files
committed
messy code, but it works
1 parent a56603e commit 6c791b1

18 files changed

+1359
-307
lines changed

README.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Simple create a page rule:
2121

2222
The service is split up into different subdomains to make securing and serving it from different services and levels easier. webfinger.io currently relies upon email based confirmation of a normalized email address (e.g. we remove +stuff and dots) which provides strong proof of control. We do not currently confirm Mastodon ID's are owned by the user, this is planned for the future
2323

24-
### register
24+
### registration
2525

2626
webfinger.io frontpage and entry form, passes POST request to processing
2727

@@ -31,8 +31,12 @@ processing script for entry form, takes POST request, checks if email Block is o
3131

3232
### confirmation
3333

34-
confirmation script takes GET request with action, email, key and optional Mastodon ID (if registering one), presents user with a confirmation screen, if they hit submit it sends a POST request to itself and does the action specified and clears the auth record
34+
confirmation script takes a GET request with action, email, key and optional Mastodon ID (if registering one) for email processing, presents user with a confirmation screen, if they hit submit it sends a POST request to itself and does the action specified and clears the auth record. Also handles POST requests directly for social media via the verification API.
3535

3636
### webfinger
3737

3838
webfinger script that serves requests from KV store, please note it normalizes outgoing emails and Mastodon ID's for safety and reliability
39+
40+
## Validation API
41+
42+
PHP script to run the validation (is Mastodon ID X in web page Y basically)

assets/mastodon-validation.png

19.5 KB
Loading

docs.webfinger.io/SETUP.MD

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Webfinger
2+
3+
You'll need a Cloudflare account with workers and two KV stores (one for auth and one for prod).
4+
5+
# API Validation Server
6+
7+
This is currently a PHP script and some custom scripts to start the VPN/etc. Long term it will be containerized to ease setup.
8+
9+
# Email
10+
11+
See DKIM-setup.md

docs.webfinger.io/TODO.md

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# TODO
2+

webservice/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "webservice",
3-
"version": "0.0.0",
3+
"version": "0.1.0",
44
"devDependencies": {
55
"wrangler": "2.1.10"
66
},

webservice/src/emailContentProcessing.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ If you have any concerns or questions just hit reply to contact our admin help.
5757

5858
email_content["footer"] = `
5959
\n\n
60-
` + globalDomain + ` is a Cloud Security Alliance (https://cloudsecurityalliance.org/) Research beta.
60+
` + globalDomain + ` is a Cloud Security Alliance (https://cloudsecurityalliance.org/) Research project.
6161
The Cloud Security Alliance is a not-for-profit organization promoting best practices for
6262
providing security assurance within Cloud Computing. We are also working on various projects
6363
within the Blockchain and Fediverse ecosystems. The Cloud Security Alliance privacy policy is available at:

webservice/src/htmlContentConfirmation.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export function gethtmlContentConfirmation(status, data) {
1515
<html lang="en">
1616
<head>
1717
<meta charset="utf-8">
18-
<title>webfinger.io (a Cloud Security Alliance Research beta)</title>
18+
<title>webfinger.io (a Cloud Security Alliance Research project)</title>
1919
<meta name="viewport" content="width=device-width, initial-scale=1.0">
2020
<link rel="icon" href="https://assetswebfingerio.pages.dev/favicon.ico"/>
2121
<link rel="stylesheet" href="https://assetswebfingerio.pages.dev/fonts.googleapis.com-css-family-Roboto-300-300italic-700-700italic.txt"/>
@@ -26,7 +26,7 @@ export function gethtmlContentConfirmation(status, data) {
2626
<body>
2727
<main>
2828
<section class="container" id="registration">
29-
<h1>webfinger.io is a <a href="https://cloudsecurityalliance.org/">Cloud Security Alliance</a> Research beta</h1>
29+
<h3>webfinger.io is a <a href="https://cloudsecurityalliance.org/">Cloud Security Alliance</a> Research project</h3>
3030
`
3131

3232
html_content_reply["echovariables"] = `
@@ -64,7 +64,7 @@ Please check that your email and Mastodon ID were entered correctly.</p>
6464
`;
6565

6666
html_content_reply["link_mastodon_id"] = `
67-
<p>We have processed your request to link MASTODON_ID to EMAIL_ADDRESS.</p>
67+
<p>We have processed your request to link MASTODON_ID to <a href="https://webfinger.io/EMAIL_ADDRESS">EMAIL_ADDRESS</a>. You can test it by clicking on your email address</p>
6868
6969
<p>The Cloud Security Alliance privacy policy is available
7070
<a href="https://cloudsecurityalliance.org/legal/privacy-notice/">here</a>.</p>

webservice/src/htmlContentProcessing.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export function gethtmlContentProcessing(status, data) {
99
<html lang="en">
1010
<head>
1111
<meta charset="utf-8">
12-
<title>webfinger.io (a Cloud Security Alliance Research beta)</title>
12+
<title>webfinger.io (a Cloud Security Alliance Research project)</title>
1313
<meta name="viewport" content="width=device-width, initial-scale=1.0">
1414
<link rel="icon" href="https://assetswebfingerio.pages.dev/favicon.ico"/>
1515
<link rel="stylesheet" href="https://assetswebfingerio.pages.dev/fonts.googleapis.com-css-family-Roboto-300-300italic-700-700italic.txt"/>
@@ -20,7 +20,7 @@ export function gethtmlContentProcessing(status, data) {
2020
<body>
2121
<main>
2222
<section class="container" id="registration">
23-
<h1>webfinger.io is a <a href="https://cloudsecurityalliance.org/">Cloud Security Alliance</a> Research beta</h1>
23+
<h3>webfinger.io is a <a href="https://cloudsecurityalliance.org/">Cloud Security Alliance</a> Research project</h3>
2424
2525
`
2626

@@ -62,6 +62,7 @@ export function gethtmlContentProcessing(status, data) {
6262
</body>
6363
</html>
6464
`;
65+
6566
html_content["delete_record"] = `
6667
<p>We have processed your request to delete the record for EMAIL_ADDRESS, you should check for
6768
an email shortly, please check your spam folders if it doesn't show up. It will be valid
+143
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
// filename: ./src/htmlContentProcessingNew.js
2+
3+
export function gethtmlContentProcessingNew(processing_results, data) {
4+
// check processing_results and generate the HTML
5+
// then process the variables via data
6+
7+
html_content = {};
8+
9+
html_content["header"] = `
10+
<!DOCTYPE html>
11+
<html lang="en">
12+
<head>
13+
<meta charset="utf-8">
14+
<title>webfinger.io (a Cloud Security Alliance Research project)</title>
15+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
16+
<link rel="icon" href="https://assetswebfingerio.pages.dev/favicon.ico"/>
17+
<link rel="stylesheet" href="https://assetswebfingerio.pages.dev/fonts.googleapis.com-css-family-Roboto-300-300italic-700-700italic.txt"/>
18+
<link rel="stylesheet" href="https://assetswebfingerio.pages.dev/normalize.css"/>
19+
<link rel="stylesheet" href="https://assetswebfingerio.pages.dev/milligram.min.css"/>
20+
<link rel="stylesheet" href="https://assetswebfingerio.pages.dev/main.css"/>
21+
</head>
22+
<body>
23+
<main>
24+
<section class="container" id="registration">
25+
<h3>webfinger.io is a <a href="https://cloudsecurityalliance.org/">Cloud Security Alliance</a> Research project</h3>
26+
27+
`
28+
29+
html_content["badinput"] = `
30+
<p>We cannot process your request at this time, please try again later.
31+
Please check that your email and Mastodon ID were entered correctly.</p>
32+
`;
33+
34+
html_content["link_mastodon_id_email"] = `
35+
<p>We have processed your request to link MASTODON_ID to EMAIL_ADDRESS, you should check
36+
for an email shortly, please check your spam folders if it doesn't show up.
37+
It will be valid for one hour, and then the link expires.</p>
38+
`;
39+
40+
html_content["link_mastodon_id_social"] = `
41+
<p>We have processed your request to link MASTODON_ID to SOCIAL_ID (please wait about 10 seconds and then click to ensure it works, you should see a success and a link to your GitHub profile). </p>
42+
`;
43+
44+
html_content["block_email"] = `
45+
<p>We have processed your request to unsubscribe and block any more email to EMAIL_ADDRESS.
46+
In order to prevent abuse we've sent an email with a confirmation link,
47+
please check your spam folders if it doesn't show up. It will be valid
48+
for one hour, and then the link expires.</p>
49+
`;
50+
51+
html_content["delete_record"] = `
52+
<p>We have processed your request to delete the record for SOCIAL_ID, you should check for
53+
an email shortly, please check your spam folders if it doesn't show up. It will be valid
54+
for one hour, and then the link expires.</p>
55+
`;
56+
57+
html_content["footer"] = `
58+
<p>The Cloud Security Alliance privacy policy is available
59+
<a href="https://cloudsecurityalliance.org/legal/privacy-notice/">here</a>.</p>
60+
</section>
61+
62+
</body>
63+
</html>
64+
`;
65+
66+
67+
68+
new_content = html_content["header"];
69+
70+
// Email processing
71+
72+
if (processing_results["email_address"]){
73+
if (processing_results["email_address"] == "SUCCESS:LINK_MASTODON_ID") {
74+
new_content = new_content + html_content["link_mastodon_id_email"];
75+
}
76+
else if (processing_results["email_address"] == "SUCCESS:BLOCK_EMAIL") {
77+
new_content = new_content + html_content["block_email"];
78+
}
79+
else if (processing_results["email_address"] == "SUCCESS:DELETE_RECORD") {
80+
new_content = new_content + html_content["delete_record"];
81+
}
82+
// replacements go later since email is special
83+
}
84+
85+
86+
// Twitter processing
87+
if (processing_results["twitter_id"]){
88+
if (processing_results["twitter_id"] == "SUCCESS:LINK_MASTODON_ID") {
89+
new_content = new_content + html_content["link_mastodon_id_social"];
90+
}
91+
else if (processing_results["twitter_id"] == "SUCCESS:DELETE_RECORD") {
92+
new_content = new_content + html_content["delete_record"];
93+
}
94+
new_content = new_content.replace(/SOCIAL_ID/g, "<a target=\"_blank\" href=\"https://webfinger.io/@TWITTER_ID\">https://webfinger.io/@TWITTER_ID</a>");
95+
}
96+
97+
// GitHub processing
98+
if (processing_results["github_id"]){
99+
if (processing_results["github_id"] == "SUCCESS:LINK_MASTODON_ID") {
100+
new_content = new_content + html_content["link_mastodon_id_social"];
101+
}
102+
else if (processing_results["github_id"] == "SUCCESS:DELETE_RECORD") {
103+
new_content = new_content + html_content["delete_record"];
104+
}
105+
new_content = new_content.replace(/SOCIAL_ID/g, "<a target=\"_blank\" href=\"https://webfinger.io/github/GITHUB_ID\">https://webfinger.io/github/GITHUB_ID</a>");
106+
}
107+
108+
// Reddit processing
109+
if (processing_results["reddit_id"]){
110+
if (processing_results["reddit_id"] == "SUCCESS:LINK_MASTODON_ID") {
111+
new_content = new_content + html_content["link_mastodon_id_social"];
112+
}
113+
else if (processing_results["reddit_id"] == "SUCCESS:DELETE_RECORD") {
114+
new_content = new_content + html_content["delete_record"];
115+
}
116+
new_content = new_content.replace(/SOCIAL_ID/g, "<a target=\"_blank\" href=\"https://webfinger.io/u/REDDIT_ID\">https://webfinger.io/u/REDDIT_ID</a>");
117+
}
118+
119+
// Add footer
120+
new_content = new_content + html_content["footer"];
121+
122+
// replacements of ID's, tokens, etc.
123+
if (data["mastodon_id"]) {
124+
new_content = new_content.replace(/MASTODON_ID/g, data["mastodon_id"]);
125+
}
126+
if (data["token"]) {
127+
new_content = new_content.replace(/TOKEN/g, data["token"]);
128+
}
129+
if (data["email_address"]) {
130+
new_content = new_content.replace(/EMAIL_ADDRESS/g, data["email_address"]);
131+
}
132+
if (data["twitter_id"]) {
133+
new_content = new_content.replace(/TWITTER_ID/g, data["twitter_id"]);
134+
}
135+
if (data["github_id"]) {
136+
new_content = new_content.replace(/GITHUB_ID/g, data["github_id"]);
137+
}
138+
if (data["reddit_id"]) {
139+
new_content = new_content.replace(/REDDIT_ID/g, data["reddit_id"]);
140+
}
141+
return new_content;
142+
143+
}

0 commit comments

Comments
 (0)