fix(auth): add password strength validation to admin.createUser #1964
+255
−22
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The admin.createUser endpoint wasn't checking password strength against configured rules, while admin.updateUser was doing this validation. This creates a security gap where users created via the admin API could have weak passwords that don't meet the configured requirements.
This commit adds the missing password strength validation to ensure consistent security across all user creation paths.
What kind of change does this PR introduce?
This is a security-related bug fix that closes a gap in password validation. It maintains backward compatibility for all valid use cases while enforcing proper security standards for passwords created through the admin API.
What is the current behavior?
Currently, there's an inconsistency in password validation within the Supabase Auth API:
This inconsistency creates a security vulnerability where:
As noted in issue #1959, this means that even if an application has strict password rules configured, an administrator can inadvertently create users with weak passwords that would otherwise be rejected if created through normal registration or updated later.
What is the new behavior?
Checklist for Submitting Pull Requests
Is there a corresponding issue created for it? If so, please include it in the PR description so we can track/refer to it.:
Fixes #1959
Does your PR follow the semantic-release commit guidelines?:
Yes
Are the existing tests passing?:
The full test suite (
make test
) shows failures, but these failures existed before my changes and are unrelated to the password validation functionality I've fixed. I've verified that my specific changes work by running the relevant tests in isolation.To verify my changes, I ran:
go test ./internal/api -run TestAdmin -v
which confirms the password validation is now working correctly.Have you written some tests for your PR?:
Yes