-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/Sage-Bionetworks/release_ad…
- Loading branch information
Showing
7 changed files
with
91 additions
and
54 deletions.
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
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
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
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 |
---|---|---|
@@ -1,23 +1,60 @@ | ||
## Set Up Virtual Environment | ||
# ShinyAppys has a limit of 7000 files which this app' grossly exceeds | ||
# due to its Python dependencies. To get around the limit we zip up | ||
# the virtual environment before deployment and unzip it here. | ||
# SET UP OAUTH | ||
oauth_client <- yaml::yaml.load_file("oauth_config.yml") | ||
|
||
# unzip virtual environment, named as ".venv.zip" | ||
if (!file.exists(".venv")) utils::unzip(".venv.zip") | ||
client_id <- toString(oauth_client$client_id) | ||
client_secret <- toString(oauth_client$client_secret) | ||
app_url <- toString(oauth_client$app_url) | ||
|
||
# We get a '126' error (non-executable) if we don't do this: | ||
system("chmod -R +x .venv") | ||
if (is.null(client_id) || nchar(client_id) == 0) stop("missing DCA_CLIENT_ID environmental variable") | ||
if (is.null(client_secret) || nchar(client_secret) == 0) stop("missing DCA_CLIENT_SECRET environmental variable") | ||
if (is.null(app_url) || nchar(app_url) == 0) stop("missing DCA_APP_URL environmental variable") | ||
|
||
# Activate virtual env | ||
Sys.unsetenv("RETICULATE_PYTHON") | ||
reticulate::use_virtualenv(file.path(getwd(), ".venv"), required = TRUE) | ||
|
||
# set shiny port | ||
# update port if running app locally | ||
if (interactive()) { | ||
options(shiny.port = 8100) | ||
port <- httr::parse_url(app_url)$port | ||
if (is.null(port)) stop("running locally requires a TCP port that the application should listen on") | ||
options(shiny.port = as.numeric(port)) | ||
} | ||
|
||
has_auth_code <- function(params) { | ||
# params is a list object containing the parsed URL parameters. Return TRUE if | ||
# based on these parameters, it looks like auth code is present that we can | ||
# use to get an access token. If not, it means we need to go through the OAuth | ||
# flow. | ||
return(!is.null(params$code)) | ||
} | ||
|
||
message(Sys.getenv()) | ||
app <- httr::oauth_app("shinysynapse", | ||
key = client_id, | ||
secret = client_secret, | ||
redirect_uri = app_url | ||
) | ||
|
||
# These are the user info details ('claims') requested from Synapse: | ||
claims <- list( | ||
family_name = NULL, | ||
given_name = NULL, | ||
email = NULL, | ||
email_verified = NULL, | ||
userid = NULL, | ||
orcid = NULL, | ||
is_certified = NULL, | ||
is_validated = NULL, | ||
validated_given_name = NULL, | ||
validated_family_name = NULL, | ||
validated_location = NULL, | ||
validated_email = NULL, | ||
validated_company = NULL, | ||
validated_at = NULL, | ||
validated_orcid = NULL, | ||
company = NULL | ||
) | ||
|
||
claimsParam <- jsonlite::toJSON(list(id_token = claims, userinfo = claims)) | ||
api <- httr::oauth_endpoint( | ||
authorize = paste0("https://signin.synapse.org?claims=", claimsParam), | ||
access = "https://repo-prod.prod.sagebase.org/auth/v1/oauth2/token" | ||
) | ||
|
||
OAUTH_LIST <- projectlive.modules::create_oauth_list("oauth_config.yml") | ||
# The 'openid' scope is required by the protocol for retrieving user information. | ||
scope <- "openid view download modify" |
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
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