restbatch-user: Give additional user server access

Description Usage Arguments Examples

Description

See examples on how to give additional remote users access.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
generate_pem(
  userid,
  role = c("user", "admin"),
  password = rand_string(8),
  username = "Unknown",
  pem_file = tempfile(),
  dry_run = FALSE,
  overwrite = FALSE,
  force = FALSE
)

my_userid()

add_pem(pem_file, password = "", username = get_username())

Arguments

userid

user's ID

role

role of the user; choices as 'user' (default) and 'admin'

password

a secret code to encode/decode the private key. This is not the user's password. It is just some code that only is shared between the system admin and the target user. If password is not blank, then even if someone gets your pem_file, the private key is still safe.

username

the user's name

pem_file

where the encrypted key should be saved to

dry_run

to display the result instead of actually adding the user to the database

overwrite

whether to overwrite the private keys if the user already exists in the database

force

whether to force adding the user. This is usually used with overwrite. If the user already exists, force=FALSE will raise errors or prompt for options. If force=TRUE, then the key will be added. Depending on overwrite choice, if overwrite is set to false, then multiple keys will coexist for the same user and they can use any one to file task requests.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# ----------- If you are the server admin -----------
# The server admin need to get end user's user ID and a user name
# To add the user,

# assuming the user ID is as follows (I created a fake one)
userid <- "22dbdc9e876a74a768c15e03c7356780"
username <- "Alice"
pem <- generate_pem(userid = userid, username = username, force = TRUE)

# Now share the passcode and pen_file to the end user
# password is
pem$password

# encoded pem_file is stored at
pem$pem_file

# ---------- If you are the end user ----------

# Send your user ID and your preferred user name to the system admin
# user ID can be obtained from `my_userid()`

my_userid()  # something like "22dbdc9e876a74a768c15e03c7356780" (32-length)

# You will get a passcode and a pem file from the system admin
# (see variable `pem` in the previous example)

add_pem(pem$pem_file, pem$password, username = 'Alice')

dipterix/restbatch documentation built on Oct. 13, 2021, 8:58 a.m.