R/config.R
config.RdCall these functions every time you need to get environment variables set, like the URL, user and password of the MongoDB database used by the course.
config(
url,
password,
cache = file.path(tempdir(), ".learnitdown_config"),
debug = Sys.getenv("LEARNITDOWN_DEBUG", 0) != 0
)
sign_in(
data,
password,
cipher = "aes-256-cbc",
iv = NULL,
cache = file.path(tempdir(), ".learnitdown_user"),
debug = Sys.getenv("LEARNITDOWN_DEBUG", 0) != 0
)
sign_out(
title = "Signing out",
message = "Do you really want to sign out with learnitdown?",
cache = file.path(tempdir(), ".learnitdown_user"),
debug = Sys.getenv("LEARNITDOWN_DEBUG", 0) != 0
)
encrypt(
object,
password,
cipher = "aes-256-cbc",
iv = NULL,
serialize = TRUE,
base64 = FALSE,
url.encode = FALSE
)
decrypt(
object,
password,
cipher = "aes-256-cbc",
iv = NULL,
unserialize = TRUE,
base64 = FALSE,
url.decode = FALSE
)
lock(
object,
password,
key = "",
message = "Password for learnitdown:",
reset = FALSE,
ref1 = NULL,
ref2 = NULL
)
unlock(
object,
password,
key = "",
message = "Password for learnitdown:",
reset = FALSE,
ref1 = NULL,
ref2 = NULL
)The URL of the encrypted file that contains the configuration information.
The password to crypt, decrypt, lock or unlock the data.
The path to the file to use to store a cached version of these data. Access to the database will be checked, and if it fails, the configuration data are refreshed from the URL.
Do we issue debugging messages? By default, it is set according
to the LEARNITDOWN_DEBUG environment variable (yes, if this variable is not
0).
The fingerprint data in clear or ciphered form (in this case, the string must start with "fingerprint=").
The cryptography algorithm to use.
The initialization vector for the cipher.
The title of the dialog box prompting to sign out.
The message of the dialog box prompting to sign out, or asking for a password.
An object to be encrypted, decrypted, locked or unlocked.
Do we serialize object before ciphering it (TRUE by
default)?
Do we encode/decode base64 the object (FALSE by default)?
Do we encode for URL (query) use (FALSE by default) ?
Do we unserialize the resulting object after deciphering
it (TRUE by default)?
Do we decode URL before deciphering it (FALSE by
default)?
The key that stores the password. It is advised to use something
like course_year, so that you can manage different passwords for the same
course given at different academic years. Using a key, the course password
must be entered only once. If not provided, the password is not stored. Note
also that the name of an environment variable could be used too for the key.
This is convenient on a server like RStudio Connect, for instance.
Should we reset the password (FALSE by default)?
Code to check the validity of the password
Second code to check password validity.
Invisibly returns TRUE if success, or FALSE otherwise for
config(). The encrypted/decrypted object for encrypt() and decrypt(),
or the locked/unlocked object for lock() and unlock().
The user information for sign_in().