I need to write a captcha service for the integration software I'm working on. After some thought, I think that I don’t quite understand how captcha works technologically (I understand how it works functionally), and therefore he was unable to make some design decisions. A few things bother me:
- Should I keep a session for each user? (i.e. remember their IP, domain, etc.)
- Should I recover a passphrase on error? (I know sites like google and digg do this)
- Each call will go to the database. I'm not sure if this will affect server performance, but I will consider using things like memcahed. But I can't think about not hitting db or cache, because you need to read first, then check, then update.
- Do I need an expiration time for captcha? say 15 minutes?
If 1 is yes, then I think the logic is getting complicated because I need to do things like: has this passphrase been verified before? does it expire? is it from the same ip? etc.
And if I need to reprogram the IP address and confirm it, after too many invalid requests, what should I do? I blocked them?
So, I think captcha should work this way, in a simple way:
A type of statelessness, which means that every failure received will only survive 2 requests, an initial request and a subsequence request. And the result will be either unsuccessful or passed. If this fails, create a new one.
I come up with someone who can make some suggestions or explain how proper captcha works. Thanks.
Update:
I need to explain a little functional requirement:
Conditions:
- The client is someone else at www
- my service includes: a captcha service and another service that a client can access through an HTTP request.
Workflow:
- the client makes a request to send the service
- captcha-service generates token, passphrase and saves in db
- a client makes an http request to intercept a webpage to receive an image
- the client sends a request for our other service and passes passphrase
- our other service will use the passphrase to check our captcha service, etc ...
Also I think if 3 is necessary. Or I just have to rent the image stream in step 2.
source share