Skip to content

Commit

Permalink
change rls_run to rls_perform, fix missing param def for restrictive fun
Browse files Browse the repository at this point in the history
  • Loading branch information
sckott committed Dec 11, 2024
1 parent 0673c25 commit 062efa6
Show file tree
Hide file tree
Showing 20 changed files with 32 additions and 28 deletions.
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ export(rls_drop_policies)
export(rls_drop_policy)
export(rls_enable)
export(rls_list_roles)
export(rls_perform)
export(rls_permissions)
export(rls_policies)
export(rls_policy_exists)
export(rls_privileges)
export(rls_run)
export(rls_table_privileges)
export(rls_tbl)
export(row_policy)
Expand Down
4 changes: 2 additions & 2 deletions R/drop.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@
#' policy1 <- rls_tbl(con, "atable") %>%
#' row_policy("hide_confidential") %>%
#' rows_existing(TRUE)
#' rls_run(policy1)
#' rls_perform(policy1)
#'
#' rls_policies(con)
#' rls_drop_policy(con, policy1)
#' rls_policies(con)
#'
#' rls_run(policy1)
#' rls_perform(policy1)
#' rls_policies(con)
#' rls_drop_policies(con)
#' rls_policies(con)
Expand Down
2 changes: 1 addition & 1 deletion R/exists.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#' rows_existing(TRUE) %>%
#' to(jane)
#' policy
#' rls_run(policy)
#' rls_perform(policy)
#' rls_policies(con)
#' rls_policy_exists(con, "some_policy")
#' rls_drop_policy(con, name = "some_policy", table = "attitude")
Expand Down
2 changes: 1 addition & 1 deletion R/list.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#' row_policy("all_view") %>%
#' commands(select) %>%
#' rows_existing(TRUE) %>%
#' rls_run()
#' rls_perform()
#' rls_policies(con)
#' rls_drop_policies(con)
#' dbRemoveTable(con, "attitude")
Expand Down
4 changes: 2 additions & 2 deletions R/run.R → R/perform.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#' Run a query
#' Perform a query
#'
#' @export
#' @param query an s3 object of class `privilege` or `row_policy, required.
Expand All @@ -7,7 +7,7 @@
#' @param con DBI connection object, optional, see `query`
#' @return error from PostgreSQL or Redshift upon error, or an integer
#' value
rls_run <- function(query, con = NULL) {
rls_perform <- function(query, con = NULL) {
assert_is(query, c("privilege", "row_policy"))
con <- as_con(query %||% con)
is_conn(con)
Expand Down
2 changes: 1 addition & 1 deletion R/pipeline.R
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ pipe_autoexec <- function(toggle) {
if (isTRUE(info[["is_piped"]])) {
rls_exit <- function(x) {
if (inherits(x, c("privilege", "row_policy"))) {
rls_run(x, x$data$src$con)
rls_perform(x, x$data$src$con)
} else {
x
}
Expand Down
4 changes: 2 additions & 2 deletions R/policies.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ rls_current_user <- function(con) {
#' rls_tbl(con, "passwd") %>%
#' grant(select, cols = columns) %>%
#' to(sammy) %>%
#' rls_run()
#' rls_perform()
#' # Just user sammy
#' rls_column_privileges(con, "passwd", "sammy")
#' # All users
Expand Down Expand Up @@ -172,7 +172,7 @@ table_privileges_query <- function(con, table, schema, user_role, urtable,
#' row_policy(name = "stuff") %>%
#' rows_existing(TRUE) %>%
#' to(jane) %>%
#' rls_run()
#' rls_perform()
#'
#' rls_privileges(con, "passwd", "jane")
#'
Expand Down
2 changes: 1 addition & 1 deletion R/rls_tbl.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#' rls_tbl(con, "passwd") %>%
#' grant(select) %>%
#' to(ally) %>%
#' rls_run()
#' rls_perform()
#' dbExecute(con, "SET SESSION AUTHORIZATION ally")
#' rls_tbl(con, "passwd")
#' dbExecute(con, glue::glue("SET SESSION AUTHORIZATION {user}"))
Expand Down
3 changes: 2 additions & 1 deletion R/row_policy.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#' }
#' rls_tbl(con, "passwd") %>%
#' row_policy("my_policy") %>%
#' rls_run()
#' rls_perform()
#' rls_policies(con)
#'
#' # cleanup
Expand Down Expand Up @@ -166,6 +166,7 @@ express <- function(x) {
#' Set RLS policy to be restrictive
#'
#' @export
#' @inheritParams grant
#' @inherit row_policy return
#' @details By default row level policies are permissive. Permissive policies
#' are applied using a boolean "OR", so you need permission from only one
Expand Down
3 changes: 3 additions & 0 deletions man/restrictive.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/rls_column_privileges.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/rls_drop_policy.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions man/rls_run.Rd → man/rls_perform.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/rls_policies.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/rls_policy_exists.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/rls_privileges.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/rls_tbl.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/row_policy.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/testthat/test-rls_drop_policy.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ test_that("rls_drop_policy", {
row_policy("hide_confidential") %>%
rows_existing(TRUE)

rls_run(the_policy)
rls_perform(the_policy)

policies_before <- rls_policies(con)
out <- rls_drop_policy(con, the_policy)
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-rls_policies.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ test_that("rls_policies", {
commands(select) %>%
rows_existing(TRUE)

rls_run(my_policy)
rls_perform(my_policy)

policies <- rls_policies(con)

Expand Down

0 comments on commit 062efa6

Please sign in to comment.