Skip to content
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

previously set tenant is leaked, when RLS is disabled #43

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jordanstephens
Copy link

I frequently check RLS.current_tenant_id in my code to check if a current tenant has been specified, and I also use RLS.disable_for_block in a few places where no tenant is relevant. I was recently debugging a piece of code that could be run with or without a tenant. In this particular run, I was expecting no tenant to be set, but I noticed that RLS.current_tenant_id was set, even though I was within a RLS.disable_for_block block and RLS.disabled? was false. I could check for both RLS.enabled? && RLS.current_tenant_id, but I think it would be less error-prone to return nil for RLS.current_tenant_id and RLS.current_user_id if RLS.disabled? is true.

What do you think? Happy to push this further, if you think this could be improved more.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant