-
Notifications
You must be signed in to change notification settings - Fork 0
/
keyring_ex.Rmd
73 lines (52 loc) · 1.8 KB
/
keyring_ex.Rmd
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
---
title: "Keyring Integrations"
output: html_notebook
---
The `keyring` package enables accessing the operating system's credential store.
```{r}
library(keyring)
key_bk <- default_backend()
```
For instance, you can see all keyrings with the `list_keyring` command.
```{r}
key_bk$keyring_list()
```
The "login" keyring is automatically unlocked when you login, which is helpful to accessing credentials naturally. You can use this keyring by default without hassle, or create one of your own. When you do so, you will be prompted for a password that locks / unlocks the keyring
```{r}
key_bk$keyring_create("new_keyring")
key_bk$keyring_list()
```
Once you decide on a keyring, you can store credentials in it... when doing so, you will be prompted for the password for the item you are storing.
```{r}
key_bk$set("myservice", "myuser", "new_keyring")
key_bk$keyring_list()
key_bk$list("myservice", "new_keyring")
```
If you lock the keyring, credentials are not accessible without the keyring password.
```{r}
key_bk$keyring_lock("new_keyring")
key_bk$keyring_is_locked("new_keyring")
key_bk$list("new_keyring")
```
Once unlocked (requires password), you can add, change, and access credentials.
```{r}
key_bk$keyring_unlock("new_keyring")
key_bk$keyring_is_locked("new_keyring")
```
```{r}
key_bk$set_with_value("myservice", "myuser", "pass2", "new_keyring")
key_bk$set_with_value("myservice", "myuser2", "pass", "new_keyring")
key_bk$keyring_list()
key_bk$list("myservice", "new_keyring")
key_bk$get("myservice", "myuser", "new_keyring")
```
We can also delete the keyring when no longer necessary.
```{r}
key_bk$delete("myservice","myuser","new_keyring")
key_bk$delete("myservice", "myuser2", "new_keyring")
key_bk$keyring_delete("new_keyring")
```
And then confirm that it is gone:
```{r}
key_bk$keyring_list()
```