sqlite3_opt_userauth_omit.go 4.4 KB

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