security.toml 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. # prepare for evil ass autism configs!
  2. [security]
  3. # Yk what this is, if not read the fkn readme
  4. whitelisted_pin_ips = ["192.168.1.0/24", "127.0.0.1"]
  5. whitelisted_string_ips = ["192.168.5.0/24", "127.0.0.1"]
  6. # session stuffs
  7. session_timeout_minutes = 60 # def session timeout (makes session key go bye bye)
  8. refresh_session_on_activity = true # most useless thing ever most likely as nobody will ever disable this but sure you can just kill a users session during active use right?
  9. max_concurrent_sessions = 3 # how many gooning session to allow per user (you can set custom ones per powerlevel btw)
  10. session_cleanup_interval_minutes = 5 # how often to actually check on the session timeout, we aint gotta spam it none stop tbh
  11. # PIN and Token Auth
  12. hash_pins = false # weather or not to use bcrypt for pin field (left off for dev work)
  13. hash_tokens = false # Same as above
  14. pin_column = "pin_code"
  15. token_column = "login_string"
  16. # Rate Limiting, need i say more?
  17. enable_rate_limiting = true # Do yuo wahnt raten limitierung or not?
  18. # If i have to explain these to you just dont use this software
  19. auth_rate_limit_per_minute = 10000
  20. auth_rate_limit_per_second = 50000
  21. # api rape limitz
  22. api_rate_limit_per_minute = 100000
  23. api_rate_limit_per_second = 100000
  24. # default query limits to avoid someone spamming quieries on a table with 271k rows
  25. default_max_limit = 10000
  26. default_max_where_conditions = 1000
  27. # own user preferences level
  28. # Determines what an user can do with their own little preference store
  29. # - "read-own-only": kiosk ah ruling
  30. # - "read-write-own": what you probably want for most users
  31. # - "read-write-all": adminier maybe ?
  32. default_user_settings_access = "read-write-own"
  33. # define what tables exist
  34. # known tables for wildcard permissions (*:rw) and to prevent SQL injection via table names cuz thats a thing
  35. known_tables = [
  36. "users", "roles", "assets", "categories", "zones",
  37. "suppliers", "templates", "audit_tasks", "borrowers",
  38. "lending_history", "audit_history", "maintenance_log",
  39. "asset_change_log", "issue_tracker", "issue_tracker_change_log",
  40. "physical_audits", "physical_audit_logs",
  41. "label_templates", "printer_settings", "print_history"
  42. ]
  43. # tables you cant write or change using proxi in any way not even user overrides below
  44. read_only_tables = ["asset_change_log", "issue_tracker_change_log", "print_history"]
  45. # column names banned from being written to by default (this is however overwritable on a per table per column per user type schizo settings below)
  46. global_write_protected_columns = [
  47. "id",
  48. "created_date",
  49. "created_at",
  50. "last_modified_date",
  51. "updated_at",
  52. "last_modified_at",
  53. ]
  54. # note to myself how the rbac system kinda works
  55. # Format: role_power contains both basic table rules and advanced column rules
  56. # Basic rules: "table:permission" (r = read, w = write, rw = read+write, * = all tables (for like admins or smth))
  57. # Advanced rules: "table.column:permission" for more granular column level control
  58. # Column permissions: r = read, w = write, rw = read+write, block = blocked (obviously)
  59. # Use "table.*:block" to block all columns, then "table.specific_column:r" to allow specific ones
  60. # Use "table.*:r" to allow all columns, then "table.sensitive_column:block" to block specific ones
  61. # In the future even more advaned rules called schizo_rules will be implemented where you can define sql logic based rules
  62. # like "only allow access to rows where user_id = current_user_id" or "only allow access to assets where status != 'Stolen'"
  63. # i let an llm comment on the crap below so i can understand what ive done in like 3 months when i forget everything
  64. [permissions]
  65. [permissions."100"]
  66. # Admin - full access to everything
  67. basic_rules = [
  68. "*:rw", # Example of wildcard full access to all known tables
  69. "asset_change_log:r", # More or less redundant but whatever
  70. "issue_tracker_change_log:r" # Same as above
  71. ]
  72. advanced_rules = [
  73. # Further granularity wow!
  74. "assets.asset_numeric_id:r",
  75. "assets.created_by:r",
  76. "assets.last_modified_by:r",
  77. "users.password_hash:block",
  78. ]
  79. max_limit = 500
  80. max_where_conditions = 50
  81. session_timeout_minutes = 120 # Admins get longer sessions (2 hours)
  82. max_concurrent_sessions = 5 # Admins can have more concurrent sessions
  83. rollback_on_error = true # Rollback batch operations on any error
  84. allow_batch_operations = true # Admins can use batch operations
  85. user_settings_access = "read-write-all" # Admins can modify any user's preferences
  86. [permissions."75"]
  87. # Manager - full asset management, limited user access
  88. rollback_on_error = true # Rollback batch operations on any error
  89. allow_batch_operations = true # Managers can use batch operations
  90. basic_rules = [
  91. "assets:rw",
  92. "lending_history:rw",
  93. "audit_history:rw",
  94. "maintenance_log:rw",
  95. "borrowers:rw",
  96. "categories:rw",
  97. "zones:rw",
  98. "suppliers:rw",
  99. "templates:rw",
  100. "audit_tasks:rw",
  101. "issue_tracker:rw",
  102. "physical_audits:rw",
  103. "physical_audit_logs:rw",
  104. "label_templates:rw",
  105. "printer_settings:rw",
  106. "print_history:r",
  107. "users:r", # Basic read access, then restricted by advanced rules below
  108. "roles:r",
  109. "asset_change_log:r",
  110. "issue_tracker_change_log:r"
  111. ]
  112. advanced_rules = [
  113. # Table-specific protected (same as admin)
  114. "assets.asset_numeric_id:r",
  115. "assets.created_by:r",
  116. "assets.last_modified_by:r",
  117. # Users table - can read most info but not sensitive auth data
  118. "users.password:block",
  119. "users.password_hash:block",
  120. "users.pin_code:block",
  121. "users.login_string:block",
  122. "users.password_reset_token:block",
  123. "users.password_reset_expiry:block",
  124. ]
  125. # Query limits (moderate for managers)
  126. max_limit = 200
  127. max_where_conditions = 20
  128. user_settings_access = "read-write-own" # Managers can only modify their own preferences
  129. [permissions."50"]
  130. # Staff - asset and lending management, NO user access
  131. rollback_on_error = false # Don't rollback batch operations on error (continue processing)
  132. allow_batch_operations = true # Staff can use batch operations
  133. basic_rules = [
  134. "assets:rw",
  135. "lending_history:rw",
  136. "audit_history:rw",
  137. "maintenance_log:rw",
  138. "borrowers:rw",
  139. "categories:r",
  140. "zones:r",
  141. "suppliers:r",
  142. "templates:r",
  143. "audit_tasks:r",
  144. "issue_tracker:r",
  145. "physical_audits:r",
  146. "physical_audit_logs:r",
  147. "label_templates:r",
  148. "printer_settings:r",
  149. "print_history:r",
  150. "asset_change_log:r",
  151. "issue_tracker_change_log:r"
  152. ]
  153. advanced_rules = [
  154. # Table-specific protected (same as admin/manager)
  155. "assets.asset_numeric_id:r",
  156. "assets.created_by:r",
  157. "assets.last_modified_by:r",
  158. ]
  159. # No users table access for staff - security requirement
  160. # Query limits (standard for staff)
  161. max_limit = 100
  162. max_where_conditions = 10
  163. user_settings_access = "read-write-own" # Staff can only modify their own preferences
  164. [permissions."25"]
  165. # Student - read-only access, no financial data, no user access, no change logs
  166. rollback_on_error = true # Rollback batch operations on any error
  167. allow_batch_operations = false # Students cannot use batch operations
  168. basic_rules = [
  169. "assets:r",
  170. "lending_history:r",
  171. "borrowers:r",
  172. "categories:r",
  173. "zones:r"
  174. ]
  175. advanced_rules = [
  176. # Assets table - hide financial and sensitive info
  177. "assets.price:block",
  178. "assets.purchase_date:block",
  179. "assets.supplier_id:block",
  180. "assets.warranty_expiry:block",
  181. # Borrowers table - hide personal contact info
  182. "borrowers.email:block",
  183. "borrowers.phone_number:block",
  184. "borrowers.notes:block"
  185. ]
  186. # Query limits (restricted for students)
  187. max_limit = 50
  188. max_where_conditions = 5
  189. user_settings_access = "read-own-only" # Students can only read their own preferences, not modify