-
Notifications
You must be signed in to change notification settings - Fork 81
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
Selective Tab Security Implementation with shinymanager #185
Comments
Hi @henrykironde, I'm using library(shiny)
library(glue)
library(shinymanager)
credentials <- data.frame(
user = c("user1", "user2", "user3"),
password = c("123", "456", "789"),
restricted = c("mod1", "mod1,mod2", NA_character_)
)
mod_ui <- function(id) {
ns <- NS(id)
tagList(
textOutput(ns("out"))
)
}
mod_server <- function(id, toprint) {
moduleServer(id, function(input, output, session) {
ns <- session$ns
output$out <- renderText({ toprint })
return(toprint)
})
}
ui <- secure_app(
navbarPage(
"Selective Feature",
id = "current_tab",
tabPanel(
"main",
"Nothing to do here"
),
tabPanel("mod1", mod_ui("id1")),
tabPanel("mod2", mod_ui("id2"))
)
)
server <- function(input, output, session) {
rv_auth <-
secure_server(
check_credentials = check_credentials(credentials)
)
rv <-
reactiveValues(
user = reactive({
rv_auth$user
}),
current_tab = reactive({
input$current_tab
}),
restricted_section = reactive({
tryCatch(
unlist(strsplit(rv_auth$restricted, ",")),
error = function(e) NA_character_
)
})
)
observe({
lapply(
rv$restricted_section(),
\(x) removeUI(selector = glue("a[data-value='{x}']"))
)
})
observe({
if (rv$current_tab() == "mod1" && is.null(rv$mod1)) {
rv$mod1 <- mod_server("id1", "Hello")
}
if (rv$current_tab() == "mod2" && is.null(rv$mod2)) {
rv$mod2 <- mod_server("id2", "World")
}
}) |>
bindEvent(rv$current_tab())
}
shinyApp(ui, server) |
Thank you @henrykironde for raising this feature. I also would like to secure some Tabs and leave others open to everyone. |
Hello
thank you! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We are exploring the possibility of implementing selective tab security using the shinymanager package.
Our goal is to secure specific tabs while leaving others unsecured. For instance, we want to secure the 'Private Data' tab, requiring authentication, while leaving tabs like the landing page, About, and public data pages accessible without authentication.
We would like to discuss and understand the recommended approach or any existing features within shinymanager that support this selective tab security implementation. Any insights or guidance on how to achieve this would be highly appreciated
The text was updated successfully, but these errors were encountered: