Skip to content

Consolidate SAML/OIDC redirect JavaScript#9985

Merged
aduth merged 6 commits intomainfrom
aduth-saml-oidc-redirect
Jan 30, 2024
Merged

Consolidate SAML/OIDC redirect JavaScript#9985
aduth merged 6 commits intomainfrom
aduth-saml-oidc-redirect

Conversation

@aduth
Copy link
Contributor

@aduth aduth commented Jan 26, 2024

🛠 Summary of changes

Consolidates openid-connect-redirect.ts and saml-post.js packs to a single click-immediate.ts which immediately clicks any elements annotated with a data-click-immediate attribute.

Why?

  • The intended behavior of these scripts is essentially the same
  • Remove legacy, non-typechecked JavaScript code
  • Smaller file size
  • Avoid announcing screen reader text for text which would not be visible for a JavaScript-enabled device

📜 Testing Plan

Using SAML & OIDC sample applications, verify there are no regressions in signing-in and redirecting back to the partner application.

Repeat testing instructions from #9790 to verify behavior of client-side OIDC redirect.

changelog: Internal, Code Quality, Consolidate redirect logic for SAML/OIDC
@@ -1,13 +1,16 @@
<!DOCTYPE html>
<html>
<html class="no-js">
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It'd be nice to have a base-ier base template that we could extend, to avoid having to bring in these individual elements.

There's probably some other features from the base template we want here too, like the lang attribute, some of the meta tags, etc.

Comment on lines 26 to 28
<% if params.key?(:RelayState) %>
<%= hidden_field_tag('RelayState', params[:RelayState]) %>
<% end %>
Copy link
Contributor

Choose a reason for hiding this comment

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

could we reuse saml_post_form.html.erb here and pass in :RelayState as form_params?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

could we reuse saml_post_form.html.erb here and pass in :RelayState as form_params?

Maybe! I can check

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There was some prior discussion about this approach with a general leaning toward the duplication? Not sure I'd totally agree, but might save this for a separate effort.

https://github.com/18F/identity-idp/pull/5624/files#r753741166

@aduth
Copy link
Contributor Author

aduth commented Jan 29, 2024

Very strangely the spec failures have something to do with <html class="no-js"> in saml_post_binding.html.erb. The tests pass when the class attribute is removed. I'll take a closer look tomorrow.

@aduth
Copy link
Contributor Author

aduth commented Jan 30, 2024

Very strangely the spec failures have something to do with <html class="no-js"> in saml_post_binding.html.erb. The tests pass when the class attribute is removed. I'll take a closer look tomorrow.

This turned out to be caused by a spec helper looking specifically for an HTML opening tag without any attributes.

elsif @response.body.include?('<html>')

This was made more flexible in cf1c923, to allow for the new class attribute.

@aduth aduth merged commit da1311e into main Jan 30, 2024
@aduth aduth deleted the aduth-saml-oidc-redirect branch January 30, 2024 17:36
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