forked from mattn/go-sqlite3
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsqlite3_opt_userauth.go
More file actions
94 lines (84 loc) · 3.61 KB
/
sqlite3_opt_userauth.go
File metadata and controls
94 lines (84 loc) · 3.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// Copyright (C) 2018 G.J.R. Timmer <gjr.timmer@gmail.com>.
//
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file.
//go:build sqlite_userauth
// +build sqlite_userauth
package sqlite3
import "errors"
var (
ErrUnauthorized = errors.New("SQLITE_AUTH: Unauthorized")
ErrAdminRequired = errors.New("SQLITE_AUTH: Unauthorized; Admin Privileges Required")
errUserAuthNoLongerSupported = errors.New("sqlite3: the sqlite_userauth tag is no longer supported " +
"as the userauth extension is no longer supported by the SQLite authors, " +
"see https://github.com/mattn/go-sqlite3/issues/1341")
)
// NB: Even though userauth is no longer supported, we preserve
// these methods to maintain backwards compatibility.
// Authenticate will perform an authentication of the provided username
// and password against the database.
//
// If a database contains the SQLITE_USER table, then the
// call to Authenticate must be invoked with an
// appropriate username and password prior to enable read and write
// access to the database.
//
// Return SQLITE_OK on success or SQLITE_ERROR if the username/password
// combination is incorrect or unknown.
//
// If the SQLITE_USER table is not present in the database file, then
// this interface is a harmless no-op returnning SQLITE_OK.
//
// Deprecated: The sqlite3 ext/userauth module is [deprecated].
//
// [deprecated]: https://www.sqlite.org/src/artifact/ca7e9ee82ca4e1c
func (c *SQLiteConn) Authenticate(username, password string) error {
return errUserAuthNoLongerSupported
}
// 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-
// required database, automatically makes the added user an
// administrator, and logs in the current connection as that user.
// The AuthUserAdd only works for the "main" database, not
// for any ATTACH-ed databases. Any call to AuthUserAdd by a
// non-admin user results in an error.
//
// Deprecated: The sqlite3 ext/userauth module is [deprecated].
//
// [deprecated]: https://www.sqlite.org/src/artifact/ca7e9ee82ca4e1c
func (c *SQLiteConn) AuthUserAdd(username, password string, admin bool) error {
return errUserAuthNoLongerSupported
}
// 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
// credentials or admin privilege setting. No user may change their own
// admin privilege setting.
//
// Deprecated: The sqlite3 ext/userauth module is [deprecated].
//
// [deprecated]: https://www.sqlite.org/src/artifact/ca7e9ee82ca4e1c
func (c *SQLiteConn) AuthUserChange(username, password string, admin bool) error {
return errUserAuthNoLongerSupported
}
// 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
// the database cannot be converted into a no-authentication-required
// database.
//
// Deprecated: The sqlite3 ext/userauth module is [deprecated].
//
// [deprecated]: https://www.sqlite.org/src/artifact/ca7e9ee82ca4e1c
func (c *SQLiteConn) AuthUserDelete(username string) error {
return errUserAuthNoLongerSupported
}
// AuthEnabled checks if the database is protected by user authentication
//
// Deprecated: The sqlite3 ext/userauth module is [deprecated].
//
// [deprecated]: https://www.sqlite.org/src/artifact/ca7e9ee82ca4e1c
func (c *SQLiteConn) AuthEnabled() (exists bool) {
return false
}