Skip to content

[GOVCMS-13132] Allow SAML assets in Nginx rules.#512

Open
barbun wants to merge 6 commits intogovCMS:3.x-developfrom
barbun:bugfix/saml-assets-nginx
Open

[GOVCMS-13132] Allow SAML assets in Nginx rules.#512
barbun wants to merge 6 commits intogovCMS:3.x-developfrom
barbun:bugfix/saml-assets-nginx

Conversation

@barbun
Copy link
Contributor

@barbun barbun commented Nov 7, 2025

Issue

Current Nginx rules are very narrow and do not allow assets from SimpleSAMLphp library to be loaded. These assets are needed when e.g. using HTTP-POST binding that creates an intermediary page with a form to ensure that the form gets auto-submitted. When missing, the users get stuck on that intermediary page having to manually submit the form.

Proposed solution

Open up the Nginx rules to allow public/assets/ path from simplesamlphp library. That path is meant to be public by design and does not include any php or secrets but only some fonts, js and css.

@barbun barbun changed the title [GOVCMS-13132] Adjusted logic for SLO bindings. [GOVCMS-13132] Allow SAML assets in Nginx rules. Nov 18, 2025
@mingsong-hu
Copy link
Contributor

Hi @barbun, thanks for raising this question and for the PR.

The way SimpleSAMLphp deploys public assets is a bit unusual. The public/assets directory in the main repository is just an empty placeholder (see: https://github.com/simplesamlphp/simplesamlphp/tree/master/public/assets). Instead of shipping assets directly, SimpleSAMLphp relies on a Composer plugin called composer-module-installer to install “asset modules” that contain the pre-built JS/CSS files.
Documentation: https://github.com/simplesamlphp/composer-module-installer?tab=readme-ov-file#assets-modules

For example, the simplesamlphp-assets-base package (https://github.com/simplesamlphp/simplesamlphp-assets-base) contains the core assets. This means that in order for assets to be deployed into public/assets/, the composer-module-installer plugin must be enabled. If the plugin is disabled, no asset (JS or CSS files) will be installed.

For security reasons, GovCMS explicitly disables the composer-module-installer plugin (see: https://github.com/govCMS/lagoon/blob/3.x-develop/composer.json#L44). So even if we loosen the Nginx rules as this PR proposed, the required JS and CSS for the post form still won’t exist in the file system, because the asset modules were never installed.

@barbun
Copy link
Contributor Author

barbun commented Nov 18, 2025

hi @drupal-spider

That's right, I should have mentioned that the below PR needs to be merged in for this rule to have a meaningful effect:
govCMS/GovCMS#1723

My security assessment did not indicate any harm in allowing simplesamlphp to use composer-module-installer. If that is not acceptable, then simplesamlphp-assets-base package could be explicitly added via composer.json.

@cb-govcms
Copy link
Contributor

@barbun simplesaml plugin was previously set to true. Can you comment why it got disabled? b87e73f

@barbun
Copy link
Contributor Author

barbun commented Feb 27, 2026

@cb-govcms The SSO work I did was based on @mingsong-hu work, and I believe that particular change was adopted from this commit:
23fe6c8

@mingsong-hu
Copy link
Contributor

mingsong-hu commented Feb 28, 2026

@barbun , As discussed, I created another PR (#532) to achieve the goal via a different approach, instead of govCMS/GovCMS#1723

In terms of this PR, as discussed, I would suggest narrowing down what JS files explicitly required by the HTTP-POST binding login.

@barbun
Copy link
Contributor Author

barbun commented Mar 2, 2026

Hi @mingsong-hu thanks for the update. I have now updated the Nginx rules to only allow one JS file that should be sufficient for ensuring seamless flow with HTTP-POST.

@mingsong-hu
Copy link
Contributor

mingsong-hu commented Mar 2, 2026

Thanks @barbun for your update. I wonder if we need to include other asset types as well, such as CSS and font?

@barbun
Copy link
Contributor Author

barbun commented Mar 2, 2026

hi @mingsong-hu my tests showed that it isn't required to ensure the auto-submit functionality. However, it means that the intermediary page will not be styled. If the auto-submit happens quickly then the exposure to the raw page is almost un-noticeable. If I remember correctly, the current customer in question that uses HTTP-POST only had the JS file added, which was sufficient for them.

alias /app/vendor/simplesamlphp/simplesamlphp/public/assets/base/js/post.js;
access_log off;
expires 1h;
add_header Cache-Control "public";
Copy link
Contributor

Choose a reason for hiding this comment

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

Mostly, it looks good to me. I wonder if we need to add the header of 'public' here. That will prevent the inheritance of all headers directives from parent blocks, such as X-Content-Type-Options, X-Frame-Options, Content-Security-Policy, etc for this JS file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mingsong-hu fair point, I've removed that line now.

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