Skip to content

[codex] keep plugin auto-provision passwords bcrypt-safe - #33

Merged
Quick104 merged 1 commit into
mainfrom
fix/oauth-autoprovision-password
May 31, 2026
Merged

Quick104 merged 1 commit into
mainfrom
fix/oauth-autoprovision-password

Conversation

@Quick104

@Quick104 Quick104 commented May 31, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #31 by reducing the random byte payload used by randomPluginOnlyPassword() from 32 bytes to 24 bytes before hex encoding.

The generated plugin-only password changes from plugin-only- + 64 hex chars, 76 bytes total, to plugin-only- + 48 hex chars, 60 bytes total. That keeps the value below bcrypt's 72-byte input limit while preserving enough entropy for an internal password that is never meant for local login.

Relationship to #30

This is related to the same plugin OAuth sign-in surface, but it is a separate backend auto-provisioning failure. #30 handled whether OAuth providers appear on the login page; this fixes first-time OAuth account creation once the OAuth flow completes.

Validation

  • go test ./internal/auth
  • go test ./internal/api/handlers

Summary by CodeRabbit

  • Bug Fixes

    • Adjusted plugin password generation to ensure compatibility with bcrypt's character limit, preventing potential hashing failures.
  • Tests

    • Added validation test to confirm generated plugin passwords fit within bcrypt's 72-character input limit and hash successfully.

@coderabbitai

coderabbitai Bot commented May 31, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 206b636d-f416-4370-a712-a8c4c0046f7e

📥 Commits

Reviewing files that changed from the base of the PR and between 573e9c6 and 7645f95.

📒 Files selected for processing (2)
  • internal/auth/plugin_provider.go
  • internal/auth/plugin_provider_test.go

📝 Walkthrough

Walkthrough

This PR fixes an issue where plugin-only passwords exceeded bcrypt's 72-byte input limit by reducing the random buffer from 32 to 24 bytes in the password generator, and adds a test to verify the constraint is met.

Changes

Plugin Password Generation Fix

Layer / File(s) Summary
Plugin password generation and bcrypt constraint validation
internal/auth/plugin_provider.go, internal/auth/plugin_provider_test.go
randomPluginOnlyPassword() reduces the random byte buffer from 32 to 24 bytes before hex-encoding, lowering the resulting password length from 76 to 60 characters to comply with bcrypt's 72-byte limit. New test TestRandomPluginOnlyPasswordFitsBcryptLimit validates that generated passwords stay within the limit and can be successfully hashed.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Poem

🐰 A password too long made the bcrypt cry,
So we trimmed the random, brought it down to size,
Twenty-four bytes now, sixty chars of code,
Fits the seventy-two-byte safety load!
With a test to confirm, all hashing runs smooth. 🔐

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly indicates the main change: making plugin auto-provision passwords bcrypt-safe by fixing the length issue.
Linked Issues check ✅ Passed The PR directly addresses issue #31 by reducing random bytes from 32 to 24, reducing generated password from 76 to 60 bytes, meeting the ≤72-byte bcrypt requirement.
Out of Scope Changes check ✅ Passed All changes are scoped to fixing the bcrypt password length issue: adjusting randomPluginOnlyPassword() and adding validation test.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/oauth-autoprovision-password

Comment @coderabbitai help to get the list of available commands and usage tips.

@Quick104
Quick104 marked this pull request as ready for review May 31, 2026 21:39
@thezak48

Copy link
Copy Markdown
Contributor

I have tested and this fixes #31

@Quick104
Quick104 merged commit 4c5691f into main May 31, 2026
1 check passed
@Quick104
Quick104 deleted the fix/oauth-autoprovision-password branch May 31, 2026 23:59
Quick104 added a commit to thezak48/silo-server that referenced this pull request Jun 7, 2026
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.

OAuth auto-provision fails for plugin auth providers: generated password exceeds bcrypt 72-byte limit

2 participants