@@ -1906,64 +1906,10 @@ func (d *SQLiteDriver) Open(dsn string) (driver.Conn, error) {
19061906 }
19071907
19081908 // Preform Authentication
1909- if err := conn .Authenticate (authUser , authPass ); err != nil {
1910- return err
1911- }
1912-
1913- // Register: authenticate
1914- // Authenticate will perform an authentication of the provided username
1915- // and password against the database.
1916- //
1917- // If a database contains the SQLITE_USER table, then the
1918- // call to Authenticate must be invoked with an
1919- // appropriate username and password prior to enable read and write
1920- //access to the database.
1921- //
1922- // Return SQLITE_OK on success or SQLITE_ERROR if the username/password
1923- // combination is incorrect or unknown.
1924- //
1925- // If the SQLITE_USER table is not present in the database file, then
1926- // this interface is a harmless no-op returnning SQLITE_OK.
1927- if err := conn .registerAuthFunc ("authenticate" , conn .authenticate , true ); err != nil {
1928- return err
1929- }
1930- //
1931- // Register: auth_user_add
1932- // auth_user_add can be used (by an admin user only)
1933- // to create a new user. When called on a no-authentication-required
1934- // database, this routine converts the database into an authentication-
1935- // required database, automatically makes the added user an
1936- // administrator, and logs in the current connection as that user.
1937- // The AuthUserAdd only works for the "main" database, not
1938- // for any ATTACH-ed databases. Any call to AuthUserAdd by a
1939- // non-admin user results in an error.
1940- if err := conn .registerAuthFunc ("auth_user_add" , conn .authUserAdd , true ); err != nil {
1941- return err
1942- }
1943- //
1944- // Register: auth_user_change
1945- // auth_user_change can be used to change a users
1946- // login credentials or admin privilege. Any user can change their own
1947- // login credentials. Only an admin user can change another users login
1948- // credentials or admin privilege setting. No user may change their own
1949- // admin privilege setting.
1950- if err := conn .registerAuthFunc ("auth_user_change" , conn .authUserChange , true ); err != nil {
1951- return err
1952- }
19531909 //
1954- // Register: auth_user_delete
1955- // auth_user_delete can be used (by an admin user only)
1956- // to delete a user. The currently logged-in user cannot be deleted,
1957- // which guarantees that there is always an admin user and hence that
1958- // the database cannot be converted into a no-authentication-required
1959- // database.
1960- if err := conn .registerAuthFunc ("auth_user_delete" , conn .authUserDelete , true ); err != nil {
1961- return err
1962- }
1963-
1964- // Register: auth_enabled
1965- // auth_enabled can be used to check if user authentication is enabled
1966- if err := conn .registerAuthFunc ("auth_enabled" , conn .authEnabled , true ); err != nil {
1910+ // NB: This will always fail if built with the "sqlite_userauth"
1911+ // build tag since user authentication is now deprecated.
1912+ if err := conn .Authenticate (authUser , authPass ); err != nil {
19671913 return err
19681914 }
19691915
@@ -1980,6 +1926,9 @@ func (d *SQLiteDriver) Open(dsn string) (driver.Conn, error) {
19801926 }
19811927
19821928 // Check if user wants to activate User Authentication
1929+ //
1930+ // NB: This will always fail if built with the "sqlite_userauth"
1931+ // build tag since user authentication is now deprecated.
19831932 if authCreate {
19841933 // Before going any further, we need to check that the user
19851934 // has provided an username and password within the DSN.
@@ -1992,8 +1941,7 @@ func (d *SQLiteDriver) Open(dsn string) (driver.Conn, error) {
19921941 }
19931942
19941943 // Check if User Authentication is Enabled
1995- authExists := conn .AuthEnabled ()
1996- if ! authExists {
1944+ if ! conn .AuthEnabled () {
19971945 if err := conn .AuthUserAdd (authUser , authPass , true ); err != nil {
19981946 return err
19991947 }
0 commit comments