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

Priv #13

Open
wants to merge 51 commits into
base: main
Choose a base branch
from
Open

Priv #13

Changes from 1 commit
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
5b16f20
#3 privileges work
sckott Oct 21, 2024
3892677
#3 #4 added brainstorming code for policies as real code, fixed a tes…
sckott Oct 24, 2024
304dd47
only run examples if interactive
sckott Oct 29, 2024
5b4b5a9
#5 add with_db_user fxn
sckott Oct 29, 2024
65159c4
remove pkg loading messages/warnings
sckott Nov 4, 2024
b3ee90e
docs url fix
sckott Nov 4, 2024
f7c607d
add fxn rls_privileges to get overview of table and column level priv…
sckott Nov 4, 2024
14bfa57
run on all branches
sckott Nov 5, 2024
14b5fe5
add new vignette with basic important info on privileges and policies…
sckott Nov 5, 2024
b49b76a
gitignore s7 file
sckott Nov 8, 2024
898d48a
dont check system clock in r cmd check
sckott Nov 8, 2024
2ad5c83
limit to 4 sql commands we support in vignette
sckott Nov 8, 2024
6fd941a
#4 rework privilege methods
sckott Nov 8, 2024
564d0b2
styling
sckott Nov 8, 2024
0c1ae51
update man files
sckott Nov 8, 2024
2754bf9
added row policy fns
sckott Nov 12, 2024
5d98b0a
make passwd table setup example actually work from scratch
sckott Nov 12, 2024
b0f8b7b
#4 more tabular work for privileges and row policies
sckott Nov 12, 2024
de0687c
add as_con s3 method for privilege class
sckott Nov 13, 2024
45a156e
cleanup translate_privilege, add fxn rls policy exists, add test help…
sckott Nov 13, 2024
8c362fd
organize pkgdown config file
sckott Nov 13, 2024
e6304a9
overwrite = true in all dbWriteTable in test
sckott Nov 13, 2024
c6f8653
add helper fxn from tests for dropping all policies to pkg fxn, make …
sckott Nov 14, 2024
4da1d2b
add clean command to Makefile to clean out check folder and targz man…
sckott Nov 14, 2024
020da39
removed tests for old rls fxns, added some new tests
sckott Nov 14, 2024
8038f3b
move old rls create and construct fxns to inst/ignore; fix some small…
sckott Nov 14, 2024
75a0933
moved as_con to a separate R file
sckott Nov 14, 2024
66fa7fa
update vignette to use current fxns for row and column level stuff
sckott Nov 14, 2024
c5a9a4a
#10 make more examples self contained and clean up, not done yet
sckott Nov 15, 2024
b4cfcdc
fix #10 all examples i think are self contained and clean up
sckott Nov 15, 2024
d7b02b7
Merge branch 'priv' into with
sckott Dec 6, 2024
221da97
Merge pull request #11 from getwilds/with
sckott Dec 6, 2024
537fd89
fix namespace and with_db_user
sckott Dec 6, 2024
5533fd5
pkgdown config: remove some, add one
sckott Dec 6, 2024
86d8284
add lightswitch for dark/light toggle in pkgdown docs
sckott Dec 6, 2024
f706160
add more info on current_user here and there
sckott Dec 10, 2024
0673c25
fix #15 add restrictive fxn for as part of RLS policy; update vignette
sckott Dec 11, 2024
062efa6
change rls_run to rls_perform, fix missing param def for restrictive fun
sckott Dec 11, 2024
2076fa0
fix pkgdown reference for perform fxn
sckott Dec 11, 2024
66698eb
change output of rls_perform to a tibble upon success; remains error …
sckott Dec 11, 2024
7922b36
add rls_role_exists to easily check for roles or users
sckott Dec 11, 2024
c0ef212
drop NSE for row policy existing and new functions, just use sql input
sckott Dec 11, 2024
a738528
inject helper message into postgres default check for each test run w…
sckott Jan 3, 2025
b09b3cc
added PGPASSWORD to postgres helper for running tests
sckott Feb 3, 2025
977b9f4
replace all uses of rls_run with rls_perform
sckott Feb 3, 2025
aac9db2
improve revoke and grant egs
sckott Feb 3, 2025
ef01ab8
update docs and egs for privileges fxns: grant, revoke, to, from, tra…
sckott Feb 4, 2025
180f152
policies.R functions: tweaks and such
sckott Feb 4, 2025
c0ebbad
remove code in print.row_policy that was a hold over from copy/paste …
sckott Feb 4, 2025
c06d138
examples tweaks, update docs
sckott Feb 4, 2025
915b0ea
improve with_db_user example reproducibilty
sckott Feb 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
styling
sckott committed Nov 8, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 564d0b29ec33cbbf41d0a39b946cfff2f572d45d
2 changes: 1 addition & 1 deletion R/as_priv.R
Original file line number Diff line number Diff line change
@@ -26,7 +26,7 @@ print.privilege <- function(x, ...) {
if (!is_really_empty(x$privilege)) {
cat_me("type", x$type)
for (i in x$privilege) {
cat_me(x=i$commands, y=i$cols %|||% "<all cols>", indent = " ")
cat_me(x = i$commands, y = i$cols %|||% "<all cols>", indent = " ")
}
}
print(x$data)
16 changes: 8 additions & 8 deletions R/examples.R
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#' Setup for running examples throughout this package
#'
#'
#' @name passwd
#' @examplesIf interactive() && has_postgres()
#' con <- dbConnect(Postgres())
#' user <- dbGetQuery(con, "select current_user")$current_user
#' # Create a table
#' ## Create the table (with no data)
#'
#'
#' invisible(dbExecute(con, "
#' CREATE TABLE passwd (
#' user_name text UNIQUE NOT NULL,
@@ -19,22 +19,22 @@
#' shell text NOT NULL
#' );
#' "))
#'
#'
#' # Some sample data
#' sample_data <- tribble(
#' ~user_name, ~pwhash, ~uid, ~gid, ~real_name, ~home_phone, ~home_dir, ~shell,
#' 'admin','xxx',0,0,'Admin','111-222-3333','/root','/bin/dash',
#' 'bob','xxx',1,1,'Bob','123-456-7890','/home/bob','/bin/zsh',
#' 'alice','xxx',2,1,'Alice','098-765-4321','/home/alice','/bin/zsh'
#' "admin", "xxx", 0, 0, "Admin", "111-222-3333", "/root", "/bin/dash",
#' "bob", "xxx", 1, 1, "Bob", "123-456-7890", "/home/bob", "/bin/zsh",
#' "alice", "xxx", 2, 1, "Alice", "098-765-4321", "/home/alice", "/bin/zsh"
#' )
#'
#'
#' # Append rows to the `passwd` table
#' rows_append(
#' tbl(con, "passwd"),
#' copy_inline(con, sample_data),
#' in_place = TRUE
#' )
#'
#'
#' # Check that the data is in the table
#' tbl(con, "passwd")
NULL
6 changes: 4 additions & 2 deletions R/pipeline.R
Original file line number Diff line number Diff line change
@@ -45,8 +45,10 @@ pipeline_info <- function() {

is_piped <- any(is_magrittr_env)

list(is_piped = is_piped,
env = if (is_piped) sys.frames()[[max(which(is_magrittr_env))]])
list(
is_piped = is_piped,
env = if (is_piped) sys.frames()[[max(which(is_magrittr_env))]]
)
}

#' Toggle Auto Execution On or Off for Pipelines
12 changes: 7 additions & 5 deletions R/privileges.R
Original file line number Diff line number Diff line change
@@ -103,7 +103,7 @@ from <- to
#' # ON fruits
#' # TO jane
#' priv <-
#' rls_tbl(con, "fruits") %>%
#' rls_tbl(con, "fruits") %>%
#' grant(select) %>%
#' to(jane)
#' translate_privilege(priv, con)
@@ -112,7 +112,7 @@ from <- to
#' # ON fruits
#' # FROM jane
#' priv <-
#' rls_tbl(con, "fruits") %>%
#' rls_tbl(con, "fruits") %>%
#' revoke(select) %>%
#' from(jane)
#' translate_privilege(priv, con)
@@ -122,7 +122,7 @@ from <- to
#' # ON fruits
#' # TO jane
#' priv <-
#' rls_tbl(con, "fruits") %>%
#' rls_tbl(con, "fruits") %>%
#' grant(select, cols = c("apples", "strawberries")) %>%
#' to(jane)
#' sql <- translate_privilege(priv, con)
@@ -136,13 +136,15 @@ translate_privilege <- function(priv, con) {

table_cols <- collapse(lapply(priv$privilege, \(w) {
cols <- collapse(w$cols)
sprintf("%s %s",
sprintf(
"%s %s",
collapse(w$commands),
ifelse(is_really_empty(cols), "", glue("({cols})"))
)
}))

query <- sprintf(template,
query <- sprintf(
template,
table_cols,
attr(priv$data, "table"),
priv$user