Skip to content
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

Replace forms with a-href links #305

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

tvdijen
Copy link
Contributor

@tvdijen tvdijen commented Nov 14, 2023

When setting a Content-Security-Policy with form-action *.<your-domain>.nl, the forms won't work in Edge/Chrome.
See this article, paragraph "Can the form-action redirect to another url?" for the reason behind this. TL;DR: Edge/Chrome does not allow the form's POST-destination to perform a redirect.
Replacing the unnecessary forms with simple links resolves this issue and allows for a stricter CSP-policy.

Previously discussed on Slack with @MKodde

@tvdijen tvdijen requested a review from MKodde November 14, 2023 11:31
Copy link
Member

@MKodde MKodde left a comment

Choose a reason for hiding this comment

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

Conceptually this makes lots of sense. Not sure about the logout button tho, or did that also trigger the same CSP error?

Given the fact we are not actually logging out, this is not a big issue in my opinion.

@@ -66,9 +66,9 @@
<h3>{{ 'ss.registration.vetting_type.title.ra_vetting'|trans }}</h3>
<hr>
<p>{{ 'ss.registration.vetting_type.description.ra_vetting'|trans }}</p>
<form action="{{ url('ss_registration_send_registration_email', {'secondFactorId': secondFactorId}) }}" method="get">
<a href="{{ url('ss_registration_send_registration_email', {'secondFactorId': secondFactorId}) }}">
<button type="submit" class="btn btn-primary">{{ 'ss.registration.vetting_type.button.ra_vetting'|trans }}</button>
Copy link
Member

Choose a reason for hiding this comment

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

This construction is not 100% yet from a html structure point of view.

I'd say: remove the <button> element but keep the button text as the anchor text for the <a> element. And style the <a> to make it look like a button. I think we already have utility (css) classes ready for that.

Would you be so kind to look into that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, I spent the entire afternoon but I can't get it to look visually the same without the button-tags. Leaving it 'as-is', but feel free to try it yourself

@@ -45,12 +45,12 @@
</div>
{% if app.user %}
<div class="clearfix page-header-user">
<form method="post" action="{{ logout_url('saml_based') }}" class="pull-right">
<a href="{{ logout_url('saml_based') }}" class="pull-right">
Copy link
Member

Choose a reason for hiding this comment

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

See previous feedback point.

@tvdijen
Copy link
Contributor Author

tvdijen commented Nov 14, 2023

Logout got me the same CSP-error yes. Our logout-url is on another domain.

@@ -45,12 +45,12 @@
</div>
{% if app.user %}
<div class="clearfix page-header-user">
<form method="post" action="{{ logout_url('saml_based') }}" class="pull-right">
<a href="{{ logout_url('saml_based') }}" class="pull-right">
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this will work because it changes the POST to a GET, and selfservice does not allow GET requests to the logout endpoint.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's cheating, because the GET-method was only removed two weeks ago ;)

Copy link
Member

Choose a reason for hiding this comment

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

Not quite, in 4.0.9 (released Jun 6, 2023) I can also not use GET for logout, it only accepts POST.

@phavekes phavekes requested a review from MKodde February 28, 2024 09:26
Copy link
Member

@thijskh thijskh left a comment

Choose a reason for hiding this comment

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

As noted in the comment, this appears to break logout when merged as-is

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