Skip to content

bynt-1364: implement username and email validation for user endpoints#126

Merged
tarekio merged 25 commits intomainfrom
bynt-1364-username-email-validation
Aug 8, 2025
Merged

bynt-1364: implement username and email validation for user endpoints#126
tarekio merged 25 commits intomainfrom
bynt-1364-username-email-validation

Conversation

@cango91
Copy link
Contributor

@cango91 cango91 commented Jul 2, 2025

Jira Issue

  1. BYNT-1364

Description

  • Add Unicode-aware username validation (letters, numbers, underscore, hyphen)
  • Add email validation with IDN support using email-validator
  • Enhance Pydantic models with field validators for username (4- 255 32 chars) and email
  • Remove manual validation from controllers, centralize in validation utils and validation models

Checklist

  • Tests added/updated
  • Documentation updated (if needed)
  • New strings prepared for translations

API Changes (if applicable)

  • Permissions checked
  • Endpoint tests added

Additional Notes

[Any other relevant information]

cango91 and others added 4 commits June 20, 2025 21:19
…or WebAuthn device names. Addresses XSS concerns by rejecting HTML tags/entities instead of cleaning them, providing clear user feedback.
- Add Unicode-aware username validation (letters, numbers, underscore, hyphen)
- Add email validation with IDN support using email-validator
- Enhance Pydantic models with field validators for username (4-255 chars) and email
- Remove manual validation from controllers, centralize in validation utils
@cango91 cango91 requested a review from tarekio July 2, 2025 14:15
Base automatically changed from sanitize-webauthn-name to main July 2, 2025 14:47
@cango91 cango91 self-assigned this Jul 4, 2025
@tarekio tarekio requested a review from level09 July 7, 2025 18:33
cango91 added 3 commits July 10, 2025 16:38
- Refactor username validation to use plain text field validation utility (reduces code complexity/indirections)
- Remove tests that were testing pydantic itself.
@cango91 cango91 requested a review from level09 July 10, 2025 21:46
Copy link
Contributor

@tarekio tarekio left a comment

Choose a reason for hiding this comment

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

Some comments

## Jira Issue
1. [1385](https://syriajustice.atlassian.net/browse/BYNT-1385)

## Description
Add vuetify form validations to create/edit users form, display server
errors next to inputs, and conditionally show snack messages

## Checklist
- [ ] Tests added/updated
- [ ] Documentation updated (if needed)
- [ ] New strings prepared for translations

## API Changes (if applicable)
- [ ] Permissions checked
- [ ] Endpoint tests added

## Additional Notes
[Any other relevant information]


[BYNT-1386]:
https://syriajustice.atlassian.net/browse/BYNT-1386?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ

---------

Co-authored-by: tarekio <7659394+tarekio@users.noreply.github.com>
@tarekio tarekio requested a review from level09 August 1, 2025 10:54
- Centralized duplicate validation code into single validate_username_constraints() function
- Eliminated ~30 lines of repeated logic across model validators
- Unified error handling to consistent ValueError types
- Updated tests to match new validation interface
Resolved conflicts by:
- Keeping checkUsername function from main in users.html template
- Preserving our cleaner validation logic in admin views
- Our centralized username validation supersedes the manual character validation from main
@tarekio tarekio merged commit f8818c9 into main Aug 8, 2025
7 checks passed
@tarekio tarekio deleted the bynt-1364-username-email-validation branch August 8, 2025 10:11
level09 added a commit that referenced this pull request Mar 2, 2026
…lp (#273)

## Summary

- **yt-dlp**: bump to `>=2026.2.21` to fix high-severity arbitrary
command injection via `--netrc-cmd` (Dependabot alert #126)
- **extraction.py**: replace raw `str(e)` in error responses with
generic messages to prevent internal exception leakage to API clients
(CodeQL alert #132)
- **app.py**: replace substring check on `MAPS_API_ENDPOINT` with
`urlparse` hostname check to prevent crafted URLs from bypassing CSP
allowlist (CodeQL alert #122)

## Notes

All three endpoints are behind authentication, but defense-in-depth
applies. Exception strings are still logged in full server-side.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants