Movatterモバイル変換


[0]ホーム

URL:


Type:Package
Title:Authentication and Hosting for 'shiny' Apps
Version:0.8.1
Maintainer:Andy Merlino <andy.merlino@tychobra.com>
Description:Authentication, user administration, hosting, and additional infrastructure for 'shiny' apps. Seehttps://polished.tech for additional documentation and examples.
License:MIT + file LICENSE
URL:https://github.com/tychobra/polished,https://polished.tech
BugReports:https://github.com/tychobra/polished/issues
Encoding:UTF-8
Imports:automagic, digest, dplyr, desc, DT, htmltools, httr, jose,jsonlite, lubridate, otp, purrr, rlang, rmarkdown, shiny,shinycssloaders, shinydashboard, shinyFeedback, shinyjs,shinyWidgets, stats, stringr, tibble, tidyr, utils, uuid, yaml
Suggests:base64enc, config, knitr, plumber, testthat (≥ 3.0.0), xfun
VignetteBuilder:knitr
RoxygenNote:7.2.3
Config/testthat/edition:3
NeedsCompilation:no
Packaged:2023-02-11 15:11:50 UTC; andy
Author:Andy Merlino [aut, cre], Patrick Howard [aut], Tychobra LLC [cph, fnd]
Repository:CRAN
Date/Publication:2023-02-11 15:30:02 UTC

Polished API - Add an App

Description

Polished API - Add an App

Usage

add_app(app_name, app_url = NULL, api_key = get_api_key())

Arguments

app_name

the app name.

app_url

an optional app url. This url will be included in links sent out in inviteand email verification emails to redirect your users to your app.

api_key

your Polished API key. Set your polished api key usingset_api_key()so that you do not need to supply this argument with each function call.

Value

an object of classpolished_api_res. When successful, thecontent of thepolished_api_res islist(message = "success"). In the case of an error, thecontent islist(error = "<error message>").

See Also

get_apps()update_app()delete_app()


Polished API - Add a User to an App

Description

Polished API - Add a User to an App

Usage

add_app_user(  app_uid,  user_uid = NULL,  email = NULL,  is_admin = FALSE,  send_invite_email = FALSE,  api_key = get_api_key())

Arguments

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:FALSE) - whether or not the user is a Polished admin.

send_invite_email

boolean - whether or not to send the user an invite emailnotifying them they have been invited to access the app.

api_key

your Polished API key. Set your polished api key usingset_api_key()so that you do not need to supply this argument with each function call.

Details

supply either theuser_uid oremail. If both are provided, thentheuser_uid will be used, and theemail will be ignored.

Value

an object of classpolished_api_res. When successful, thecontent of thepolished_api_res islist(message = "success"). In the case of an error, thecontent islist(error = "<error message>").

See Also

get_app_users()update_app_user()delete_app_user()


add_auth_to_spec

Description

Add authentication to the openapi plumber spec so that you can use the swaggerdocumentation with theauth_filter().

Usage

add_auth_to_spec(method = c("basic", "cookie"))

Arguments

method

the authentication method(s)

Details

This minimal API examplehttps://github.com/Tychobra/polished_example_apps/blob/master/11_plumber/api/00_start.Rshows how you can add this function to your API.

Value

a function to update the openapi spec.


Polished API - Add a Role

Description

Polished API - Add a Role

Usage

add_role(role_name, api_key = get_api_key())

Arguments

role_name

a role name.

api_key

your Polished API key. Set your polished api key usingset_api_key()so that you do not need to supply this argument with each function call.

Value

an object of classpolished_api_res. When successful, thecontent of thepolished_api_res islist(message = "success"). In the case of an error, thecontent islist(error = "<error message>").

See Also

get_roles()delete_role()


Polished API - Add a User

Description

Polished API - Add a User

Usage

add_user(email, api_key = get_api_key())

Arguments

email

the new user's email address.

api_key

your Polished API key. Set your polished api key usingset_api_key()so that you do not need to supply this argument with each function call.

Value

an object of classpolished_api_res. When successful, thecontent of thepolished_api_res islist(message = "success"). In the case of an error, thecontent islist(error = "<error message>").

See Also

get_users()update_user()delete_user()


Polished API - Add a User Role

Description

Polished API - Add a User Role

Usage

add_user_role(  user_uid,  role_uid = NULL,  role_name = NULL,  api_key = get_api_key())

Arguments

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 usingset_api_key()so that you do not need to supply this argument with each function call.

Details

one of eitherrole_uid orrole_name must be provided. Ifboth are provided, only therole_uid will be used.

Value

an object of classpolished_api_res. When successful, thecontent of thepolished_api_res islist(message = "success"). In the case of an error, thecontent islist(error = "<error message>").

See Also

get_user_roles()delete_user_role()


An html button to navigate the the "Admin Panel"

Description

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 appearsin the bottom right of your 'shiny' app.

Usage

admin_button_ui(align = "right", vertical_align = "bottom")

Arguments

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"

Value

admin button UI


The server logic for the default Admin Panel dashboard

Description

The Shiny module server logic for thepolished Admin Panel, accessible to Admin users.

Usage

admin_server(input, output, session)

Arguments

input

the Shiny server input

output

the Shiny server output

session

the Shiny server session

Value

invisible(NULL)


The UI for the "Admin Panel" dashboard

Description

Theshiny module UI for thepolished Admin Panel, accessible to Admin users.

Usage

admin_ui(options = default_admin_ui_options())

Arguments

options

list of HTML elements to customize branding of "Admin Panel". Validlist element names aretitle,sidebar_branding, andbrowser_tab_icon. Seedefault_admin_ui_options for an example.

Value

the UI for the "Admin Panel"


Convert a list returned from the Polished API into a data frame

Description

In order to avoid issues with converting R data frames into JSON objects and backto R data frames, we instead convert R data frames to R lists before convertingthem to JSON to be sent via the Polished API. This function then converts thoselists back into R data frames (or more precisely tibbles).

Usage

api_list_to_df(api_list)

Arguments

api_list

a list. All elements in the list are vectors of the same length.

Value

a tibble


Auth filter for a Plumber API

Description

Auth filter for a Plumber API

Usage

auth_filter(method = c("basic", "cookie"), api_key = get_api_key())

Arguments

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 authenticateusing the cookie, and, if that fails, it will attempt to authenticate using basicauth. 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. Seehttps://polished.tech/blog/polished-plumber for details.

api_key

Your polished API key

Value

a Plumber API filter function


Create a tar archive

Description

This function is called bydeploy_app() to compress Shiny apps beforedeploying them to Polished Hosting. You probably won't need to call this functiondirectly.

Usage

bundle_app(app_dir = ".")

Arguments

app_dir

The path to the directory containing your Shiny app. Defaults to theworking directory.

Value

the file path of the app bundle

Examples

## Not run: bundle_app(  system.file("examples/polished_example_01", package = "polished"))## End(Not run)

Default Options for the Admin UI

Description

This function specifies the default logos that are displayed in the "Admin Panel".

Usage

default_admin_ui_options()

Value

the default list of HTML for branding elements in the Admin Panel UI. The valid list element names are:


Polished API - Delete an App

Description

Polished API - Delete an App

Usage

delete_app(app_uid = NULL, app_name = NULL, api_key = get_api_key())

Arguments

app_uid

an optional app uid. One of eitherapp_uid orapp_name must be provided.

app_name

an optional app name. One of eitherapp_uid orapp_name must be provided.

api_key

your Polished API key. Set your polished api key usingset_api_key()so that you do not need to supply this argument with each function call.

Details

If bothapp_uid andapp_name arguments are provided, thentheapp_uid will be used and theapp_name will be ignored.

Value

an object of classpolished_api_res. When successful, thecontent of thepolished_api_res islist(message = "success"). In the case of an error, thecontent islist(error = "<error message>").

See Also

get_apps()add_app()update_app()


Polished API - Delete an App User

Description

Polished API - Delete an App User

Usage

delete_app_user(app_uid, user_uid, api_key = get_api_key())

Arguments

app_uid

an app uid.

user_uid

a user uid.

api_key

your Polished API key. Set your polished api key usingset_api_key()so that you do not need to supply this argument with each function call.

Value

an object of classpolished_api_res. When successful, thecontent of thepolished_api_res islist(message = "success"). In the case of an error, thecontent islist(error = "<error message>").

See Also

get_apps()add_app()update_app_user()


Polished API - Delete a Role

Description

Polished API - Delete a Role

Usage

delete_role(role_uid, api_key = get_api_key())

Arguments

role_uid

the role uid of the role to be deleted.

api_key

your Polished API key. Set your polished api key usingset_api_key()so that you do not need to supply this argument with each function call.

Value

an object of classpolished_api_res. When successful, thecontent of thepolished_api_res islist(message = "success"). In the case of an error, thecontent islist(error = "<error message>").

See Also

get_roles()add_role()


Polished API - Delete a User

Description

Polished API - Delete a User

Usage

delete_user(user_uid, api_key = get_api_key())

Arguments

user_uid

the uid of the user to be deleted.

api_key

your Polished API key. Set your polished api key usingset_api_key()so that you do not need to supply this argument with each function call.

Value

an object of classpolished_api_res. When successful, thecontent of thepolished_api_res islist(message = "success"). In the case of an error, thecontent islist(error = "<error message>").

See Also

get_users()add_user()update_user()


Polished API - Delete a User Role

Description

Polished API - Delete a User Role

Usage

delete_user_role(role_uid, user_uid, api_key = get_api_key())

Arguments

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 usingset_api_key()so that you do not need to supply this argument with each function call.

Value

an object of classpolished_api_res. When successful, thecontent of thepolished_api_res islist(message = "success"). In the case of an error, thecontent islist(error = "<error message>").

See Also

get_user_roles()add_user_role()


Deploy a Shiny app to Polished Hosting

Description

Deploy a Shiny app to Polished Hosting

Usage

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)

Arguments

app_name

Your Shiny app's name.

app_dir

The path to the directory containing your Shiny app.

api_key

Yourpolished API key. Defaults toSys.getenv("POLISHED_API_KEY") if set.

launch_browser

Boolean (default:TRUE) - Whether or not to openyour newly deployed app in your default web browser after successful deployment.

region

the region to deploy the app to on Google Cloud Platform. Seehttps://cloud.google.com/run/docs/locations for all available regionson Google Cloud Platform. Currently, database connections are only supported forus-east1. Seehttps://polished.tech/docs/06-database-connections for details.

ram_gb

the amount of memory (inGiB) to allocate to your Shiny app's server.Valid values are2,4,8,16, or32.

r_ver

Character string of desiredR version. If kept asNULL (the default),deploy_app() will detect the R version you are currently running. The R version must be a versionsupported by anr-ver Docker image. You can see all ther-ver Docker image versionsof R herehttps://github.com/rocker-org/rocker-versioned2/tree/master/dockerfiles and herehttps://github.com/rocker-org/rocker-versioned/tree/master/r-ver.

tlmgr

a character vector of⁠TeX Live⁠ packages to install. This is only used if your Shinyapp generatesPDF documents. Defaults tocharacter(0) for no⁠TeX Live⁠ installation. Provide acharacter vector of your TeX Live package dependencies to have all your TeX Live packages installed at build time.

golem_package_name

if your Shiny app was created as a package with thegolem package, provide the name of the Shiny app package as a character string.Defaults toNULL. Keep asNULL for nongolem Shiny apps.

cache

Boolean (default:TRUE) - whether or not to cache the Docker image.

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 beforestarting another instance. e.g. set to 5 to have a max of 5 user sessions per app instance.The default isInf which will run all concurrent sessions on only 1 app instance.

Value

an object of classpolished_api_res.

Examples

## 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)

A Shiny emailinput

Description

This is a replica ofshiny::textInput() with the HTML inputtypeattribute set to"email" rather than"text".

Usage

email_input(  inputId,  label = tagList(shiny::icon("envelope"), "Email"),  value = "",  width = NULL,  placeholder = NULL)

Arguments

inputId

Theinput slot that will be used to access the value.

label

Display label for the control, orNULL for no label.

value

Initial value.

width

The width of the input, e.g.'400px'.

placeholder

A character string giving the user a hint as to what can be enteredinto the control. Internet Explorer 8 and 9 do not support this option.

Value

the UI for the email input.


Load the Firebase JavaScript dependencies into the UI

Description

Under the hood,polished uses Firebase JavaScript dependencies to handleSocial sign in & user authentication whensign_in_providers besides"email"are included inpolished_config(). This function loads the required Firebase JavaScript dependenciesin the the UI of your Shiny app.

Usage

firebase_dependencies(services = c("auth"), firebase_version = "7.15.5")

Arguments

services

character vector of Firebase services to load into the UI. Valid strings are"auth" (default),"firestore","functions","messaging", and"storage"

firebase_version

character string of the Firebase version. Defaults to"7.15.5".

Value

the HTML<script> tags for the Firebase JavaScript dependencies

Examples

firebase_dependencies()

Initialize Firebase

Description

Executes a few lines of JavaScript to initialize Firebase. This function should becalled in your Shiny UI immediately afterfirebase_dependencies.

Usage

firebase_init(firebase_config)

Arguments

firebase_config

namedlist of firebase configuration values.Required values are:

  • apiKey

  • authDomain

  • projectId

Value

a character string of JavaScript code to initialize Firebase

Examples

## 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)

Description

Polished API - Get App(s) User(s)

Usage

get_app_users(  app_uid = NULL,  user_uid = NULL,  email = NULL,  api_key = get_api_key())

Arguments

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 usingset_api_key()so that you do not need to supply this argument with each function call.

Details

Ifapp_uid,user_uid, &email are allNULL,then all app users will be returned.

Value

an object of classpolished_api_res. When successful, thecontent of the object is atibble of app(s) with the following columns:

See Also

add_app_user()update_app_user()delete_app_user()


Polished API - Get App(s)

Description

Polished API - Get App(s)

Usage

get_apps(app_uid = NULL, app_name = NULL, api_key = get_api_key())

Arguments

app_uid

an optional app uid.

app_name

an optional app name.

api_key

your Polished API key. Set your polished api key usingset_api_key()so that you do not need to supply this argument with each function call.

Details

If both theapp_uid andapp_name areNULL, then all theapps in your account will be returned. If eitherapp_uid orapp_name are notNULL, then a single app will be returned (assuming the app exists). If both theapp_uid andapp_name are provided, then theapp_uid will be used,and theapp_name will be ignored. If the app does not exists, a zero row tibblewill be returned.

Value

an object of classpolished_api_res. When successful, thecontent of the object is atibble of app(s) with the following columns:

See Also

add_app()update_app()delete_app()


Create a list of R Package Dependencies

Description

Given apath to a directory this function will scan all.R and.Rmd files for any used R Packages along with their CRAN versions or GitHub references.

Usage

get_package_deps(app_dir = ".", all_deps = FALSE)

Arguments

app_dir

path to a directory containing R scripts or R Markdown files. Defaultsto current working directory.

all_deps

boolean - whether or not to explicitly identify all "Imports" package dependenciesof the packages used by your app.

Details

Currently, packages are detected viaautomagic::parse_packages() which supportsthe following calls within the code:library(),require(), andprefixed:: calls to functions.

Once an initial vector of package is created, each package is a checked that it canbe downloaded and installed fromCRAN orGitHub.

Value

a list of package dependencies with installation details

See Also

automagic::parse_packages()


Polished API - Get Role(s)

Description

Polished API - Get Role(s)

Usage

get_roles(role_uid = NULL, api_key = get_api_key())

Arguments

role_uid

an optional role uid.

api_key

your Polished API key. Set your polished api key usingset_api_key()so that you do not need to supply this argument with each function call.

Value

an object of classpolished_api_res. Thecontent of the object is atibble of user(s) with the following columns:

See Also

add_role()delete_role()


Polished API - Get User Role(s)

Description

Polished API - Get User Role(s)

Usage

get_user_roles(user_uid = NULL, role_uid = NULL, api_key = get_api_key())

Arguments

user_uid

an optional user uid.

role_uid

an optional role uid.

api_key

your Polished API key. Set your polished api key usingset_api_key()so that you do not need to supply this argument with each function call.

Value

an object of classpolished_api_res. The "content" of the object is atibble of users(s) with the following columns:

See Also

add_user_role()delete_user_role()


Polished API - Get User(s)

Description

Polished API - Get User(s)

Usage

get_users(  user_uid = NULL,  email = NULL,  include_two_fa = FALSE,  api_key = get_api_key())

Arguments

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 usingset_api_key()so that you do not need to supply this argument with each function call.

Details

If both theuser_uid andemail areNULL, then all theusers in your account will be returned. If eitheruser_uid oremail are notNULL, then a single user will be returned (assuming the user exists). If both theuser_uid andemail are provided, then theuser_uid will be used,and theemail will be ignored. If the user does not exists, a zero row tibblewill be returned.

Value

an object of classpolished_api_res. Thecontent of the object is atibble of users(s) with the following columns:

See Also

add_user()update_user()delete_user()


normalize UI

Description

the UI passed a shiny app can be a function HTML. This function normalized the 2 differentformats so that they both use the character

Usage

normalize_ui(ui, request_)

Arguments

ui

the Shiny ui

request_

the request environment passed to the first argument of the UIfunction

Value

the Shiny UI


A modification ofshiny::passwordInput

Description

This modified version of Shiny'spasswordInput() does not actually send the passwordto our Shiny server. It is just a regular password input that always keeps youruser's password on the client. The password is used to sign the user in and thenconverted to a JWT by Firebase, all on the client, before it is sent to your Shinyserver.

Usage

password_input(  input_id,  label = htmltools::tagList(icon("unlock-alt"), "Password"),  value = "",  style = "",  placeholder = NULL)

Arguments

input_id

Theinput slot that will be used to access the value.

label

Display label for the control, orNULL for no label.

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 canbe entered into the control. Internet Explorer 8 and 9 do not support this option.

Value

the UI to create a password input.


Send GET Request to the Polished API

Description

Send GET Request to the Polished API

Usage

polished_api_res(resp)

Arguments

resp

a Polished API response

Value

an S3 object of class "polished_api_res".


global configuration forpolished authentication

Description

global configuration forpolished authentication

Usage

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(...)

Arguments

app_name

the name of the Shiny app.

api_key

thepolished API key, available athttps://dashboard.polished.tech.

firebase_config

if using Social Sign In (seehttps://polished.tech/docs/03-social-sign-infor more documentation), a list containing your Firebase project configuration (Default:NULL).This list should have the following named elements:

  • apiKey

  • authDomain

  • projectId

is_invite_required

TRUE by default. Whether or not to require the user to have aninvite before registering/signing in

sign_in_providers

a character vector of sign in providers to enable. Valid values are"google""email","microsoft", and/or"facebook". Defaults to"email".

is_email_verification_required

TRUE by default. Whether or not to require the user toverify their email before accessing your Shiny app.

cookie_expires

the number of days before a user's cookie expires.Set toNULL to force Sign Out at session end. This argument is passed totheexpires option in js-cookie:https://github.com/js-cookie/js-cookie#expires.Default value is365L (i.e. 1 year)

is_auth_required

TRUE by default. Whether or not to require users to be signedin to access the app. It can be useful to set this argument toFALSE if you want toallow users to do certain actions (such as viewing charts and tables) without signing in,and only require users to sign in if they want to save data to your database.

is_two_fa_required

boolean specifying whether or not 2 factor authentication is required. DefaultstoFALSE.

...

arguments to pass topolished_config

Details

This is the primary function for configuringpolished. It configures your app's instance ofthePolished class that managespolished authentication. Call this function inyourglobal.R file. Seehttps://github.com/Tychobra/polished/blob/master/inst/examples/polished_example_01/global.Rfor a complete example.

Value

invisible(NULL)

Examples

## Not run: # global.Rpolished_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)

print polished_api_res

Description

Generic print function forpolished_api_res S3 class.

Usage

## S3 method for class 'polished_api_res'print(x, ...)

Arguments

x

an S3 object of classpolished_api_res.

...

additional arguments.

Value

invisible(NULL)


Profile Module Server

Description

The server logic to accompany theprofile_module_ui.

Usage

profile_module(input, output, session)

Arguments

input

the Shiny serverinput

output

the Shiny serveroutput

session

the Shiny serversession

Value

invisible(NULL)


Profile Module UI

Description

Generates the UI for a user profile dropdown button to be used with theshinydashboard package.

Usage

profile_module_ui(id, other_lis = NULL)

Arguments

id

the Shiny module id.

other_lis

additional<li> HTML tags to place between the email addressand the Sign out button in the user profile dropdown. This is often used toadd a user "My Account" page/app where the user can set their account settings.

Value

the UI to create the profile dropdown.


UI for the Social Sign In authentication providers' buttons

Description

Creates the HTML UI of the "Sign in with *" buttons. These buttons are onlynecessary if you enable Social Sign In via thesign_in_providers argumentpassed topolished_config.

Usage

providers_ui(  ns,  sign_in_providers = c("google", "email"),  title = "Sign In",  fancy = TRUE)

Arguments

ns

the Shiny namespace function created withshiny::NS().

sign_in_providers

a character vector of sign in providers to enable. Valid values are"google""email","microsoft", and/or"facebook". Defaults to"email".

title

The title to be used above the provider buttons. Set toNULL to not include

fancy

Should the buttons be large and colorful?

Value

the HTML UI of the "Sign in with *" buttons.


Remove the URL query

Description

Remove the entire query string from the URL. This function should only be calledinside the server function of your Shiny app.

Usage

remove_query_string(  session = shiny::getDefaultReactiveDomain(),  mode = "replace")

Arguments

session

the Shinysession

mode

the mode to pass toshiny::updateQueryString(). Valid values are"replace" or"push".

Value

invisible(NULL)


Render and secure R Markdown document

Description

secure_rmd() can be used to render (or run) and secure manytypes of R Markdown documents. Rendering is handled either byrmarkdown::renderor, if usingshiny, ashiny app is constructed, and the thenthe output is secured withpolished authentication.

Usage

secure_rmd(  rmd_file_path,  polished_config_args = list(),  sign_in_page_args = list(),  sign_out_button = NULL)

Arguments

rmd_file_path

the path the to .Rmd file.

polished_config_args

arguments to be passed topolished_config.(NOTE: Values passed in this list will override YAML header values if both provided).

sign_in_page_args

a namedlist() to customize the Sign In pageUI. Valid names arecolor,company_name,logo, &background_image.(NOTE: Values passed in this list will override YAML header values if both provided).

sign_out_button

Ashiny::actionButton orshiny::actionLink withinputId = "sign_out".If this argument is left asNULL,secure_rmd will attempt to add in an appropriate signout button/link depending on the output format of your .Rmd document. Set this argument tolist()to not include a sign out button.

Value

a Shiny app object

Examples

## 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)

Secure your Shiny app's server

Description

This function is used to secure your Shiny app's server function. Make sure to passyour Shiny app's server function as the first argument tosecure_server() atthe bottom of your Shiny app'sserver.R file.

Usage

secure_server(server, custom_sign_in_server = NULL, custom_admin_server = NULL)

Arguments

server

A Shiny server function (e.gfunction(input, output, session) {})

custom_sign_in_server

EitherNULL, the default, or a Shiny server containing your customsign in server logic.

custom_admin_server

EitherNULL, the default, or a Shiny server function containing your custom adminserver functionality.

Value

a Shiny server function.


Secure your Shiny UI

Description

This function is used to secure your Shiny app's UI. Make sure to passyour Shiny app's UI as the first argument tosecure_ui() atthe bottom of your Shiny app'sui.R file.

Usage

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())

Arguments

ui

UI of the application.

sign_in_page_ui

EitherNULL, the default (Seesign_in_ui_default), or the ShinyUI for a custom Sign In page.

custom_admin_ui

EitherNULL, the default, or the Shiny UI for a customAdmin Panel.

custom_admin_button_ui

Eitheradmin_button_ui(), the default, or your customUI to take Admins from the custom Shiny app to thepolished Admin Panel. Set toNULL to exclude the button.

admin_ui_options

list of HTML elements to customize branding of thepolished Admin Panel. Thisargument is only applicable if thecustom_admin_ui is set toNULL. If acustom_admin_uiis provided, then these options will be ignored. Validlist element names aretitle,sidebar_branding, andbrowser_tab_icon. Seedefault_admin_ui_options, the default.

Value

Secured Shiny app UI


the server logic for a Shiny module to send a password reset email

Description

This function sends a request to thehttps://polished.tech API to reset a user'spassword.

Usage

send_password_reset_email_module(input, output, session, email)

Arguments

input

the Shiny serverinput

output

the Shiny serveroutput

session

the Shiny serversession

email

A reactive value returning the email address to send the passwordreset email to.

Value

invisible(NULL)


the UI for a Shiny module to send a password reset email

Description

the UI for a Shiny module to send a password reset email

Usage

send_password_reset_email_module_ui(id, link_text = "Forgot your password?")

Arguments

id

the Shiny moduleid

link_text

text to use for the password reset link.

Value

the UI to create a password reset link.


set Polished API key

Description

The API key can be set as an Environment Variable viaSys.getenv("POLISHED_API_KEY").

Usage

set_api_key(api_key)get_api_key()

Arguments

api_key

the Polished API key

Value

a list of the newly setpolished R options

Examples

set_api_key(api_key = "<my Polished API key>")

Automatically set the config environment

Description

Determines if the app is deployed to a server or running locally, and adjuststhe config environment to"production" or"default", respectively. This functionis almost always called in theglobal.R file of a Shiny app immediately beforethe configuration in theconfig.yml is read in.

Usage

set_config_env(override = NULL)

Arguments

override

Set the environment to"default" or"production" manually.CAUTION:Be sure you know the difference between"default" &"production" configuration environments.Using the"production" environment will affect the database of the deployed application.

Value

invisible(NULL)


Check the JWT from the user sign in

Description

This function retrieves the JWT created by the JavaScript fromsign_in_jsand 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 sureto callsign_in_js in the UI function of this module.

Usage

sign_in_check_jwt(jwt, session = shiny::getDefaultReactiveDomain())

Arguments

jwt

a reactive returning a Firebase JSON web token for the signed in user.

session

the shiny session.

Value

invisible(NULL)


Sign in and register pages JavaScript dependencies

Description

This function should be called at the bottom of your custom sign in and registrationpages UI. It loads in all the JavaScript dependencies to handle polished signin and registration. See the vignette for details.

Usage

sign_in_js(ns = function(x) x)

Arguments

ns

the ns function from the Shiny module that this function is calledwithin.

Value

the javascript to and other web dependencies to create the sign in functionality.


Server logic for the Sign In & Register pages

Description

This server logic accompanies thesign_in_module_ui.

Usage

sign_in_module(input, output, session)

Arguments

input

the Shinyinput

output

the Shinyoutput

session

the Shinysession

Value

invisible(NULL)


Server logic for the Sign In & Register pages

Description

This server logic accompaniessign_in_module_2_ui.

Usage

sign_in_module_2(input, output, session)

Arguments

input

the Shinyinput

output

the Shinyoutput

session

the Shinysession

Value

invisible(NULL)


UI for the Sign In & Register pages

Description

Alternate sign in UI that works regardless of whether or not invitesare required. The UI displays email sign in inputs on the left, and social sign in optionson the right.sign_in_module_2 must be provided as theargumentcustom_sign_in_server insecure_server for properfunctionality.

Usage

sign_in_module_2_ui(id)

Arguments

id

the Shiny moduleid

Value

the sign in module UI.


UI for the Sign In & Register pages

Description

UI for the Sign In & Register pages when a user invite is required to Register & Sign In.

Usage

sign_in_module_ui(  id,  register_link = "First time user? Register here!",  password_reset_link = "Forgot your password?")

Arguments

id

the Shiny moduleid

register_link

The text that will be displayed in the link to go to theuser registration page. The default is"First time user? Register here!".Set toNULL if you don't want to use the registration page.

password_reset_link

The text that will be displayed in the link to go to thereceive an email to reset your password. The default is"Forgot your password?".Set toNULL if you don't want to use the registration page.

Value

the sign in module UI.


verify the users Firebase JWT and store the session

Description

verify the users Firebase JWT and store the session

Usage

sign_in_social(firebase_token, hashed_cookie)

Arguments

firebase_token

the Firebase JWT. This JWT is created client side(in JavaScript) viafirebase.auth().

hashed_cookie

the hashedpolished cookie. Used for tracking the usersession. This cookie is inserted into the "polished.sessions" table if theJWT is valid.

Value

NULL if sign in fails. If sign in is successful, a list containing the following:


Default UI styles for the Sign In & Registration pages

Description

Default styling for the sign in & registration pages. Update thesign_in_ui_default()arguments with your brand and colors to quickly style the sign in & registrationpages to match your brand.

Usage

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")

Arguments

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 toNULL,the default, thecolor argument will be used for the background instead of thisimage.

terms_and_privacy_footer

links to place in the footer, directly above the copyrightnotice.

align

The horizontal alignment of the Sign In box. Defaults to"center". Validvalues are"left","center", or"right"

button_color

the color of the "Continue", "Sign In", and "Register" buttons. If keptasNULL, the default, then the button color will be the same color as the color passed tothecolor argument.

footer_color

the text color for the copyright text in the footer.

Value

the html and css to create the default sign in UI.

the UI for the Sign In & Registration pages


Sign Out from your Shiny app

Description

Call this function to sign a user out of your Shiny app. This function shouldbe called inside the server function of your Shiny app. Seehttps://github.com/Tychobra/polished/blob/master/inst/examples/polished_example_01/server.RFor an example of this function being called after the user clicks a "Sign Out"button.

Usage

sign_out_from_shiny(  session = shiny::getDefaultReactiveDomain(),  redirect_page = "?page=sign_in")

Arguments

session

the Shinysession

redirect_page

the query string for the page that the user should be redirectedto after signing out.

Value

invisible(NULL)


Polished API - Update an App

Description

Polished API - Update an App

Usage

update_app(app_uid, app_name = NULL, app_url = NULL, api_key = get_api_key())

Arguments

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 usingset_api_key()so that you do not need to supply this argument with each function call.

Value

an object of classpolished_api_res. When successful, thecontent of thepolished_api_res islist(message = "success"). In the case of an error, thecontent islist(error = "<error message>").

See Also

get_apps()add_app()delete_app()


Polished API - Update an App User

Description

Polished API - Update an App User

Usage

update_app_user(app_uid, user_uid, is_admin = FALSE, api_key = get_api_key())

Arguments

app_uid

the app uid to update.

user_uid

the user uid to update.

is_admin

boolean (default:FALSE) - whether or not the user is an admin.

api_key

your Polished API key. Set your polished api key usingset_api_key()so that you do not need to supply this argument with each function call.

Value

an object of classpolished_api_res. When successful, thecontent of thepolished_api_res islist(message = "success"). In the case of an error, thecontent islist(error = "<error message>").

See Also

get_app_users()add_app_user()delete_app_user()


Polished API - Update a user

Description

Polished API - Update a user

Usage

update_user(user_uid, user_data, api_key = get_api_key())

Arguments

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 usingset_api_key()so that you do not need to supply this argument with each function call.

Value

an object of classpolished_api_res. When successful, thecontent of thepolished_api_res islist(message = "success"). In the case of an error, thecontent islist(error = "<error message>").

See Also

get_users()add_user()delete_user()


admin user access module

Description

Server function for the default Shiny module to control user access in thepolishedAdmin Panel.

Usage

user_access_module(input, output, session)

Arguments

input

the Shiny server input

output

the Shiny server output

session

the Shiny server session

Value

invisible(NULL)


admin user access_ui

Description

Shiny module UI for the default user access tab in thepolished Admin Panel.

Usage

user_access_module_ui(id)

Arguments

id

the module id

Value

the UI to create the user access module.


Valid Regions for Polished Hosting

Description

Set theregion argument ofdeploy_app() to one of these regions.

Usage

valid_gcp_regions

Format

An object of classcharacter of length 35.


[8]ページ先頭

©2009-2025 Movatter.jp