Title: | Simple Authentification for 'shiny' Applications |
---|---|
Description: | Provides a simple authentification mechanism for single 'shiny' applications. Authentification and password change functionality are performed calling user provided functions that typically access some database backend. Source code of main applications is protected until authentication is successful. |
Authors: | Diego Florio [aut, cre] |
Maintainer: | Diego Florio <[email protected]> |
License: | GPL-3 |
Version: | 1.0.0.2 |
Built: | 2025-02-28 04:31:52 UTC |
Source: | https://github.com/diegoefe/shinydbauth |
See all labels registered with get_labels()
,
then set custom text with set_labels()
.
set_labels(language, ...) get_labels(language = "en")
set_labels(language, ...) get_labels(language = "en")
language |
Language to use for labels, supported values are : "en", "es". |
... |
A named list with labels to replace. |
get_labels()
return a named list with all labels registered.
# In global.R for example: set_labels( language = "en", "Please authenticate" = "You have to login", "Username:" = "What's your name:", "Password:" = "Enter your password:" )
# In global.R for example: set_labels( language = "en", "Please authenticate" = "You have to login", "Username:" = "What's your name:", "Password:" = "Enter your password:" )
Create a fixed button in page corner with additional button(s) in it
fab_button( ..., position = c("bottom-right", "top-right", "bottom-left", "top-left", "none"), animation = c("slidein", "slidein-spring", "fountain", "zoomin"), toggle = c("hover", "click"), inputId = NULL, label = NULL )
fab_button( ..., position = c("bottom-right", "top-right", "bottom-left", "top-left", "none"), animation = c("slidein", "slidein-spring", "fountain", "zoomin"), toggle = c("hover", "click"), inputId = NULL, label = NULL )
... |
|
position |
Position for the button. |
animation |
Animation when displaying floating buttons. |
toggle |
Display floating buttons when main button is clicked or hovered. |
inputId |
Id for the FAB button (act like an |
label |
Label for main button. |
Authentication module
auth_ui( id, status = "primary", tags_top = NULL, tags_bottom = NULL, background = NULL, choose_language = NULL, lan = NULL, ... ) auth_server( input, output, session, check_credentials, use_token = FALSE, lan = NULL )
auth_ui( id, status = "primary", tags_top = NULL, tags_bottom = NULL, background = NULL, choose_language = NULL, lan = NULL, ... ) auth_server( input, output, session, check_credentials, use_token = FALSE, lan = NULL )
id |
Module's id. |
status |
Bootstrap status to use for the panel and the button.
Valid status are: |
tags_top |
A |
tags_bottom |
A |
background |
A optionnal |
choose_language |
|
lan |
A language object. See |
... |
: Used for old version compatibility. |
input , output , session
|
Standard Shiny server arguments. |
check_credentials |
Function with two arguments (
|
use_token |
Add a token in the URL to check authentication. Should not be used directly. |
A reactiveValues
with 3 slots :
result : logical, result of authentication.
user : character, name of connected user.
user_info : information about the user.
Change password module
chpass_ui(id, tag_img = NULL, status = "primary", lan = NULL) chpass_server( input, output, session, update_credentials, validate_pwd = NULL, use_token = FALSE, lan = NULL )
chpass_ui(id, tag_img = NULL, status = "primary", lan = NULL) chpass_server( input, output, session, update_credentials, validate_pwd = NULL, use_token = FALSE, lan = NULL )
id |
Module's id. |
tag_img |
A |
status |
Bootstrap status to use for the panel and the button.
Valid status are: |
lan |
An language object. Should not be used directly. |
input , output , session
|
Standard Shiny server arguments. |
update_credentials |
A |
validate_pwd |
A |
use_token |
Add a token in the URL to check authentication. Should not be used directly. |
Secure a Shiny application and manage authentication
secure_app( ui, ..., head_auth = NULL, theme = NULL, language = "en", fab_position = "bottom-right" ) secure_server( check_credentials, timeout = 15, inputs_list = NULL, keep_token = FALSE, validate_pwd = NULL, update_credentials = NULL, session = shiny::getDefaultReactiveDomain() ) create_server(check_credentials, update_credentials, server_fn)
secure_app( ui, ..., head_auth = NULL, theme = NULL, language = "en", fab_position = "bottom-right" ) secure_server( check_credentials, timeout = 15, inputs_list = NULL, keep_token = FALSE, validate_pwd = NULL, update_credentials = NULL, session = shiny::getDefaultReactiveDomain() ) create_server(check_credentials, update_credentials, server_fn)
ui |
UI of the application. |
... |
Arguments passed to |
head_auth |
Tag or list of tags to use in the |
theme |
Alternative Bootstrap stylesheet, default is to use |
language |
Language to use for labels, supported values are : "en", "es". |
fab_position |
Position for the FAB button, see |
check_credentials |
Function passed to |
timeout |
Timeout session (minutes) before logout if sleeping. Defaut to 15. 0 to disable. |
inputs_list |
|
keep_token |
Logical, keep the token used to authenticate in the URL, it allow to refresh the
application in the browser, but careful the token can be shared between users ! Default to |
validate_pwd |
A |
update_credentials |
Function passed to |
session |
Shiny session. |
server_fn |
Function that returns the authenticated server. |
If database credentials, you can configure inputs with inputs_list
for editing users information
from the admin console. start
, expire
, admin
and password
are not configurable.
The others columns are rendering by defaut using a textInput
. You can modify this using inputs_list
.
inputs_list
must be a named list. Each name must be a column name, and then we must have the function
shiny to call fun
and the arguments args
like this :
list(group = list(
fun = "selectInput",
args = list(
choices = c("all", "restricted"),
multiple = TRUE,
selected = c("all", "restricted")
)
)
)
You can specify if you want to allow downloading users file, sqlite database and logs from within
the admin panel by invoking options("shinydbauth.download")
. It defaults
to c("db", "logs", "users")
, that allows downloading all. You can specify
options("shinydbauth.download" = "db"
if you want allow admin to download only
sqlite database, options("shinydbauth.download" = "logs")
to allow logs download
or options("shinydbauth.download" = "")
to disable all.
Using options("shinydbauth.pwd_validity")
, you can set password validity period. It defaults
to Inf
. You can specify for example
options("shinydbauth.pwd_validity" = 90)
if you want to force user changing password each 90 days.
Using options("shinydbauth.pwd_failure_limit")
, you can set password failure limit. It defaults
to Inf
. You can specify for example
options("shinydbauth.pwd_failure_limit" = 5)
if you want to lock user account after 5 wrong password.
create_server
calls secure_server
and, if authentication is ok, passes user_info to server_fn
A reactiveValues
containing informations about the user connected.
A special input value will be accessible server-side with input$shinydbauth_where
to know in which step user is : authentication, application, admin or password.
See all labels registered with get_labels()
,
then set custom text with set_labels()
.
use_language(lan = "en")
use_language(lan = "en")
lan |
Language to use for labels, supported values are : "en", "es". |
A language object
use_language(lan = "en")
use_language(lan = "en")