Skip to content

AUTHLIB-178 LDAP Domain Validaiton - #98

Merged
heathharrelson merged 4 commits into
mainfrom
AUTHLIB-178
Sep 24, 2026
Merged

heathharrelson merged 4 commits into
mainfrom
AUTHLIB-178

Conversation

@saligiad

@saligiad saligiad commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Overview

Add front-end validation in authlib.js and back-end validation in UserController.java, to ensure that user emails and validated against the LDAP domain if their authentication method is set to LDAP.

Issues

AUTHLIB-178

[x] Added to CHANGELOG.md

Discussion

The diff for authlib.js looks pretty attrocious, but a lot of the changes are just shuffling blocks around to reduce redundant variables and to ensure that everything executes in the proper order. I'll leave some comments pointing out biggest changes.

Testing Responsiveness

I've tried to ensure that the front-end validation is responsive to a few different actions:

  • Switching the auth method to LDAP should immediately trigger domain validation, and switching to table-based should immediately defer back to basic validation
  • Using the LDAP search button should cause the validation to reevaluate (which should always clear the error)
  • The error message will dynamically switch between the default error message ("Email must be valid and < 320 characters"), the LDAP validation message, and a valid field state as the user changes their input

Testing Server Validation

I tested the server validation by temporarily setting domainMatches = .. || true in authlib.js, so that I could submit bad emails. The server correctly generated errors if the email didn't match, and I've updated authlib.js to populate the feedback content with the server's error message.

Screenshots

Error message

image

Add front-end validation in authlib.js and back-end validation in
UserController.java, to ensure that user emails and validated against
the LDAP domain if their authentication method is set to LDAP.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I couldn't quickly make sense of how to implement a new validator, but the ConstraintViolations were ultimately converted to FieldError's, so inserting a FieldError in this context seemed pretty safe.

Simplify logic that controls the LDAP search button, and removed a block
of commented out code.
Some changes intended for the previous commit were omitted.
Finish a half completed section of comments.
document.getElementById('last_name').value = jsonData.lastName;
document.getElementById('email').value = jsonData.email;
document.getElementById('institution').value = jsonData.institution;
document.getElementById('email').dispatchEvent(new Event('change'));

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ensures that the validation is run after the LDAP search button is used, which effectively clears the previous feedback message.

Comment on lines +404 to +407
const feedbackElement = findErrorDivForElement(inputElement);
if (feedbackElement) {
feedbackElement.textContent = serverError.dataset.message;
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updates the feedback message with server error messages.

@saligiad
saligiad marked this pull request as ready for review September 23, 2026 23:08

usernameInput.addEventListener('input', searchHandler);
}
});

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Most of the code was moved inside the onLoad handler, largely to reduce the number of redundant variable declarations across the two contexts.

@heathharrelson heathharrelson 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.

This was a bit hard to review because you combined feature development and refactoring, although it seems to work. To make things easier for your reviewers, please make separate PRs for features and refactoring, or make the changes two separate commits and call that out in the PR description.

@heathharrelson
heathharrelson merged commit 1c5fba9 into main Sep 24, 2026
2 checks passed
@heathharrelson
heathharrelson deleted the AUTHLIB-178 branch September 24, 2026 23:06
@heathharrelson
heathharrelson restored the AUTHLIB-178 branch September 24, 2026 23:44
@heathharrelson
heathharrelson deleted the AUTHLIB-178 branch September 24, 2026 23:45
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.

2 participants