-
Notifications
You must be signed in to change notification settings - Fork 1
fix: environment-based auth bypass architecture #199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
3f3f291
bade7c2
3b935d8
8b397ad
5e3c681
c333def
af9b04c
3521be0
dbfa6bd
2728081
4750b73
fd4490b
d0894dc
7ca6b9c
8218115
45dae3b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| -- Migration 018: Add PostGIS support for geographic grounding | ||
| -- Required for Serper integration spatial queries | ||
|
|
||
| -- Enable PostGIS extension | ||
| CREATE EXTENSION IF NOT EXISTS postgis; | ||
|
|
||
| -- Add PostGIS geometry column to pois table | ||
| -- This will store point locations for spatial queries | ||
| ALTER TABLE pois ADD COLUMN IF NOT EXISTS geom geometry(Point, 4326); | ||
|
|
||
| -- Populate geometry column from existing latitude/longitude | ||
| -- SRID 4326 = WGS 84 (standard GPS coordinates) | ||
| UPDATE pois | ||
| SET geom = ST_SetSRID(ST_MakePoint(longitude, latitude), 4326) | ||
| WHERE latitude IS NOT NULL | ||
| AND longitude IS NOT NULL | ||
| AND geom IS NULL; | ||
|
|
||
| -- Create spatial index for fast geographic queries | ||
| -- Used by getGeographicContext() in serperService.js | ||
| CREATE INDEX IF NOT EXISTS idx_pois_geom ON pois USING GIST (geom); | ||
|
|
||
| -- Add geometry column for boundary polygons | ||
| -- This will store polygon data from the existing JSONB geometry field | ||
| ALTER TABLE pois ADD COLUMN IF NOT EXISTS boundary_geom geometry(Polygon, 4326); | ||
|
|
||
| -- Note: Boundary polygon migration from JSONB will be handled separately | ||
| -- The JSONB geometry field contains GeoJSON that needs custom parsing | ||
| -- For now, boundaries can be re-imported from GeoJSON files | ||
|
|
||
| -- Verify PostGIS is working | ||
| DO $$ | ||
| BEGIN | ||
| IF NOT EXISTS (SELECT 1 FROM pg_extension WHERE extname = 'postgis') THEN | ||
| RAISE EXCEPTION 'PostGIS extension not available'; | ||
| END IF; | ||
| RAISE NOTICE 'PostGIS extension installed successfully'; | ||
| END $$; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| -- Migration 019: Migrate boundary polygons from JSONB to PostGIS geometry | ||
| -- This converts the existing GeoJSON data to proper PostGIS geometry | ||
| -- Handles both Polygon and MultiPolygon geometries | ||
|
|
||
| -- First, change column type to accept both Polygon and MultiPolygon | ||
| ALTER TABLE pois DROP COLUMN IF EXISTS boundary_geom; | ||
| ALTER TABLE pois ADD COLUMN boundary_geom geometry(MultiPolygon, 4326); | ||
|
|
||
| -- Convert JSONB GeoJSON to PostGIS geometry for boundaries | ||
| -- Ensures all geometries are MultiPolygon (converts Polygon → MultiPolygon if needed) | ||
| UPDATE pois | ||
| SET boundary_geom = ST_SetSRID( | ||
| ST_Multi(ST_GeomFromGeoJSON(geometry::text))::geometry(MultiPolygon, 4326), | ||
| 4326 | ||
| ) | ||
| WHERE poi_type = 'boundary' | ||
| AND geometry IS NOT NULL | ||
| AND boundary_geom IS NULL; | ||
|
|
||
| -- Verify all boundaries have PostGIS geometry | ||
| DO $$ | ||
| DECLARE | ||
| boundary_count INTEGER; | ||
| migrated_count INTEGER; | ||
| BEGIN | ||
| SELECT COUNT(*) INTO boundary_count | ||
| FROM pois | ||
| WHERE poi_type = 'boundary'; | ||
|
|
||
| SELECT COUNT(*) INTO migrated_count | ||
| FROM pois | ||
| WHERE poi_type = 'boundary' | ||
| AND boundary_geom IS NOT NULL; | ||
|
|
||
| RAISE NOTICE 'Boundary migration: % of % boundaries have PostGIS geometry', | ||
| migrated_count, boundary_count; | ||
|
|
||
| IF migrated_count < boundary_count THEN | ||
| RAISE WARNING 'Some boundaries missing PostGIS geometry - check GeoJSON format'; | ||
| END IF; | ||
| END $$; | ||
|
|
||
| -- Create spatial index for boundary polygons (if not exists) | ||
| CREATE INDEX IF NOT EXISTS idx_pois_boundary_geom ON pois USING GIST (boundary_geom) | ||
| WHERE poi_type = 'boundary'; |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -114,7 +114,7 @@ const pool = new Pool({ | |||||
| host: process.env.PGHOST || 'localhost', | ||||||
| port: process.env.PGPORT || 5432, | ||||||
| database: process.env.PGDATABASE || 'rotv', | ||||||
| user: process.env.PGUSER || 'rotv', | ||||||
| user: process.env.PGUSER || 'postgres', // Use standard PostgreSQL superuser | ||||||
| password: process.env.PGPASSWORD || 'rotv', | ||||||
| // Background jobs use up to 10 concurrent connections | ||||||
| // Reserve extra for API requests to prevent blocking | ||||||
|
|
@@ -2612,7 +2612,7 @@ async function start() { | |||||
| startMcpServer(pool, app.get('boss'), parseInt(process.env.MCP_PORT || '3001')); | ||||||
| } | ||||||
|
|
||||||
| app.listen(PORT, '::', () => { | ||||||
| app.listen(PORT, '0.0.0.0', () => { | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changing the listening interface from
Suggested change
|
||||||
| console.log(`Roots of The Valley API running on port ${PORT}`); | ||||||
| }); | ||||||
| } | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Defaulting to the
postgressuperuser for application database connections is a significant security risk. It violates the principle of least privilege by granting the application full control over the entire database instance. It is highly recommended to use a dedicated application user with permissions restricted to the specific database.