Migrate to Postgresql for better network handling. Add more user functionality.

This commit is contained in:
Dan Milne
2025-11-06 14:08:39 +11:00
parent 85252a1a07
commit fc567f0b91
69 changed files with 4266 additions and 952 deletions

View File

@@ -1,54 +1,69 @@
# SQLite. Versions 3.8.0 and up are supported.
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem "sqlite3"
#
default: &default
# Primary database: PostgreSQL for network intelligence
# Cache/Queue/Cable: SQLite for auxiliary storage
# Default configuration for SQLite databases (cache/queue/cable)
sqlite_default: &sqlite_default
adapter: sqlite3
max_connections: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
timeout: 5000
# Default configuration for PostgreSQL
postgres_default: &postgres_default
adapter: postgresql
encoding: unicode
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
host: localhost
port: 5432
development:
primary:
<<: *default
database: storage/development.sqlite3
<<: *postgres_default
database: baffle_hub_development
cache:
<<: *default
<<: *sqlite_default
database: storage/development_cache.sqlite3
migrations_paths: db/cache_migrate
queue:
<<: *default
<<: *sqlite_default
database: storage/development_queue.sqlite3
migrations_paths: db/queue_migrate
cable:
<<: *default
<<: *sqlite_default
database: storage/development_cable.sqlite3
migrations_paths: db/cable_migrate
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
<<: *default
database: storage/test.sqlite3
primary:
<<: *postgres_default
database: baffle_hub_test
cache:
<<: *sqlite_default
database: storage/test_cache.sqlite3
migrations_paths: db/cache_migrate
queue:
<<: *sqlite_default
database: storage/test_queue.sqlite3
migrations_paths: db/queue_migrate
cable:
<<: *sqlite_default
database: storage/test_cable.sqlite3
migrations_paths: db/cable_migrate
# Store production database in the storage/ directory, which by default
# is mounted as a persistent Docker volume in config/deploy.yml.
production:
primary:
<<: *default
database: storage/production.sqlite3
<<: *postgres_default
database: baffle_hub_production
username: baffle_hub
password: <%= ENV["BAFFLE_HUB_DATABASE_PASSWORD"] %>
cache:
<<: *default
<<: *sqlite_default
database: storage/production_cache.sqlite3
migrations_paths: db/cache_migrate
queue:
<<: *default
<<: *sqlite_default
database: storage/production_queue.sqlite3
migrations_paths: db/queue_migrate
cable:
<<: *default
<<: *sqlite_default
database: storage/production_cable.sqlite3
migrations_paths: db/cable_migrate
migrations_paths: db/cable_migrate

View File

@@ -2,7 +2,7 @@ Rails.application.routes.draw do
# Registration only allowed when no users exist
resource :registration, only: [:new, :create]
resource :session
resources :passwords, param: :token
resource :password
# OIDC authentication routes
get "/auth/failure", to: "omniauth_callbacks#failure"
@@ -39,6 +39,20 @@ Rails.application.routes.draw do
end
end
# Network range management
resources :network_ranges, only: [:index, :show, :new, :create, :edit, :update, :destroy] do
member do
post :enrich
end
collection do
get :lookup
get :search
end
end
# Support CIDR patterns with dots in network range routes
get '/network_ranges/:id', to: 'network_ranges#show', constraints: { id: /[\d\.:\/_]+/ }
# Rule management
resources :rules, only: [:index, :new, :create, :show, :edit, :update] do
member do