Implement wopi proof keys mechanism - #416
Conversation
| def build_rsa_public_key(modulus, exponent): | ||
| """Build RSA public key from modulus and exponent.""" | ||
| mod = int(b64decode(modulus).hex(), 16) | ||
| exp = int(b64decode(exponent).hex(), 16) | ||
|
|
||
| rsa_public_key = RSAPublicNumbers(exp, mod).public_key() | ||
|
|
||
| return rsa_public_key.public_bytes( | ||
| encoding=serialization.Encoding.PEM, | ||
| format=serialization.PublicFormat.SubjectPublicKeyInfo, | ||
| ) |
There was a problem hiding this comment.
Here I hesitate a lot between saving the modulus and exponent in redis and rebuild the key each time I need it or save it in a PEM format. PEM format take much more space and I don't know if it's faster to load a public key in PEM format or build it from its exponent and modulus
6980bf8 to
2b0bac1
Compare
NathanVss
left a comment
There was a problem hiding this comment.
LGTM! What is the intention behind the case where the old pk verifies the signature but not the current one?
| item = request.auth.item | ||
| abilities = item.get_abilities(request.user) | ||
|
|
||
| self._verify_request_signature(request) |
There was a problem hiding this comment.
I can see that this call is made on only few actions, why ? Is it because the standard only expect some actions to be signed ?
2b0bac1 to
9b88584
Compare
|
|
@kernicPanel You should finish this PR, this is a missing part in the WOPI implementation. |
711080a to
bca6859
Compare
bca6859 to
2d98857
Compare
2d98857 to
08bfcac
Compare
651a643 to
d2c1e47
Compare
84a968e to
88aca18
Compare
The proof-key feature is not yet implemented. The first step is to save the proof-key given by the client in its discovery document.
in order to validate a WOPI signature, if the client has defined proof keys, we need several tools to implement the algo defined in this [documentation][1] [1]: https://learn.microsoft.com/en-us/microsoft-365/ cloud-storage-partner-program/online/scenarios/proofkeys
We can now implement the logic to verify a wopi request signature. If a wopi configuration have proof keys then the request must provide a signature and a valid timestamp.
88aca18 to
8a0dd2a
Compare
|



Purpose
The wopi specs provide a documentation explaining how to verify that a wopi request provides from a trusted wopi client.
This documentation is available here https://learn.microsoft.com/en-us/microsoft-365/cloud-storage-partner-program/online/scenarios/proofkeys
We have first to save wopi proof keys if present in the discovery xml than use them to validate the signature provided in the request.
Proposal