diff options
author | Gert-Jan Timmer <gjr.timmer@gmail.com> | 2018-06-01 11:28:04 +0200 |
---|---|---|
committer | Gert-Jan Timmer <gjr.timmer@gmail.com> | 2018-06-01 11:28:04 +0200 |
commit | 0e289439a27f126dcc2fa96b2dd2d4cc9ecbbf7c (patch) | |
tree | 6616049900fbb9a6c45bf26a92a35d151b3aa1e6 /sqlite3_opt_userauth_omit.go | |
parent | Stash (diff) | |
download | golite-0e289439a27f126dcc2fa96b2dd2d4cc9ecbbf7c.tar.gz golite-0e289439a27f126dcc2fa96b2dd2d4cc9ecbbf7c.tar.xz |
Update User Authentication
* Update bindings
* Add user authentication sql functions
Reference #579
Diffstat (limited to 'sqlite3_opt_userauth_omit.go')
-rw-r--r-- | sqlite3_opt_userauth_omit.go | 88 |
1 files changed, 85 insertions, 3 deletions
diff --git a/sqlite3_opt_userauth_omit.go b/sqlite3_opt_userauth_omit.go index 3d1c758..302cd57 100644 --- a/sqlite3_opt_userauth_omit.go +++ b/sqlite3_opt_userauth_omit.go @@ -29,6 +29,19 @@ func (c *SQLiteConn) Authenticate(username, password string) error { return nil } +// authenticate provides the actual authentication to SQLite. +// This is not exported for usage in Go. +// It is however exported for usage within SQL by the user. +// +// Returns: +// C.SQLITE_OK (0) +// C.SQLITE_ERROR (1) +// C.SQLITE_AUTH (23) +func (c *SQLiteConn) authenticate(username, password string) int { + // NOOP + return 0 +} + // AuthUserAdd can be used (by an admin user only) // to create a new user. When called on a no-authentication-required // database, this routine converts the database into an authentication- @@ -42,6 +55,24 @@ func (c *SQLiteConn) AuthUserAdd(username, password string, admin bool) error { return nil } +// authUserAdd enables the User Authentication if not enabled. +// Otherwise it will add a user. +// +// When user authentication is already enabled then this function +// can only be called by an admin. +// +// This is not exported for usage in Go. +// It is however exported for usage within SQL by the user. +// +// Returns: +// C.SQLITE_OK (0) +// C.SQLITE_ERROR (1) +// C.SQLITE_AUTH (23) +func (c *SQLiteConn) authUserAdd(username, password string, admin int) int { + // NOOP + return 0 +} + // AuthUserChange can be used to change a users // login credentials or admin privilege. Any user can change their own // login credentials. Only an admin user can change another users login @@ -52,6 +83,27 @@ func (c *SQLiteConn) AuthUserChange(username, password string, admin bool) error return nil } +// authUserChange allows to modify a user. +// Users can change their own password. +// +// Only admins can change passwords for other users +// and modify the admin flag. +// +// The admin flag of the current logged in user cannot be changed. +// THis ensures that their is always an admin. +// +// This is not exported for usage in Go. +// It is however exported for usage within SQL by the user. +// +// Returns: +// C.SQLITE_OK (0) +// C.SQLITE_ERROR (1) +// C.SQLITE_AUTH (23) +func (c *SQLiteConn) authUserChange(username, password string, admin int) int { + // NOOP + return 0 +} + // AuthUserDelete can be used (by an admin user only) // to delete a user. The currently logged-in user cannot be deleted, // which guarantees that there is always an admin user and hence that @@ -62,9 +114,39 @@ func (c *SQLiteConn) AuthUserDelete(username string) error { return nil } -// Check is database is protected by user authentication -func (c *SQLiteConn) AuthIsEnabled() (exists bool) { - return +// authUserDelete can be used to delete a user. +// +// This function can only be executed by an admin. +// +// This is not exported for usage in Go. +// It is however exported for usage within SQL by the user. +// +// Returns: +// C.SQLITE_OK (0) +// C.SQLITE_ERROR (1) +// C.SQLITE_AUTH (23) +func (c *SQLiteConn) authUserDelete(username string) int { + // NOOP + return 0 +} + +// AuthEnabled checks if the database is protected by user authentication +func (c *SQLiteConn) AuthEnabled() (exists bool) { + // NOOP + return false +} + +// authEnabled perform the actual check for user authentication. +// +// This is not exported for usage in Go. +// It is however exported for usage within SQL by the user. +// +// Returns: +// 0 - Disabled +// 1 - Enabled +func (c *SQLiteConn) authEnabled() int { + // NOOP + return 0 } // EOF |