-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create a middleware to verify signatures and adminOnly #51
Comments
We might be even able to extract that middleware into a small npm package that can be used to effortlessly work with signatures on other projects. Something with an api similar to // server
import { verifySignatureMiddleware, signatureMessages } from 'easy-web3-sign/server'
// sets up everything to generate messages to sign
// Potentially receives a configurator to show a readable message plus a bunch of metadata
// that can be use to generate a specific hash to make the message to sign unique
// e.g.: "Sign to submit challenge two [hash: 23a9ef83c0233b]"
// or maybe that's not needed and the config goes into the middleware ¯\_(ツ)_/¯
app.use(signatureMessages)
app.post('/needs-signature', verifySignatureMiddleware, (req, res) => {
// ...
})
// client
import { sign } from 'easy-web3-sign/client'
// handles getting messages, showing errors, etc
<button onClick={() => sign(onSuccess, onError)} /> Definitely not something to implement as part of this project, but could be useful for moonshots in general (not sure where I should drop a suggestion like this). |
This will be needed after #29 is implemented. We'll remove the usage of JWTs, and therefore will need to verify signatures to confirm someone is admin. |
Just read some comments from the server:
Now that this is live we should probably tackle this one |
@dgrcode I don't see it critical, but could plan on taking this one over the next weeks. We are using the
Here it doesn't matter because the signature is doing the validation work.
Every one can gets this data right now, which It's not very sensitive, but I guess we don't want to expose it. I see 3 options:
I'll go with 1 or 3, depending on future functionalities. What do you think? |
I think the problem is actually on the For reading ( |
You're right. I think something like this will fix it for now: #105 Even if they guess an admin address, they won't be able to make the signature work. |
This is calling for a middleware. I envision using something like this:
That means the middleware would need to be curried:
I also showed in the snippet a way to avoid creating a different
verifyOptions
for each case, which is handy to abstract the code in a middleware. We know the required options must come from the client in the request's body, so we just pass all that to theverifySignature
call ¯\_(ツ)_/¯Given the current code works, we might want to open an enhancement issue for this.
Originally posted by @dgrcode in #48 (comment)
The text was updated successfully, but these errors were encountered: