/ Check-in [96ea5c0b]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:All interfaces working and tested.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | user-auth
Files: files | file ages | folders
SHA1: 96ea5c0b3cd1dec81d490f2f958ebd2e47a24921
User & Date: drh 2014-09-11 15:25:02
Context
2014-09-11
16:19
Enhance the sqlite3_user_add() interface to initialize the user authentication logic. Add test cases for the extra argument on the end of the authorizer callback. check-in: 842c6da8 user: drh tags: user-auth
15:25
All interfaces working and tested. check-in: 96ea5c0b user: drh tags: user-auth
14:56
Get the sqlite3_user_delete() interface working. check-in: 974a9c65 user: drh tags: user-auth
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/attach.c.

   208    208       sqlite3BtreeLeaveAll(db);
   209    209     }
   210    210   #ifdef SQLITE_USER_AUTHENTICATION
   211    211     if( rc==SQLITE_OK ){
   212    212       u8 newAuth = 0;
   213    213       rc = sqlite3UserAuthCheckLogin(db, zName, &newAuth);
   214    214       if( newAuth<db->auth.authLevel ){
   215         -      rc = SQLITE_AUTH;
          215  +      rc = SQLITE_AUTH_USER;
   216    216       }
   217    217     }
   218    218   #endif
   219    219     if( rc ){
   220    220       int iDb = db->nDb - 1;
   221    221       assert( iDb>=2 );
   222    222       if( db->aDb[iDb].pBt ){

Changes to test/userauth01.test.

   197    197   do_test userauth01-1.50 {
   198    198     sqlite3_user_delete db alice
   199    199   } {SQLITE_AUTH}
   200    200   do_test userauth01-1.51 {
   201    201     db eval {SELECT uname, isadmin FROM sqlite_user ORDER BY uname}
   202    202   } {alice 1 cindy 0 david 0}
   203    203   
          204  +# When ATTACH-ing new database files to a connection, each newly attached
          205  +# database that is an authentication-required database is checked using
          206  +# the same username and password as supplied to the main database.  If that
          207  +# check fails, then the ATTACH command fails with an SQLITE_AUTH error.
          208  +#
          209  +do_test userauth01-1.60 {
          210  +  forcedelete test3.db
          211  +  sqlite3 db3 test3.db
          212  +  db3 eval {
          213  +    CREATE TABLE t3(a,b,c); INSERT INTO t3 VALUES(1,2,3);
          214  +    SELECT * FROM t3;
          215  +  }
          216  +} {1 2 3}
          217  +do_test userauth01-1.61 {
          218  +  sqlite3_user_add db3 alice xyzzy-alice 1
          219  +} {SQLITE_OK}
          220  +do_test userauth01-1.62 {
          221  +  db eval {
          222  +    ATTACH 'test3.db' AS aux;
          223  +    SELECT * FROM t1, t3 ORDER BY x LIMIT 1;
          224  +    DETACH aux;
          225  +  }
          226  +} {{} 1 2 3}
          227  +do_test userauth01-1.63 {
          228  +  sqlite3_user_change db alice pw-4-alice 1
          229  +  sqlite3_user_authenticate db alice pw-4-alice
          230  +  catchsql {
          231  +    ATTACH 'test3.db' AS aux;
          232  +  }
          233  +} {1 {unable to open database: test3.db}}
          234  +do_test userauth01-1.64 {
          235  +  sqlite3_extended_errcode db
          236  +} {SQLITE_AUTH}
          237  +do_test userauth01-1.65 {
          238  +  db eval {PRAGMA database_list}
          239  +} {~/test3.db/}
   204    240   
   205    241   finish_test