Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
    • Switch to GitLab Next
  • Sign in / Register
M
massive-js
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 9
    • Issues 9
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 2
    • Merge Requests 2
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Security & Compliance
    • Security & Compliance
    • Dependency List
    • License Compliance
  • Operations
    • Operations
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Container Registry
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Dian Fay
  • massive-js
  • Issues
  • #291

Closed
Open
Opened Jul 24, 2016 by Benjie Gillam@benjie1Contributor

Wrapping connections, e.g. for Row Level Security?

Hey, great project! One of the recent awesome features Postgres has added in 9.5 is Row Level Security (RLS); I really want to use that in combination with the simple update/insert/etc features in massive (as well as the file query features). However, for this to be really useful you really need to be able to insert some per-query authentication into the database after massive has booted up (we don't want to do all those table and file scans again!); e.g. we want to wrap every "pg.connect" with something like:

begin;
set local role users;
set local claims.user_id to 7;

-- Do the intended query here

commit;

I was hoping to come up with a proof of concept to demostrate RLS working with massive; but alas due to how Entities work (keeping a reference via this.db = args.db) I couldn't do it the way I was planning. Nonetheless I've shared my work in progress to help you see what I'm getting at here:

https://github.com/benjie/massive-js/commit/336977b6dd9282369f49103904989999636f9f59

I've tried to implement it in a generic way such that the wrapping function isn't tied specifically to RLS, but could be used for other features too - anything that needs to change on a per-user/per-request/per-query basis but doesn't want to incur massive's startup cost. Intention is to do something like:

const superuserDb = massive.connectSync(URL);

const app = express();

app.use((req, res, next) => {
  req.db = superuserDb.withConnectionWrapper(connectionWrapperForUserId(req.session.user_id));
  next();
});

app.use((req, res, next) => {
  req.db.posts.find(7, ...);
});

What are your thoughts on implementing something like this?

Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: dmfay/massive-js#291