标签:#hack
找到 10724 篇相关文章
A glitch in February of the year 0
South Korea to Train All Active-Duty Soldiers to Operate Drones
A little bird told her: scientist wins $100k prize for decoding birdsong
What is a Lithium-ion capacitor?
Type-checked non-empty strings
Why software engineers are grieving
Endive 1.0: WebAssembly on the JVM, Now a Bytecode Alliance Project
Ask HN: Is "no source code was copied" still a sufficient copyright defense?
We are all familiar with the Corgi event: https://x.com/mfts0/status/2070080422482977095 With the barrier to create new apps having dropped significantly thanks to LLMs, I am seeing more cases about copyright and unfair competition. I've seen and participated in some of these cases. Usually expert witnesses are required. Curious to hear the community stance on this one. "Now software developers are feeling what authors and artist felt". https://x.com/PriyRanjan96/status/2070204156703568377 There
How I built multi-tenant Row Level Security with Aurora PostgreSQL for a B2B SaaS — H0 Hackathon
I'll be honest: I almost did multi-tenancy the wrong way. When I started building InspectIQ "a SaaS platform for Florida home inspectors" my first instinct was to add a tenant_id column to every table and filter it in the application layer. Every query would have a WHERE tenant_id = :current_tenant clause. Simple, familiar, done. Then I thought about what happens when you forget one. One missing WHERE clause. One endpoint that skips the filter. One inspector sees another inspector's client data. In a home inspection business, that's not just a bug — it's a HIPAA-adjacent nightmare and a trust-destroying moment with your first customer. So I did it properly from day one: Row Level Security at the database layer. What is Row Level Security? RLS is a PostgreSQL feature that lets you define policies directly on tables. When a user queries a table, the policy runs automatically, before your application code even sees the results. You can't forget to apply it. You can't bypass it with a careless JOIN. It's enforced at the lowest possible layer. For a multi-tenant SaaS, this is exactly what you want. How I implemented it Every table in InspectIQ has this pattern: ALTER TABLE inspections ENABLE ROW LEVEL SECURITY ; ALTER TABLE inspections FORCE ROW LEVEL SECURITY ; CREATE POLICY tenant_isolation ON inspections USING ( tenant_id = NULLIF ( current_setting ( 'app.current_tenant_id' , true ), '' ):: uuid ); The FORCE is important — it applies the policy even to the table owner. No superuser backdoor. The tenant context comes from the JWT. When an inspector logs in, their tenant_id is embedded as a custom Cognito claim. The FastAPI middleware extracts it and sets it at the start of every request: await session . execute ( text ( f " SET LOCAL app.current_tenant_id = ' { tenant_id } '" ) ) SET LOCAL scopes the setting to the current transaction. When the transaction ends, it's gone. No leakage between requests. Aurora PostgreSQL Serverless v2 I'm running this on Aurora PostgreSQ