create_db: Create credentials database

View source: R/credentials-db.R

create_dbR Documentation

Create credentials database

Description

Create a SQLite database with credentials data protected by a password.

Usage

create_db(
  credentials_data,
  sqlite_path,
  passphrase = NULL,
  flags = RSQLite::SQLITE_RWC
)

Arguments

credentials_data

A data.frame with information about users, user and password are required.

sqlite_path

Path to the SQLite database.

passphrase

A password to protect the data inside the database.

flags

RSQLite::SQLITE_RWC: open the database in read/write mode and create the database file if it does not already exist; RSQLite::SQLITE_RW: open the database in read/write mode. Raise an error if the file does not already exist; RSQLite::SQLITE_RO: open the database in read only mode. Raise an error if the file does not already exist

Details

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

See Also

read_db_decrypt

Examples

## Not run: 

# Credentials data
credentials <- data.frame(
  user = c("shiny", "shinymanager"),
  password = c("azerty", "12345"), # password will automatically be hashed
  stringsAsFactors = FALSE
)

# you can use keyring package to set database key
library(keyring)
key_set("R-shinymanager-key", "obiwankenobi")

# Create the database
create_db(
  credentials_data = credentials,
  sqlite_path = "path/to/database.sqlite", # will be created
  passphrase = key_get("R-shinymanager-key", "obiwankenobi")
)


## End(Not run)

shinymanager documentation built on Sept. 27, 2022, 9:06 a.m.