Skip to content

Implement wopi proof keys mechanism - #416

Open
lunika wants to merge 3 commits into
mainfrom
wopi/proof_keys
Open

Implement wopi proof keys mechanism#416
lunika wants to merge 3 commits into
mainfrom
wopi/proof_keys

Conversation

@lunika

@lunika lunika commented Nov 24, 2025

Copy link
Copy Markdown
Member

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

  • ✨(wopi) save woopi client proof key in the configuration
  • ✨(wopi) add utils to validate a WOPI request signature
  • ✨(wopi) verify wopi signature in Wopi viewset

@lunika
lunika requested review from NathanVss and qbey November 24, 2025 16:50
@lunika lunika self-assigned this Nov 24, 2025
Comment on lines +46 to +56
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,
)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@NathanVss NathanVss left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! What is the intention behind the case where the old pk verifies the signature but not the current one?

Comment thread src/backend/core/tests/items/test_api_items_wopi.py Outdated
Comment thread src/backend/wopi/tasks/configure_wopi.py
Comment thread src/backend/wopi/tests/utils/test_signature.py
Comment thread src/backend/wopi/utils/signature.py Outdated
item = request.auth.item
abilities = item.get_abilities(request.user)

self._verify_request_signature(request)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ?

@sonarqubecloud

Copy link
Copy Markdown

@lunika lunika assigned kernicPanel and unassigned lunika Jul 9, 2026
@lunika

lunika commented Jul 9, 2026

Copy link
Copy Markdown
Member Author

@kernicPanel You should finish this PR, this is a missing part in the WOPI implementation.

@kernicPanel
kernicPanel force-pushed the wopi/proof_keys branch 2 times, most recently from 711080a to bca6859 Compare July 15, 2026 10:50
@kernicPanel
kernicPanel changed the base branch from main to fix/security-dependency-updates July 22, 2026 06:57
Base automatically changed from fix/security-dependency-updates to fix/dockerfile-hardening July 22, 2026 13:22
Base automatically changed from fix/dockerfile-hardening to fix/pin-collabora-image July 22, 2026 13:22
@kernicPanel
kernicPanel force-pushed the fix/pin-collabora-image branch from 651a643 to d2c1e47 Compare July 22, 2026 13:45
Base automatically changed from fix/pin-collabora-image to main July 22, 2026 13:59
@kernicPanel
kernicPanel force-pushed the wopi/proof_keys branch 2 times, most recently from 84a968e to 88aca18 Compare August 7, 2026 08:45
lunika added 3 commits August 13, 2026 09:22
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.
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants