Closed PaulC91 closed 5 years ago
Paul, unfortunately it is not possible for now. To make it work you should copy the global scripts to the app.R file, as you suggested.
As an alternative, you can use source() to run big scripts in app.R without flooding it, including global.R. That's what we do in some of our apps in production.
On Tue, Mar 5, 2019, 10:34 Paul Campbell notifications@github.com wrote:
Thanks for this great package! I've previously setup auth0 with a shiny-server manually but this makes it so much easier.
I'm just wondering if it's possible to use auth0 with apps that have been setup with separate ui.R, server.R and global.R scripts or would I have bring everything back into a single app.R file to be able to call auth0::shinyAuth0App(ui, server)?
Thanks, Paul
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/curso-r/auth0/issues/5, or mute the thread https://github.com/notifications/unsubscribe-auth/ABXCMiyheKH-Hr7N6v-dp13bkWwnnY5xks5vTnJogaJpZM4benbl .
Thanks for clarifying Julio!
Unrelated issue and most likely unrelated to this package but I've setup one of Auth0's rule templates to only allow logins from emails of a certain domain, but no matter what I try the rule is not being enforced and I can log into the app with any email address.
Just wondering if you have any idea why the rule is not being enforced by auth0?
Thanks, Paul
@jtrecenti this is the biggest issue and first one that I also thought about. Any real shiny app is going to be too big and complex to only use app.R
. I think it's a very important feature that is worth investing some time to look into (I don't have a good solution for you though, it's much easier for me to just say "please think about it!" :smile:).
At the very least, I propose that until the two file approach is truly supported, the following could be a temporary solution:
Add a function named makeAuth0App()
that, when called inside a directory that has ui.R+server.R (and potentially a global.R), it will rename ui.R to ui_auth0.R, server.R to server_auth0.R, and create an app.R file that simply sources the ui, server, and global, and runs it as an auth0 app. This is easier than forcing the dev to copy the file contents from 3 files into an app.R file, adding the correct syntax, and calling the right auth0 function at the end. This is just a proposal.
Paul, unfortunately it is not possible for now. To make it work you should copy the global scripts to the app.R file, as you suggested. As an alternative, you can use source() to run big scripts in app.R without flooding it, including global.R. That's what we do in some of our apps in production. … On Tue, Mar 5, 2019, 10:34 Paul Campbell @.***> wrote: Thanks for this great package! I've previously setup auth0 with a shiny-server manually but this makes it so much easier. I'm just wondering if it's possible to use auth0 with apps that have been setup with separate ui.R, server.R and global.R scripts or would I have bring everything back into a single app.R file to be able to call auth0::shinyAuth0App(ui, server)? Thanks, Paul — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#5>, or mute the thread https://github.com/notifications/unsubscribe-auth/ABXCMiyheKH-Hr7N6v-dp13bkWwnnY5xks5vTnJogaJpZM4benbl .
Hi, and congrats for this great package! @jtrecenti you mention that you source() iu.R and server.R in production. Do you deploy them as well?
Following your example, I deployed this and didn't work out as expected:
library(shiny)
library(auth0)
source('ui.R')
source('server.R')
shinyAppAuth0(ui, server)
With this error:
ERROR: An error has occurred. Check your logs or contact the app author for clarification.
In this case you must rename ui.R
and server.R
files to something else, like _ui.R
and _server.R
.
Thank you very much! With those renames, my app was successfully deployed.
I'm writing an app in a package, using the golem package and following their guidelines. ui
and server
are both functions with package scope so they are available to be passed to shinyAppAuth0
without having to source the files containing them. It works fine with auth0
.
Yeah, @kent37 we're working that way too and we are really happy with this workflow
I just realized that it's actually possible and super easy to use auth0 in a ui.R/server.R framework.
Take a look at this code:
library(shiny)
library(auth0)
a0_info <- auth0:::auth0_info(auth0:::auth0_config())
auth0:::auth0_ui(fluidPage(
# ui code goes here
logoutButton()
), info = a0_info)
library(shiny)
library(auth0)
a0_info <- auth0:::auth0_info(auth0:::auth0_config())
auth0:::auth0_server(function(input, output, session) {
# server code goes here
}, info = a0_info)
and the _auth0.yml
file in the directory.
This code runs smoothly using runApp()
, after setting the port (e.g. options(shiny.port = 8080)
)
If the user wants to, she/he can create the a0_info
object inside the global.R
file
@daattali what do you think?
If this approach is OK, I can document and export these 4 functions. We also could simplfly a0_info
to just one function.
Great!!! This is a huge part towards making auth0 much easier to use! I'm not on a computer so can't test it, but from your comment this looks perfect.
So essentially you just need to wrap both the UI and server functions in auth0 ui/server functions. Very easy for the user.
Would this work with any UI, regardless if it's a fluidPage, a navbarpage, an HTML template, just raw HTML tags, and most importantly if the ui is defined as ui <- function(req) {fluidPage(...)}
(to support bookmarking)?
Could the ui/server functions automatically infer the info parameter assuming the config file is in some default assumed location, and only if it's in a non standard path you'd need to use the info parameter?
PS. Does this mean your talk got accepted? :p
Don't know why the issue didn't close automatically with #43
Nice! Looking at the new README, it looks like you did eliminate the mandatory info param. This is really really great. I hope this also works on bookmarked apps.
It works for bookmarked apps! I've added an example
On Thu, Sep 19, 2019, 17:18 Dean Attali notifications@github.com wrote:
Nice! Looking at the new README, it looks like you did eliminate the mandatory info param. This is really really great. I hope this also works on bookmarked apps.
— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/curso-r/auth0/issues/5?email_source=notifications&email_token=AAK4EMUX5T6M3QHZMBWCBYLQKPM73A5CNFSM4G32O3S2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD7EWOVQ#issuecomment-533292886, or mute the thread https://github.com/notifications/unsubscribe-auth/AAK4EMR5TSWJCDQQKGRKEJ3QKPM73ANCNFSM4G32O3SQ .
Thanks for this great package! I've previously setup auth0 with a shiny-server manually but this makes it so much easier.
I'm just wondering if it's possible to use
auth0
with apps that have been setup with separateui.R
,server.R
andglobal.R
scripts or would I have bring everything back into a singleapp.R
file to be able to callauth0::shinyAuth0App(ui, server)
?Thanks, Paul