gemini-search

A simple search engine for Geminispace
git clone git://git.laack.co/gemini-search.git
Log | Files | Refs | README

sqlite3_opt_userauth_omit.go (4470B)


      1 // Copyright (C) 2018 G.J.R. Timmer <gjr.timmer@gmail.com>.
      2 //
      3 // Use of this source code is governed by an MIT-style
      4 // license that can be found in the LICENSE file.
      5 
      6 //go:build !sqlite_userauth
      7 // +build !sqlite_userauth
      8 
      9 package sqlite3
     10 
     11 import (
     12 	"C"
     13 )
     14 
     15 // Authenticate will perform an authentication of the provided username
     16 // and password against the database.
     17 //
     18 // If a database contains the SQLITE_USER table, then the
     19 // call to Authenticate must be invoked with an
     20 // appropriate username and password prior to enable read and write
     21 // access to the database.
     22 //
     23 // Return SQLITE_OK on success or SQLITE_ERROR if the username/password
     24 // combination is incorrect or unknown.
     25 //
     26 // If the SQLITE_USER table is not present in the database file, then
     27 // this interface is a harmless no-op returnning SQLITE_OK.
     28 func (c *SQLiteConn) Authenticate(username, password string) error {
     29 	// NOOP
     30 	return nil
     31 }
     32 
     33 // authenticate provides the actual authentication to SQLite.
     34 // This is not exported for usage in Go.
     35 // It is however exported for usage within SQL by the user.
     36 //
     37 // Returns:
     38 //
     39 //		C.SQLITE_OK (0)
     40 //		C.SQLITE_ERROR (1)
     41 //	 C.SQLITE_AUTH (23)
     42 func (c *SQLiteConn) authenticate(username, password string) int {
     43 	// NOOP
     44 	return 0
     45 }
     46 
     47 // AuthUserAdd can be used (by an admin user only)
     48 // to create a new user.  When called on a no-authentication-required
     49 // database, this routine converts the database into an authentication-
     50 // required database, automatically makes the added user an
     51 // administrator, and logs in the current connection as that user.
     52 // The AuthUserAdd only works for the "main" database, not
     53 // for any ATTACH-ed databases. Any call to AuthUserAdd by a
     54 // non-admin user results in an error.
     55 func (c *SQLiteConn) AuthUserAdd(username, password string, admin bool) error {
     56 	// NOOP
     57 	return nil
     58 }
     59 
     60 // authUserAdd enables the User Authentication if not enabled.
     61 // Otherwise it will add a user.
     62 //
     63 // When user authentication is already enabled then this function
     64 // can only be called by an admin.
     65 //
     66 // This is not exported for usage in Go.
     67 // It is however exported for usage within SQL by the user.
     68 //
     69 // Returns:
     70 //
     71 //		C.SQLITE_OK (0)
     72 //		C.SQLITE_ERROR (1)
     73 //	 C.SQLITE_AUTH (23)
     74 func (c *SQLiteConn) authUserAdd(username, password string, admin int) int {
     75 	// NOOP
     76 	return 0
     77 }
     78 
     79 // AuthUserChange can be used to change a users
     80 // login credentials or admin privilege.  Any user can change their own
     81 // login credentials.  Only an admin user can change another users login
     82 // credentials or admin privilege setting.  No user may change their own
     83 // admin privilege setting.
     84 func (c *SQLiteConn) AuthUserChange(username, password string, admin bool) error {
     85 	// NOOP
     86 	return nil
     87 }
     88 
     89 // authUserChange allows to modify a user.
     90 // Users can change their own password.
     91 //
     92 // Only admins can change passwords for other users
     93 // and modify the admin flag.
     94 //
     95 // The admin flag of the current logged in user cannot be changed.
     96 // THis ensures that their is always an admin.
     97 //
     98 // This is not exported for usage in Go.
     99 // It is however exported for usage within SQL by the user.
    100 //
    101 // Returns:
    102 //
    103 //		C.SQLITE_OK (0)
    104 //		C.SQLITE_ERROR (1)
    105 //	 C.SQLITE_AUTH (23)
    106 func (c *SQLiteConn) authUserChange(username, password string, admin int) int {
    107 	// NOOP
    108 	return 0
    109 }
    110 
    111 // AuthUserDelete can be used (by an admin user only)
    112 // to delete a user.  The currently logged-in user cannot be deleted,
    113 // which guarantees that there is always an admin user and hence that
    114 // the database cannot be converted into a no-authentication-required
    115 // database.
    116 func (c *SQLiteConn) AuthUserDelete(username string) error {
    117 	// NOOP
    118 	return nil
    119 }
    120 
    121 // authUserDelete can be used to delete a user.
    122 //
    123 // This function can only be executed by an admin.
    124 //
    125 // This is not exported for usage in Go.
    126 // It is however exported for usage within SQL by the user.
    127 //
    128 // Returns:
    129 //
    130 //		C.SQLITE_OK (0)
    131 //		C.SQLITE_ERROR (1)
    132 //	 C.SQLITE_AUTH (23)
    133 func (c *SQLiteConn) authUserDelete(username string) int {
    134 	// NOOP
    135 	return 0
    136 }
    137 
    138 // AuthEnabled checks if the database is protected by user authentication
    139 func (c *SQLiteConn) AuthEnabled() (exists bool) {
    140 	// NOOP
    141 	return false
    142 }
    143 
    144 // authEnabled perform the actual check for user authentication.
    145 //
    146 // This is not exported for usage in Go.
    147 // It is however exported for usage within SQL by the user.
    148 //
    149 // Returns:
    150 //
    151 //		0 - Disabled
    152 //	 1 - Enabled
    153 func (c *SQLiteConn) authEnabled() int {
    154 	// NOOP
    155 	return 0
    156 }
    157 
    158 // EOF