View source: R/check_credentials.R
check_credentials | R Documentation |
Check credentials
check_credentials(db, passphrase = NULL)
db |
A |
passphrase |
Passphrase to decrypt the SQLite database. |
The credentials data.frame
can have the following columns:
user (mandatory) : the user's name.
password (mandatory) : the user's password.
admin (optional) : logical, is user have admin right ? If so, user can access the admin mode (only available using a SQLite database)
start (optional) : the date from which the user will have access to the application
expire (optional) : the date from which the user will no longer have access to the application
applications (optional) : the name of the applications to which the user is authorized,
separated by a semicolon. The name of the application corresponds to the name of the directory,
or can be declared using : options("shinymanager.application" = "my-app")
additional columns : add others columns to retrieve the values server-side after authentication
Return a function
with two arguments: user
and password
to be used in module-authentication
. The authentication function returns
a list
with 4 slots :
result : logical, result of authentication.
expired : logical, is user has expired ? Always FALSE
if db
doesn't have a expire
column.
authorized : logical, is user can access to his app ? Always TRUE
if db
doesn't have a applications
column.
user_info : the line in db
corresponding to the user.
# data.frame with credentials info credentials <- data.frame( user = c("fanny", "victor"), password = c("azerty", "12345"), stringsAsFactors = FALSE ) # check a user check_credentials(credentials)("fanny", "azerty") check_credentials(credentials)("fanny", "azert") check_credentials(credentials)("fannyyy", "azerty") # data.frame with credentials info # using hashed password with scrypt credentials <- data.frame( user = c("fanny", "victor"), password = c(scrypt::hashPassword("azerty"), scrypt::hashPassword("12345")), is_hashed_password = TRUE, stringsAsFactors = FALSE ) # check a user check_credentials(credentials)("fanny", "azerty") check_credentials(credentials)("fanny", "azert") check_credentials(credentials)("fannyyy", "azerty") ## Not run: ## With a SQLite database: check_credentials("credentials.sqlite", passphrase = "supersecret") ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.