-
Notifications
You must be signed in to change notification settings - Fork 3
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
restrict administration tab #242
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,6 @@ on: | |
branches: | ||
- main | ||
- dev* | ||
- fds* | ||
tags: | ||
- v[0-9]+.[0-9]+.[0-9]+ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,15 +30,18 @@ app_server <- function( input, output, session ) { | |
httr::authenticate(app$key, app$secret, type = "basic"), | ||
config = list() | ||
) | ||
# Stop the code if anything other than 2XX status code is returned | ||
|
||
# Stop the code if anything other than 2XX status code is returned | ||
httr::stop_for_status(req, task = "get an access token") | ||
token_response <- httr::content(req, type = NULL) | ||
access_token <- token_response$access_token | ||
|
||
session$userData$access_token <- access_token | ||
|
||
# hide things | ||
# sidebar | ||
shinyjs::hide(selector = ".sidebar-menu") | ||
shinyjs::hide(selector = "a[data-value='tab_administrator']") | ||
|
||
# SET UP REACTIVE VALUES ################################################### | ||
|
||
|
@@ -72,6 +75,18 @@ app_server <- function( input, output, session ) { | |
# CONFIGURE APP ############################################################ | ||
observeEvent(mod_select_dcc_out()$btn_click, { | ||
|
||
# update reactiveVals | ||
# FIXME: redundant (could get rid of selected_dcc_config_list) | ||
selected_dcc_config_list$synapse_asset_view( | ||
mod_select_dcc_out()$selected_dcc_config$dcc$synapse_asset_view | ||
) | ||
selected_dcc_config_list$manifest_dataset_id( | ||
mod_select_dcc_out()$selected_dcc_config$dcc$manifest_dataset_id | ||
) | ||
selected_dcc_config_list$schema_url( | ||
mod_select_dcc_out()$selected_dcc_config$dcc$data_model_url | ||
) | ||
|
||
selected_dcc_config(mod_select_dcc_out()$selected_dcc_config) | ||
|
||
# move to dashboard page | ||
|
@@ -89,28 +104,31 @@ app_server <- function( input, output, session ) { | |
color="#424874" | ||
) | ||
|
||
# show sidebar tabs | ||
# show sidebar menu | ||
shinyjs::show(selector = ".sidebar-menu") | ||
|
||
# update reactiveVals | ||
selected_dcc_config_list$synapse_asset_view( | ||
mod_select_dcc_out()$selected_dcc_config$dcc$synapse_asset_view | ||
) | ||
selected_dcc_config_list$manifest_dataset_id( | ||
mod_select_dcc_out()$selected_dcc_config$dcc$manifest_dataset_id | ||
) | ||
selected_dcc_config_list$schema_url( | ||
mod_select_dcc_out()$selected_dcc_config$dcc$data_model_url | ||
# check user's access | ||
# show admin tab if user has ADMIN access to data flow manifest | ||
manifest_admin_perm <- dfamodules::synapse_access( | ||
id = selected_dcc_config()$dcc$manifest_dataset_id, | ||
access = "CHANGE_PERMISSIONS", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Confirmed with Jay that using |
||
auth = access_token | ||
) | ||
|
||
if (isTRUE(manifest_admin_perm)) { | ||
shinyjs::show(selector = "a[data-value='tab_administrator']") | ||
} else { | ||
shinyjs::hide(selector = "a[data-value='tab_administrator']") | ||
} | ||
|
||
# Check that user has appropriate permissions to use DFA | ||
# User must have DOWNLOAD access to the DFA manifest. | ||
manifest_perm <- dfamodules::synapse_access( | ||
manifest_download_perm <- dfamodules::synapse_access( | ||
id = selected_dcc_config()$dcc$manifest_dataset_id, | ||
access = "DOWNLOAD", | ||
auth = access_token | ||
) | ||
if (!isTRUE(manifest_perm)) { | ||
if (!isTRUE(manifest_download_perm)) { | ||
shinypop::nx_report_error( | ||
title = "Permission error", | ||
message = tagList( | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been using shinyjs hide and show functions to manage when tabs are visible to the user. Through some googling it was brought to my attention that this isn't a very secure method. A user can easily bypass the hidden tab (see for more info).
I'm not really too worried about users "breaking in" to the data flow manifest, but there is a solution if we wanted to make this more secure. For example, using shinyjs::renderMenu() to dynamically render the menu rather than just hiding the tab.
I didn't come across this problem/solution until after implementing the hide/show method. So I figured it was worth putting it up to review to determine if this extra step is necessary.
Curious what you think @afwillia @milen-sage @mialy-defelice