pondersource / nextcloud-mfa-awareness

Make Nextcloud aware of whether the current user is logged in with Multi-Factor Authentication
MIT License
0 stars 2 forks source link

Add check in app #106

Closed michielbdejong closed 6 months ago

michielbdejong commented 6 months ago

Seeing if I can move the Workflow Engine check into the MFA Zones app to reduce the need for changes in Nextcloud Server itself.

michielbdejong commented 6 months ago

backend seems to work, now looking at frontend. As per https://github.com/nextcloud/server/pull/40235#discussion_r1438684557 maybe we can call window.OCA.WorkflowEngine.registerCheck. Will try to copy how https://github.com/nextcloud/flow_webhooks/blob/d06203fa3cc6a5dc83b6f08ab7dd82d61585d334/src/main.js#L27 does it!

michielbdejong commented 6 months ago

this.$store.getters.getChecksForEntity(this.rule.entity) is still failing. Should debug in the web console

michielbdejong commented 6 months ago

It seems I'm getting close - my JS code is being compiled with Vue and executed on page load. The problem I have now is:

Object.keys(window.OCA)
Array(10) [ "Search", "Files", "Sharing", "Trashbin", "Circles", "SystemTags", "Comments", "Viewer", "Text", "Theming" ]

So WorkflowEngine is missing from that list, despite the fact that it's being set in /var/www/html/dist/workflowengine-workflowengine.js

michielbdejong commented 6 months ago

Ah! It doesn't always get set.

michielbdejong commented 6 months ago

When on http://sunet-nc2/index.php/settings/admin/workflow the list is different:

Object.keys(window.OCA)
Array(10) [ "Search", "WorkflowEngine", "Theming" ]

But there our mfazones code is not loaded! That is only loaded in the main files view. Will dig deeper on how NC decides which app-specific JS scripts to run on which page.

michielbdejong commented 6 months ago

Ah I think I found the answer on https://docs.nextcloud.com/server/28/developer_manual/digging_deeper/flow.html

In the RegisterOperationsEvent listener we need to registere the above JS bundle.

michielbdejong commented 6 months ago

I can get it to call our Application::register function from https://github.com/nextcloud/server/blob/dc2066bc26d9d92ddceaf15f9be447a5dbffb8ca/lib/private/AppFramework/Bootstrap/Coordinator.php#L142 now, I'm pretty confident now that I can get mfazones working without patches to nextcloud/server.