I am not new to programming, but I am very new to R Shiny.
A web portal will be linking to my R Shiny app (the app will be deployed to a shiny-server in a docker container), and the web portal will be passing some query string parameters to my app - an auth0 token, aud value, and the auth0 url where I should validate the token.
What I want to happen is once my app starts up, it gets the query parameters from the query string, validates the token with the auth0 url, and check that the "aud" value matches what is in the validated token.
I also want catch any errors and show just a "403 Forbidden" text . Currently, I've been bashing my head around trying to get this to work, but because of my limited experience with R and shiny, I have very little that works in my code. Any thorough explanation of code solutions would be super helpful.
What I have so far
server <- function(input, output, session){
# gets query string values
token <- reactive({getQueryString()$token})
authurl <- reactive({getQueryString()$authurl})
aud <- reactive({getQueryString()$aud})
# this currently makes sure the token validates and compares the "aud" value to what
# was received in the query string but i need to break this apart some how, to:
# 1) show "403 Forbidden" if the authurl is not present/bad/cannot connect
# 2) show "403 Forbidden" if the token is not present/bad
# 3) show "403 Forbidden" if the aud is not present/bad
# 4) show "OK" (eventually the app itself) if result is True and all is valid
result <- reactive({jwt_decode_sig(token(), read_jwk(fromJSON(rawToChar(GET(paste0("https://",authurl(),"/.well-known/jwks.json"))[["content"]]))$keys[[1]]))$aud == aud()})
# I'm using this to printout the value of the result() call as a test
output$token <- renderText({result()})
# this is what I'd like to use (or something like this) to determine if the user should
# be shown a "403" or the app itself. In running some tests, I don't believe this code
# actually executes. I don't know why.
shinyCatch(
if(result() == TRUE){
shinyjs::show("app-content")
shinyjs::hide("loading-content")
}
else{
shinyjs::show("error")
shinyjs::hide("loading-content")
}
)
}
TIA