| Type: | Package |
| Title: | Authentication in Shiny with Auth0 |
| Version: | 0.2.3 |
| Description: | Uses Auth0 API (seehttps://auth0.com for more information) to use a simple authentication system. It provides tools to log in and out a shiny application using social networks or a list of e-mails. |
| BugReports: | https://github.com/curso-r/auth0/issues |
| License: | MIT + file LICENSE |
| Encoding: | UTF-8 |
| RoxygenNote: | 7.2.3 |
| Imports: | httr, shiny, yaml, utils, shinyjs |
| Suggests: | knitr, rmarkdown |
| VignetteBuilder: | knitr |
| URL: | https://curso-r.github.io/auth0/ |
| NeedsCompilation: | no |
| Packaged: | 2023-03-22 18:59:25 UTC; julio |
| Author: | Julio Trecenti [cre], Daniel Falbel [aut], José Jesus [ctb], Dean Attali [ctb], C Lente [ctb] |
| Maintainer: | Julio Trecenti <julio.trecenti@gmail.com> |
| Repository: | CRAN |
| Date/Publication: | 2023-03-26 21:50:05 UTC |
Parse_auth0.yml file.
Description
Validates and creates a list of useful information fromthe_auth0.yml file.
Usage
auth0_config(config_file)Arguments
config_file | path to the |
Value
List containing all the information from the_auth0.yml file.
Find the configuration file.
Description
Tries to find the path to the_auth0.yml file. First, it tries to getthis info fromoptions(auth0_config_file = ). If this option isNULL(the default) it tries to find the_auth0.yml within the workingdirectory. If the file does not exist, it raises an error.
Usage
auth0_find_config_file()Value
Character vector of length one contaning the path of the_auth0.yml file.
See Also
Information used to connect to Auth0.
Description
Creates a list containing all the important information to connect to Auth0service's API.
Usage
auth0_info(config)Arguments
config | path to the |
Value
A list contaning scope, state, keys, OAuth2.0 app, endpoints,audience andremote URL. For compatibility reasons,remote_url can be either a parameterin the root yaml or inside ashiny_config parameter.
See Also
use_auth0 to create an_auth0.yml template.
Generate logout URL
Description
auth0_logout_url() is defunct as of auth0 0.1.2 in order to simplifly theuser experience with thelogoutButton() function.
Usage
auth0_logout_url(config_file = NULL, redirect_js = TRUE)Arguments
config_file | Path to YAML configuration file. |
redirect_js | include javascript code to redirect page? Defaults to |
Examples
# simple UI with action button# AFTER auth0 0.1.2if (interactive()) { library(shiny) library(auth0) ui <- fluidPage(logoutButton()) server <- function(input, output, session) {} config_file <- system.file("simple/_auth0.yml", package = "auth0") shinyAppAuth0(ui, server, config_file) # simple UI with action button # BEFORE auth0 0.1.2 library(shiny) library(auth0) library(shinyjs) # note that you must include shinyjs::useShinyjs() for this to work ui <- fluidPage(shinyjs::useShinyjs(), actionButton("logout_auth0", "Logout")) # server with one observer that logouts server <- function(input, output, session) { observeEvent(input$logout_auth0, { # javascript code redirecting to correct url js <- auth0_logout_url() shinyjs::runjs(js) }) } shinyAuth0App(ui, server, config_file)}Log out of an auth0 app
Description
Log the current user out of an auth0 shiny app.
Usage
logout()Details
You can also use a diferent configuration file by setting theauth0_config_file option with:options(auth0_config_file = "path/to/file.yaml").
See Also
Create a button to log out
Description
AlogoutButton is anactionButton that is meantto be used to log out of an auth0 Shiny app.
Usage
logoutButton(label = "Log out", ..., id = "._auth0logout_")Arguments
label | The label on the button. |
... | Named attributes to apply to the button. |
id | An ID for the button. If you only have one logout button inyour app, you do not need to explicitly provide an ID. If you have more thanone logout button, you need to provide a unique ID to each button. When youcreate a button with a non-default ID, you must create an observer thatlistens to a click on this button and logs out of the app with a call to |
See Also
Examples
if (interactive()) { ui <- fluidPage( logoutButton(), logoutButton(label = "Another logout button", id = "logout2") ) server <- function(input, output, session) { observeEvent(input$logout2, { logout() }) } shinyAuth0App(ui, server)}Generate a logout URL
Description
Generate a URL that will log the user out of the app if visited.
Usage
logout_url()Details
You can also use a diferent configuration file by setting theauth0_config_file option with:options(auth0_config_file = "path/to/file.yaml").
Value
URL string to log out.
See Also
Create a Shiny app object with Auth0 Authentication
Description
This function modifies ui and server objects to run using Auth0authentication.
Usage
shinyAppAuth0(ui, server, config_file = NULL, ...)Arguments
ui | an ordinary UI object to create shiny apps. |
server | an ordinary server object to create shiny apps. |
config_file | path to YAML configuration file. |
... | Other arguments passed on to |
Details
You can also use a diferent configuration file by setting theauth0_config_file option with:options(auth0_config_file = "path/to/file.yaml").
Disable auth0 while developing apps
Sometimes, using auth0 to develop and test apps can be frustrating,because every time the app is started, auth0 requires the user to log-in.To avoid this problem, one can runoptions(auth0_disable = TRUE) todisable auth0 temporarily.
Create a Shiny app object with Auth0 Authentication
Description
As of auth0 0.1.2,shinAuth0App() hasbeen renamed toshinyAppAuth0() for consistency.
Usage
shinyAuth0App(ui, server, config_file = NULL)Arguments
ui | an ordinary UI object to create shiny apps. |
server | an ordinary server object to create shiny apps. |
config_file | path to YAML configuration file. |
Modifies ui/server objects to authenticate using Auth0.
Description
These functions can be used in a ui.R/server.R framework, modifying theshiny objects to authenticate using Auth0 service with no pain.
Usage
auth0_ui(ui, info)auth0_server(server, info)Arguments
ui |
|
info | object returned fromauth0_info. If not informed,will try to find the |
server | the shiny server function. |
See Also
Examples
# first, create the yml file using use_auth0() functionif (interactive()) { # ui.R file library(shiny) library(auth0) auth0_ui(fluidPage(logoutButton())) # server.R file library(auth0) auth0_server(function(input, output, session) {}) # console options(shiny.port = 8080) shiny::runApp()}Auth0 configuration file
Description
Create an YAML containing information to connect with Auth0.
Usage
use_auth0(path = ".", file = "_auth0.yml", overwrite = FALSE)Arguments
path | Directory name. Should be the root of the shiny appyou want to add this functionality |
file | File name. Defaults to |
overwrite | Will only overwrite existing path if |
Details
The YAML configuration file has required parameters and extraparameters.
The required parameters are:
auth0_configis a list contaning at least:api_url: Your account at Auth0 (e.g. https://jonhdoe.auth0.com).It is the "Domain" in Auth0 application settings.credentials: Your credentials to access Auth0 API, includingkey: the Client ID in Auth0 application settings.secret: the Client Secret in Auth0 application settings.
The extra parameters are:
remote_url: If you are using Shiny-Server or ShinyApps IO service.scope: The information that Auth0 app will access.Defaults to "openid profile".request: Endpoit to request a token. Defaults to "oauth/token"access: Endpoit to access. Defaults to "oauth/token"