Skip to content

Drop userauth implementation #1344

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open

Conversation

mattn
Copy link
Owner

@mattn mattn commented Jul 26, 2025

Closes #1341

@mattn mattn requested a review from Copilot July 26, 2025 13:06
Copilot

This comment was marked as outdated.

@mattn mattn requested a review from Copilot July 26, 2025 14:01
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR removes the user authentication implementation from the SQLite Go driver, deprecating the feature and simplifying the codebase. The change converts all user authentication functions to no-ops that return unauthorized errors.

  • User authentication functions now return errors instead of performing actual authentication
  • Test suite simplified to verify authentication is disabled
  • Documentation updated to mark the feature as deprecated

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
sqlite3_opt_userauth.go Removes C bindings and implementation, converts all auth methods to return ErrUnauthorized
sqlite3_opt_userauth_test.go Simplifies test suite to single test verifying auth is disabled
sqlite3.go Adds conditional check before attempting authentication
error_test.go Improves error handling with type assertion check
README.md Adds deprecation notice for user authentication
.github/workflows/go.yaml Updates Go versions and adds sqlite_userauth tag to CI

sqlite3.go Outdated
Comment on lines 1571 to 1576
if conn.AuthEnabled() {
// Preform Authentication
if err := conn.Authenticate(authUser, authPass); err != nil {
return nil, err
}
}
Copy link
Preview

Copilot AI Jul 26, 2025

Choose a reason for hiding this comment

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

This conditional check is unnecessary since AuthEnabled() now always returns false. The authentication code inside this block will never execute, making it unreachable code.

Suggested change
if conn.AuthEnabled() {
// Preform Authentication
if err := conn.Authenticate(authUser, authPass); err != nil {
return nil, err
}
}
// Authentication is disabled as AuthEnabled() always returns false.

Copilot uses AI. Check for mistakes.

Copy link
Owner Author

Choose a reason for hiding this comment

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

No, we need to remain this code for users who uses Authenticate method.

Comment on lines +71 to 75
t.Fatalf("UserAuth not enabled: %s", err)
}
defer db2.Close()

// Delete user while logged in as normal user
// through SQL
rv, err = deleteUser(db2, "user")
if err != nil {
if !errors.Is(err, ErrUnauthorized) {
t.Fatal(err)
}
Copy link
Preview

Copilot AI Jul 26, 2025

Choose a reason for hiding this comment

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

The test logic is incorrect. Since connect() now always fails (AuthEnabled returns false, but authentication is still attempted), the test should expect an error, but the error checking logic suggests it expects ErrUnauthorized specifically. However, the previous condition checks if err == nil and fails the test, creating contradictory expectations.

Copilot uses AI. Check for mistakes.

Copy link
Owner Author

Choose a reason for hiding this comment

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

This is a test for connect should return ErrUnauthorized always.

@mattn mattn requested a review from rittneje July 26, 2025 14:03
default:
return c.lastError()
}
return ErrUnauthorized
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should return something like errors.New("sqlite3: the sqlite_userauth tag is no longer supported as the userauth extension is no longer supported by the SQLite authors, see <GitHub issue link>").

That way, users that have been relying on this extension will get a very clear message as to what the problem is, as opposed to a mysterious "not authorized" error.

sqlite3.go Outdated
// Preform Authentication
if err := conn.Authenticate(authUser, authPass); err != nil {
return nil, err
if conn.AuthEnabled() {
Copy link
Collaborator

@rittneje rittneje Jul 26, 2025

Choose a reason for hiding this comment

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

I don't think we can add this check. Now AuthEnabled() always returns false even if you use the build tag. Therefore, anyone who had been relying on it just would skip auth instead of getting the error.

Copy link
Owner Author

Choose a reason for hiding this comment

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

If enable sqlite_userauth tag, sqlite3 driver always fail since conn.Authenticate return error eventthough user/pass is not set. This means declaring to developers not to use sqlite_userauth. Is this what you intended?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes. If the user doesn't need this extension, then the fix is simple - stop passing the build tag they don't need.

Copy link
Owner Author

Choose a reason for hiding this comment

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

please take a look.

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.

sqlite3_user_authenticate was removed
2 participants