Title: | Authentication and Hosting for 'shiny' Apps |
---|---|
Description: | Authentication, user administration, hosting, and additional infrastructure for 'shiny' apps. See <https://polished.tech> for additional documentation and examples. |
Authors: | Andy Merlino [aut, cre], Patrick Howard [aut], Tychobra LLC [cph, fnd] |
Maintainer: | Andy Merlino <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.8.1 |
Built: | 2024-11-12 05:27:16 UTC |
Source: | https://github.com/tychobra/polished |
Polished API - Add an App
add_app(app_name, app_url = NULL, api_key = get_api_key())
add_app(app_name, app_url = NULL, api_key = get_api_key())
app_name |
the app name. |
app_url |
an optional app url. This url will be included in links sent out in invite and email verification emails to redirect your users to your app. |
api_key |
your Polished API key. Set your polished api key using |
an object of class polished_api_res
. When successful, the content
of the
polished_api_res
is list(message = "success")
. In the case of an error, the
content is list(error = "<error message>")
.
get_apps()
update_app()
delete_app()
Polished API - Add a User to an App
add_app_user( app_uid, user_uid = NULL, email = NULL, is_admin = FALSE, send_invite_email = FALSE, api_key = get_api_key() )
add_app_user( app_uid, user_uid = NULL, email = NULL, is_admin = FALSE, send_invite_email = FALSE, api_key = get_api_key() )
app_uid |
the app uid. |
user_uid |
an optional user uid for the user to be invited to the app. |
email |
an optional email address for the user to be invited to the app. |
is_admin |
boolean (default: |
send_invite_email |
boolean - whether or not to send the user an invite email notifying them they have been invited to access the app. |
api_key |
your Polished API key. Set your polished api key using |
supply either the user_uid
or email
. If both are provided, then
the user_uid
will be used, and the email
will be ignored.
an object of class polished_api_res
. When successful, the content
of the
polished_api_res
is list(message = "success")
. In the case of an error, the
content is list(error = "<error message>")
.
get_app_users()
update_app_user()
delete_app_user()
Add authentication to the openapi plumber spec so that you can use the swagger
documentation with the auth_filter()
.
add_auth_to_spec(method = c("basic", "cookie"))
add_auth_to_spec(method = c("basic", "cookie"))
method |
the authentication method(s) |
This minimal API example https://github.com/Tychobra/polished_example_apps/blob/master/11_plumber/api/00_start.R shows how you can add this function to your API.
a function to update the openapi spec.
Polished API - Add a Role
add_role(role_name, api_key = get_api_key())
add_role(role_name, api_key = get_api_key())
role_name |
a role name. |
api_key |
your Polished API key. Set your polished api key using |
an object of class polished_api_res
. When successful, the content
of the
polished_api_res
is list(message = "success")
. In the case of an error, the
content is list(error = "<error message>")
.
Polished API - Add a User
add_user(email, api_key = get_api_key())
add_user(email, api_key = get_api_key())
email |
the new user's email address. |
api_key |
your Polished API key. Set your polished api key using |
an object of class polished_api_res
. When successful, the content
of the
polished_api_res
is list(message = "success")
. In the case of an error, the
content is list(error = "<error message>")
.
get_users()
update_user()
delete_user()
Polished API - Add a User Role
add_user_role( user_uid, role_uid = NULL, role_name = NULL, api_key = get_api_key() )
add_user_role( user_uid, role_uid = NULL, role_name = NULL, api_key = get_api_key() )
user_uid |
a user uid. |
role_uid |
an optional role uid. |
role_name |
an optional role name. |
api_key |
your Polished API key. Set your polished api key using |
one of either role_uid
or role_name
must be provided. If
both are provided, only the role_uid
will be used.
an object of class polished_api_res
. When successful, the content
of the
polished_api_res
is list(message = "success")
. In the case of an error, the
content is list(error = "<error message>")
.
get_user_roles()
delete_user_role()
The UI portion of the 'shiny' module for the button to navigate to the "Admin Panel". This is the button that, when clicked, navigates a 'polished' admin from your 'shiny' app to the 'polished' Admin Panel. If your app is set up with the default 'polished' configuration, this button appears in the bottom right of your 'shiny' app.
admin_button_ui(align = "right", vertical_align = "bottom")
admin_button_ui(align = "right", vertical_align = "bottom")
align |
The horizontal alignment of the button. Valid options are "right" (the default) or "left". |
vertical_align |
the vertical alignment of the button. Valid options are "bottom" (the default) or "top" |
admin button UI
The Shiny module server logic for the polished
Admin Panel, accessible to Admin users.
admin_server(input, output, session)
admin_server(input, output, session)
input |
the Shiny server input |
output |
the Shiny server output |
session |
the Shiny server session |
invisible(NULL)
The shiny
module UI for the polished
Admin Panel, accessible to Admin users.
admin_ui(options = default_admin_ui_options())
admin_ui(options = default_admin_ui_options())
options |
list of HTML elements to customize branding of "Admin Panel". Valid
list element names are |
the UI for the "Admin Panel"
In order to avoid issues with converting R data frames into JSON objects and back to R data frames, we instead convert R data frames to R lists before converting them to JSON to be sent via the Polished API. This function then converts those lists back into R data frames (or more precisely tibbles).
api_list_to_df(api_list)
api_list_to_df(api_list)
api_list |
a list. All elements in the list are vectors of the same length. |
a tibble
Auth filter for a Plumber API
auth_filter(method = c("basic", "cookie"), api_key = get_api_key())
auth_filter(method = c("basic", "cookie"), api_key = get_api_key())
method |
The authentication method. Valid options are "basic" and/or "cookie". If "basic" is set, the filter will authenticate the request using basic auth. If "cookie", the filter will authenticate the request using the cookie. If both "cookie" and "basic" are set, then the filter will first attempt to authenticate using the cookie, and, if that fails, it will attempt to authenticate using basic auth. If you use cookie based auth, and you want to send requests directly from the browser, then be sure to set your Plumber API to allow for cookies. See https://polished.tech/blog/polished-plumber for details. |
api_key |
Your polished API key |
a Plumber API filter function
This function is called by deploy_app()
to compress Shiny apps before
deploying them to Polished Hosting. You probably won't need to call this function
directly.
bundle_app(app_dir = ".")
bundle_app(app_dir = ".")
app_dir |
The path to the directory containing your Shiny app. Defaults to the working directory. |
the file path of the app bundle
## Not run: bundle_app( system.file("examples/polished_example_01", package = "polished") ) ## End(Not run)
## Not run: bundle_app( system.file("examples/polished_example_01", package = "polished") ) ## End(Not run)
This function specifies the default logos that are displayed in the "Admin Panel".
default_admin_ui_options()
default_admin_ui_options()
the default list of HTML for branding elements in the Admin Panel UI. The valid list element names are:
title
- Title/Logo element in top left corner of Admin Panel dashboard & browser tab title
sidebar_branding
- Branding (e.g. Logo) on left sidebar of Admin Panel dashboard
browser_tab_icon
- Icon to display in browser tab
Polished API - Delete an App
delete_app(app_uid = NULL, app_name = NULL, api_key = get_api_key())
delete_app(app_uid = NULL, app_name = NULL, api_key = get_api_key())
app_uid |
an optional app uid. One of either |
app_name |
an optional app name. One of either |
api_key |
your Polished API key. Set your polished api key using |
If both app_uid
and app_name
arguments are provided, then
the app_uid
will be used and the app_name
will be ignored.
an object of class polished_api_res
. When successful, the content
of the
polished_api_res
is list(message = "success")
. In the case of an error, the
content is list(error = "<error message>")
.
get_apps()
add_app()
update_app()
Polished API - Delete an App User
delete_app_user(app_uid, user_uid, api_key = get_api_key())
delete_app_user(app_uid, user_uid, api_key = get_api_key())
app_uid |
an app uid. |
user_uid |
a user uid. |
api_key |
your Polished API key. Set your polished api key using |
an object of class polished_api_res
. When successful, the content
of the
polished_api_res
is list(message = "success")
. In the case of an error, the
content is list(error = "<error message>")
.
get_apps()
add_app()
update_app_user()
Polished API - Delete a Role
delete_role(role_uid, api_key = get_api_key())
delete_role(role_uid, api_key = get_api_key())
role_uid |
the role uid of the role to be deleted. |
api_key |
your Polished API key. Set your polished api key using |
an object of class polished_api_res
. When successful, the content
of the
polished_api_res
is list(message = "success")
. In the case of an error, the
content is list(error = "<error message>")
.
Polished API - Delete a User
delete_user(user_uid, api_key = get_api_key())
delete_user(user_uid, api_key = get_api_key())
user_uid |
the uid of the user to be deleted. |
api_key |
your Polished API key. Set your polished api key using |
an object of class polished_api_res
. When successful, the content
of the
polished_api_res
is list(message = "success")
. In the case of an error, the
content is list(error = "<error message>")
.
get_users()
add_user()
update_user()
Polished API - Delete a User Role
delete_user_role(role_uid, user_uid, api_key = get_api_key())
delete_user_role(role_uid, user_uid, api_key = get_api_key())
role_uid |
the role uid of the role to be deleted. |
user_uid |
the user uid that the role should be removed from. |
api_key |
your Polished API key. Set your polished api key using |
an object of class polished_api_res
. When successful, the content
of the
polished_api_res
is list(message = "success")
. In the case of an error, the
content is list(error = "<error message>")
.
get_user_roles()
add_user_role()
Deploy a Shiny app to Polished Hosting
deploy_app( app_name, app_dir = ".", api_key = get_api_key(), launch_browser = TRUE, region = "us-east1", ram_gb = 2, r_ver = NULL, tlmgr = character(0), golem_package_name = NULL, cache = TRUE, gh_pat = NULL, max_sessions = Inf )
deploy_app( app_name, app_dir = ".", api_key = get_api_key(), launch_browser = TRUE, region = "us-east1", ram_gb = 2, r_ver = NULL, tlmgr = character(0), golem_package_name = NULL, cache = TRUE, gh_pat = NULL, max_sessions = Inf )
app_name |
Your Shiny app's name. |
app_dir |
The path to the directory containing your Shiny app. |
api_key |
Your |
launch_browser |
Boolean (default: |
region |
the region to deploy the app to on Google Cloud Platform. See
https://cloud.google.com/run/docs/locations for all available regions
on Google Cloud Platform. Currently, database connections are only supported for
|
ram_gb |
the amount of memory (in |
r_ver |
Character string of desired |
tlmgr |
a character vector of |
golem_package_name |
if your Shiny app was created as a package with the
|
cache |
Boolean (default: |
gh_pat |
optional GitHub PAT for installing packages from private GitHub repos. |
max_sessions |
the maximum number of concurrent sessions to run on a single app instance before
starting another instance. e.g. set to 5 to have a max of 5 user sessions per app instance.
The default is |
an object of class polished_api_res
.
## Not run: deploy_app( app_name = "polished_example_01", app_dir = system.file("examples/polished_example_01", package = "polished"), api_key = "<your polished.tech API key>" ) ## End(Not run)
## Not run: deploy_app( app_name = "polished_example_01", app_dir = system.file("examples/polished_example_01", package = "polished"), api_key = "<your polished.tech API key>" ) ## End(Not run)
input
This is a replica of shiny::textInput()
with the HTML input type
attribute set to "email"
rather than "text"
.
email_input( inputId, label = tagList(shiny::icon("envelope"), "Email"), value = "", width = NULL, placeholder = NULL )
email_input( inputId, label = tagList(shiny::icon("envelope"), "Email"), value = "", width = NULL, placeholder = NULL )
inputId |
The |
label |
Display label for the control, or |
value |
Initial value. |
width |
The width of the input, e.g. |
placeholder |
A character string giving the user a hint as to what can be entered into the control. Internet Explorer 8 and 9 do not support this option. |
the UI for the email input.
Under the hood, polished
uses Firebase JavaScript dependencies to handle
Social sign in & user authentication when sign_in_providers
besides "email"
are included in polished_config()
. This function loads the required Firebase JavaScript dependencies
in the the UI of your Shiny app.
firebase_dependencies(services = c("auth"), firebase_version = "7.15.5")
firebase_dependencies(services = c("auth"), firebase_version = "7.15.5")
services |
character vector of Firebase services to load into the UI. Valid strings are
|
firebase_version |
character string of the Firebase version. Defaults to |
the HTML <script>
tags for the Firebase JavaScript dependencies
firebase_dependencies()
firebase_dependencies()
Executes a few lines of JavaScript to initialize Firebase. This function should be
called in your Shiny UI immediately after firebase_dependencies
.
firebase_init(firebase_config)
firebase_init(firebase_config)
firebase_config |
named
|
a character string of JavaScript code to initialize Firebase
## Not run: my_config <- list( apiKey = "your Firebase API key", authDomain = "your Firebase auth domain", projectId = "your Firebase Project ID" ) firebase_init(my_config) ## End(Not run)
## Not run: my_config <- list( apiKey = "your Firebase API key", authDomain = "your Firebase auth domain", projectId = "your Firebase Project ID" ) firebase_init(my_config) ## End(Not run)
Polished API - Get App(s) User(s)
get_app_users( app_uid = NULL, user_uid = NULL, email = NULL, api_key = get_api_key() )
get_app_users( app_uid = NULL, user_uid = NULL, email = NULL, api_key = get_api_key() )
app_uid |
an optional app uid. |
user_uid |
an optional user uid. |
email |
an optional user email address. |
api_key |
your Polished API key. Set your polished api key using |
If app_uid
, user_uid
, & email
are all NULL
,
then all app users will be returned.
an object of class polished_api_res
. When successful, the content
of the object is a
tibble of app(s) with the following columns:
uid
app_uid
user_uid
is_admin
created_at
email
add_app_user()
update_app_user()
delete_app_user()
Polished API - Get App(s)
get_apps(app_uid = NULL, app_name = NULL, api_key = get_api_key())
get_apps(app_uid = NULL, app_name = NULL, api_key = get_api_key())
app_uid |
an optional app uid. |
app_name |
an optional app name. |
api_key |
your Polished API key. Set your polished api key using |
If both the app_uid
and app_name
are NULL
, then all the
apps in your account will be returned. If either app_uid
or app_name
are not
NULL
, then a single app will be returned (assuming the app exists). If both the
app_uid
and app_name
are provided, then the app_uid
will be used,
and the app_name
will be ignored. If the app does not exists, a zero row tibble
will be returned.
an object of class polished_api_res
. When successful, the content
of the object is a
tibble of app(s) with the following columns:
uid
app_name
app_url
created_at
modified_at
In the case of an error, the content is a list with 1 element named "error".
add_app()
update_app()
delete_app()
Polished API - Get Role(s)
get_roles(role_uid = NULL, api_key = get_api_key())
get_roles(role_uid = NULL, api_key = get_api_key())
role_uid |
an optional role uid. |
api_key |
your Polished API key. Set your polished api key using |
an object of class polished_api_res
. The content
of the object is a
tibble of user(s) with the following columns:
uid
role_name
created_at
Polished API - Get User Role(s)
get_user_roles(user_uid = NULL, role_uid = NULL, api_key = get_api_key())
get_user_roles(user_uid = NULL, role_uid = NULL, api_key = get_api_key())
user_uid |
an optional user uid. |
role_uid |
an optional role uid. |
api_key |
your Polished API key. Set your polished api key using |
an object of class polished_api_res
. The "content" of the object is a
tibble of users(s) with the following columns:
role_uid
role_name,
user_uid,
user_name,
created_at
add_user_role()
delete_user_role()
Polished API - Get User(s)
get_users( user_uid = NULL, email = NULL, include_two_fa = FALSE, api_key = get_api_key() )
get_users( user_uid = NULL, email = NULL, include_two_fa = FALSE, api_key = get_api_key() )
user_uid |
an optional user uid. |
email |
an optional user email. |
include_two_fa |
boolean, whether or not to include the 2FA information. |
api_key |
your Polished API key. Set your polished api key using |
If both the user_uid
and email
are NULL
, then all the
users in your account will be returned. If either user_uid
or email
are not
NULL
, then a single user will be returned (assuming the user exists). If both the
user_uid
and email
are provided, then the user_uid
will be used,
and the email
will be ignored. If the user does not exists, a zero row tibble
will be returned.
an object of class polished_api_res
. The content
of the object is a
tibble of users(s) with the following columns:
uid
email
email_verified
created_by
created_at
modified_by
modified_at
is_password_set
add_user()
update_user()
delete_user()
the UI passed a shiny app can be a function HTML. This function normalized the 2 different formats so that they both use the character
normalize_ui(ui, request_)
normalize_ui(ui, request_)
ui |
the Shiny ui |
request_ |
the request environment passed to the first argument of the UI function |
the Shiny UI
shiny::passwordInput
This modified version of Shiny's passwordInput()
does not actually send the password
to our Shiny server. It is just a regular password input that always keeps your
user's password on the client. The password is used to sign the user in and then
converted to a JWT by Firebase, all on the client, before it is sent to your Shiny
server.
password_input( input_id, label = htmltools::tagList(icon("unlock-alt"), "Password"), value = "", style = "", placeholder = NULL )
password_input( input_id, label = htmltools::tagList(icon("unlock-alt"), "Password"), value = "", style = "", placeholder = NULL )
input_id |
The |
label |
Display label for the control, or |
value |
Initial value. |
style |
Character string of in-line CSS to style the input. |
placeholder |
A character string giving the user a hint as to what can be entered into the control. Internet Explorer 8 and 9 do not support this option. |
the UI to create a password input.
Send GET Request to the Polished API
polished_api_res(resp)
polished_api_res(resp)
resp |
a Polished API response |
an S3 object of class "polished_api_res".
polished
authenticationglobal configuration for polished
authentication
polished_config( app_name, api_key = get_api_key(), firebase_config = NULL, is_invite_required = TRUE, sign_in_providers = "email", is_email_verification_required = TRUE, cookie_expires = 365L, is_auth_required = TRUE, is_two_fa_required = FALSE ) global_sessions_config(...)
polished_config( app_name, api_key = get_api_key(), firebase_config = NULL, is_invite_required = TRUE, sign_in_providers = "email", is_email_verification_required = TRUE, cookie_expires = 365L, is_auth_required = TRUE, is_two_fa_required = FALSE ) global_sessions_config(...)
app_name |
the name of the Shiny app. |
api_key |
the |
firebase_config |
if using Social Sign In (see https://polished.tech/docs/03-social-sign-in
for more documentation), a list containing your Firebase project configuration (Default:
|
is_invite_required |
|
sign_in_providers |
a character vector of sign in providers to enable. Valid values are |
is_email_verification_required |
|
cookie_expires |
the number of days before a user's cookie expires.
Set to |
is_auth_required |
|
is_two_fa_required |
boolean specifying whether or not 2 factor authentication is required. Defaults
to |
... |
arguments to pass to |
This is the primary function for configuring polished
. It configures your app's instance of
the Polished
class that manages polished
authentication. Call this function in
your global.R
file. See https://github.com/Tychobra/polished/blob/master/inst/examples/polished_example_01/global.R
for a complete example.
invisible(NULL)
## Not run: # global.R polished_config( app_name = "<your app name>", api_key = "<your API key>", firebase_config = list( apiKey = "<Firebase apiKey>", authDomain = "<Firebase authDomain", projectId = "<Firebase projectId>" ), sign_in_providers = c( "email", "google", "microsoft" ) ) ## End(Not run)
## Not run: # global.R polished_config( app_name = "<your app name>", api_key = "<your API key>", firebase_config = list( apiKey = "<Firebase apiKey>", authDomain = "<Firebase authDomain", projectId = "<Firebase projectId>" ), sign_in_providers = c( "email", "google", "microsoft" ) ) ## End(Not run)
Generic print function for polished_api_res
S3 class.
## S3 method for class 'polished_api_res' print(x, ...)
## S3 method for class 'polished_api_res' print(x, ...)
x |
an S3 object of class |
... |
additional arguments. |
invisible(NULL)
The server logic to accompany the profile_module_ui
.
profile_module(input, output, session)
profile_module(input, output, session)
input |
the Shiny server |
output |
the Shiny server |
session |
the Shiny server |
invisible(NULL)
Generates the UI for a user profile dropdown button to be used with the
shinydashboard
package.
profile_module_ui(id, other_lis = NULL)
profile_module_ui(id, other_lis = NULL)
id |
the Shiny module id. |
other_lis |
additional |
the UI to create the profile dropdown.
Creates the HTML UI of the "Sign in with *" buttons. These buttons are only
necessary if you enable Social Sign In via the sign_in_providers
argument
passed to polished_config
.
providers_ui( ns, sign_in_providers = c("google", "email"), title = "Sign In", fancy = TRUE )
providers_ui( ns, sign_in_providers = c("google", "email"), title = "Sign In", fancy = TRUE )
ns |
the Shiny namespace function created with |
sign_in_providers |
a character vector of sign in providers to enable. Valid values are |
title |
The title to be used above the provider buttons. Set to |
fancy |
Should the buttons be large and colorful? |
the HTML UI of the "Sign in with *" buttons.
Remove the entire query string from the URL. This function should only be called inside the server function of your Shiny app.
remove_query_string( session = shiny::getDefaultReactiveDomain(), mode = "replace" )
remove_query_string( session = shiny::getDefaultReactiveDomain(), mode = "replace" )
session |
the Shiny |
mode |
the mode to pass to |
invisible(NULL)
secure_rmd()
can be used to render (or run) and secure many
types of R Markdown documents. Rendering is handled either by rmarkdown::render
or, if using shiny
, a shiny
app is constructed, and the then
the output is secured with polished
authentication.
secure_rmd( rmd_file_path, polished_config_args = list(), sign_in_page_args = list(), sign_out_button = NULL )
secure_rmd( rmd_file_path, polished_config_args = list(), sign_in_page_args = list(), sign_out_button = NULL )
rmd_file_path |
the path the to .Rmd file. |
polished_config_args |
arguments to be passed to |
sign_in_page_args |
a named |
sign_out_button |
A |
a Shiny app object
## Not run: secure_rmd(system.file("examples/rmds/flexdashboard.Rmd", package = "polished")) secure_rmd( system.file("examples/rmds/flexdashboard.Rmd", package = "polished"), polished_config_args = list( # any values in this list will override values in YAML header app_name = "different_name" ), sign_in_page_args = list( color = "#FF5700" ) ) secure_rmd(system.file("examples/rmds/flexdashboard_shiny.Rmd", package = "polished")) secure_rmd(system.file("examples/rmds/html_document.Rmd", package = "polished")) secure_rmd(system.file("examples/rmds/pdf_document.Rmd", package = "polished")) io_file_path <- system.file( "examples/rmds/ioslides/ioslides_presentation.Rmd", package = "polished" ) secure_rmd(io_file_path) ## End(Not run)
## Not run: secure_rmd(system.file("examples/rmds/flexdashboard.Rmd", package = "polished")) secure_rmd( system.file("examples/rmds/flexdashboard.Rmd", package = "polished"), polished_config_args = list( # any values in this list will override values in YAML header app_name = "different_name" ), sign_in_page_args = list( color = "#FF5700" ) ) secure_rmd(system.file("examples/rmds/flexdashboard_shiny.Rmd", package = "polished")) secure_rmd(system.file("examples/rmds/html_document.Rmd", package = "polished")) secure_rmd(system.file("examples/rmds/pdf_document.Rmd", package = "polished")) io_file_path <- system.file( "examples/rmds/ioslides/ioslides_presentation.Rmd", package = "polished" ) secure_rmd(io_file_path) ## End(Not run)
This function is used to secure your Shiny app's server function. Make sure to pass
your Shiny app's server function as the first argument to secure_server()
at
the bottom of your Shiny app's server.R
file.
secure_server(server, custom_sign_in_server = NULL, custom_admin_server = NULL)
secure_server(server, custom_sign_in_server = NULL, custom_admin_server = NULL)
server |
A Shiny server function (e.g |
custom_sign_in_server |
Either |
custom_admin_server |
Either |
a Shiny server function.
This function is used to secure your Shiny app's UI. Make sure to pass
your Shiny app's UI as the first argument to secure_ui()
at
the bottom of your Shiny app's ui.R
file.
secure_ui( ui, sign_in_page_ui = NULL, custom_admin_ui = NULL, custom_admin_button_ui = admin_button_ui(), admin_ui_options = default_admin_ui_options() )
secure_ui( ui, sign_in_page_ui = NULL, custom_admin_ui = NULL, custom_admin_button_ui = admin_button_ui(), admin_ui_options = default_admin_ui_options() )
ui |
UI of the application. |
sign_in_page_ui |
Either |
custom_admin_ui |
Either |
custom_admin_button_ui |
Either |
admin_ui_options |
list of HTML elements to customize branding of the |
Secured Shiny app UI
This function sends a request to the https://polished.tech API to reset a user's password.
send_password_reset_email_module(input, output, session, email)
send_password_reset_email_module(input, output, session, email)
input |
the Shiny server |
output |
the Shiny server |
session |
the Shiny server |
email |
A reactive value returning the email address to send the password reset email to. |
invisible(NULL)
the UI for a Shiny module to send a password reset email
send_password_reset_email_module_ui(id, link_text = "Forgot your password?")
send_password_reset_email_module_ui(id, link_text = "Forgot your password?")
id |
the Shiny module |
link_text |
text to use for the password reset link. |
the UI to create a password reset link.
The API key can be set as an Environment Variable via
Sys.getenv("POLISHED_API_KEY")
.
set_api_key(api_key) get_api_key()
set_api_key(api_key) get_api_key()
api_key |
the Polished API key |
a list of the newly set polished
R options
set_api_key(api_key = "<my Polished API key>")
set_api_key(api_key = "<my Polished API key>")
Determines if the app is deployed to a server or running locally, and adjusts
the config environment to "production"
or "default"
, respectively. This function
is almost always called in the global.R
file of a Shiny app immediately before
the configuration in the config.yml
is read in.
set_config_env(override = NULL)
set_config_env(override = NULL)
override |
Set the environment to |
invisible(NULL)
This function retrieves the JWT created by the JavaScript from sign_in_js
and signs the user in as long as the token can be verified.
This function should be called in the server function of a shiny module. Make sure
to call sign_in_js
in the UI function of this module.
sign_in_check_jwt(jwt, session = shiny::getDefaultReactiveDomain())
sign_in_check_jwt(jwt, session = shiny::getDefaultReactiveDomain())
jwt |
a reactive returning a Firebase JSON web token for the signed in user. |
session |
the shiny session. |
invisible(NULL)
This function should be called at the bottom of your custom sign in and registration pages UI. It loads in all the JavaScript dependencies to handle polished sign in and registration. See the vignette for details.
sign_in_js(ns = function(x) x)
sign_in_js(ns = function(x) x)
ns |
the ns function from the Shiny module that this function is called within. |
the javascript to and other web dependencies to create the sign in functionality.
This server logic accompanies the sign_in_module_ui
.
sign_in_module(input, output, session)
sign_in_module(input, output, session)
input |
the Shiny |
output |
the Shiny |
session |
the Shiny |
invisible(NULL)
This server logic accompanies sign_in_module_2_ui
.
sign_in_module_2(input, output, session)
sign_in_module_2(input, output, session)
input |
the Shiny |
output |
the Shiny |
session |
the Shiny |
invisible(NULL)
Alternate sign in UI that works regardless of whether or not invites
are required. The UI displays email sign in inputs on the left, and social sign in options
on the right. sign_in_module_2
must be provided as the
argument custom_sign_in_server
in secure_server
for proper
functionality.
sign_in_module_2_ui(id)
sign_in_module_2_ui(id)
id |
the Shiny module |
the sign in module UI.
UI for the Sign In & Register pages when a user invite is required to Register & Sign In.
sign_in_module_ui( id, register_link = "First time user? Register here!", password_reset_link = "Forgot your password?" )
sign_in_module_ui( id, register_link = "First time user? Register here!", password_reset_link = "Forgot your password?" )
id |
the Shiny module |
register_link |
The text that will be displayed in the link to go to the
user registration page. The default is |
password_reset_link |
The text that will be displayed in the link to go to the
receive an email to reset your password. The default is |
the sign in module UI.
verify the users Firebase JWT and store the session
sign_in_social(firebase_token, hashed_cookie)
sign_in_social(firebase_token, hashed_cookie)
firebase_token |
the Firebase JWT. This JWT is created client side
(in JavaScript) via |
hashed_cookie |
the hashed |
NULL if sign in fails. If sign in is successful, a list containing the following:
email_verified
is_admin
user_uid
hashed_cookie
session_uid
Default styling for the sign in & registration pages. Update the sign_in_ui_default()
arguments with your brand and colors to quickly style the sign in & registration
pages to match your brand.
sign_in_ui_default( sign_in_module = sign_in_module_ui("sign_in"), color = "#5ec7dd", company_name = "Your Brand Here", logo_top = tags$div(style = "width: 300px; max-width: 100%; color: #FFF;", class = "text-center", h1("Your", style = "margin-bottom: 0; margin-top: 30px;"), h1("Brand", style = "margin-bottom: 0; margin-top: 10px;"), h1("Here", style = "margin-bottom: 15px; margin-top: 10px;")), logo_bottom = NULL, icon_href = "polish/images/polished_icon.png", background_image = NULL, terms_and_privacy_footer = NULL, align = "center", button_color = NULL, footer_color = "#FFF" )
sign_in_ui_default( sign_in_module = sign_in_module_ui("sign_in"), color = "#5ec7dd", company_name = "Your Brand Here", logo_top = tags$div(style = "width: 300px; max-width: 100%; color: #FFF;", class = "text-center", h1("Your", style = "margin-bottom: 0; margin-top: 30px;"), h1("Brand", style = "margin-bottom: 0; margin-top: 10px;"), h1("Here", style = "margin-bottom: 15px; margin-top: 10px;")), logo_bottom = NULL, icon_href = "polish/images/polished_icon.png", background_image = NULL, terms_and_privacy_footer = NULL, align = "center", button_color = NULL, footer_color = "#FFF" )
sign_in_module |
UI module for the Sign In & Registration pages. |
color |
hex color for the background and button. |
company_name |
your company name. |
logo_top |
HTML for logo to go above the sign in panel. |
logo_bottom |
HTML for the logo below the sign in panel. |
icon_href |
the URL/path to the browser tab icon. |
background_image |
the URL/path to a full width background image. If set to |
terms_and_privacy_footer |
links to place in the footer, directly above the copyright notice. |
align |
The horizontal alignment of the Sign In box. Defaults to |
button_color |
the color of the "Continue", "Sign In", and "Register" buttons. If kept
as |
footer_color |
the text color for the copyright text in the footer. |
the html and css to create the default sign in UI.
the UI for the Sign In & Registration pages
Call this function to sign a user out of your Shiny app. This function should be called inside the server function of your Shiny app. See https://github.com/Tychobra/polished/blob/master/inst/examples/polished_example_01/server.R For an example of this function being called after the user clicks a "Sign Out" button.
sign_out_from_shiny( session = shiny::getDefaultReactiveDomain(), redirect_page = "?page=sign_in" )
sign_out_from_shiny( session = shiny::getDefaultReactiveDomain(), redirect_page = "?page=sign_in" )
session |
the Shiny |
redirect_page |
the query string for the page that the user should be redirected to after signing out. |
invisible(NULL)
Polished API - Update an App
update_app(app_uid, app_name = NULL, app_url = NULL, api_key = get_api_key())
update_app(app_uid, app_name = NULL, app_url = NULL, api_key = get_api_key())
app_uid |
the app uid of the app to update. |
app_name |
an optional app name to replace the existing app name. |
app_url |
an optional app url to replace the existing app url. |
api_key |
your Polished API key. Set your polished api key using |
an object of class polished_api_res
. When successful, the content
of the
polished_api_res
is list(message = "success")
. In the case of an error, the
content is list(error = "<error message>")
.
get_apps()
add_app()
delete_app()
Polished API - Update an App User
update_app_user(app_uid, user_uid, is_admin = FALSE, api_key = get_api_key())
update_app_user(app_uid, user_uid, is_admin = FALSE, api_key = get_api_key())
app_uid |
the app uid to update. |
user_uid |
the user uid to update. |
is_admin |
boolean (default: |
api_key |
your Polished API key. Set your polished api key using |
an object of class polished_api_res
. When successful, the content
of the
polished_api_res
is list(message = "success")
. In the case of an error, the
content is list(error = "<error message>")
.
get_app_users()
add_app_user()
delete_app_user()
Polished API - Update a user
update_user(user_uid, user_data, api_key = get_api_key())
update_user(user_uid, user_data, api_key = get_api_key())
user_uid |
the uid of the user to be updated. |
user_data |
list of data to update. |
api_key |
your Polished API key. Set your polished api key using |
an object of class polished_api_res
. When successful, the content
of the
polished_api_res
is list(message = "success")
. In the case of an error, the
content is list(error = "<error message>")
.
get_users()
add_user()
delete_user()
Server function for the default Shiny module to control user access in the polished
Admin Panel.
user_access_module(input, output, session)
user_access_module(input, output, session)
input |
the Shiny server input |
output |
the Shiny server output |
session |
the Shiny server session |
invisible(NULL)
Shiny module UI for the default user access tab in the polished
Admin Panel.
user_access_module_ui(id)
user_access_module_ui(id)
id |
the module id |
the UI to create the user access module.
Set the region
argument of deploy_app()
to one of these regions.
valid_gcp_regions
valid_gcp_regions
An object of class character
of length 35.