This repository was archived by the owner on Nov 28, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
CAPTCHA #5
Draft
nicholasngai
wants to merge
37
commits into
Cal-CS-61A-Staff:master
Choose a base branch
from
nicholasngai:captcha
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
CAPTCHA #5
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Hi Nicholas, Wow, this looks awesome so far! One thing to be aware of is that we are submitting Cats to SIGCSE, so I'd like to keep cats.cs61a.org in its current known-stable state, rather than risk breaking submitted files. I'll merge all your PRs in at some point in the future, though, certainly before we use the project against next semester! Thanks once again for all your contributions! After 61A, if you ever want to work on 61A software development for the OH queue, 61A Code, or any of the other course tools in this repo, just let me know! |
Cool! It’d be good to have some more pairs of eyes on the PRs before it gets merged, though, since I’m new to all the languages the CATS project uses except for vanilla JavaScript. |
Merged
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I’ve been playing around with the Claptcha library in Python and created a rough prototype of what a CAPTCHA thing could look like. It’s built on top of the #2 PR, so it adds an additional token that’s needed above 100 WPM before the leaderboard posting will go through.
This token is actually stored as a cookie so that it’s persistent across sessions (and has a maximum age of 24 hours), and the client will automatically prompt to complete a CAPTCHA upon receiving a flag for the server along with the
wpm_token
, which will only work in conjunction with the cookie.The CAPTCHA works by generating a specified number of CAPTCHA images on the server and sending it to the client along with a CAPTCHA token which is just a Fernet-encrypted copy of the text (so the client won’t be able to read it). This token is timestamped, so when the client sends the token and the typed text back to the server, the server calculates the CAPTCHA’s WPM based on the server’s current time and the timestamp of the token, so it can’t be modified by the client. If the accuracy of the words is greater than 80%, the client receives another token as a
Set-Cookie
header, which is the user’s “verified” WPM encrypted under Fernet. This “verified” WPM is just the server’s calculated WPM scaled by 1.5 to account for random variation and the more-difficult-to-read words as well as network latency.Since it’s a cookie, it will automatically be sent to the server for
/record_wpm
and will persist across sessions, and the server will verify bothwpm_token
(to ensure the WPM was validly sent by the server) and the verification token (to ensure that the user is truly able to type that fast).There are still a couple things that need to be worked on, such as pre-generating the images to reduce CAPTCHA request latency and polishing the actual CAPTCHA dialog, but I figured I’d get this out there first so you can take a look.
Also, I am new to React and JSX, so bear with me if the code is a little odd. Feel free to make changes to it.
Finally, I would avoid merging this until the other PRs (namely #1 and #2) are merged, since this builds on top of that.