Store an edge authentication token for a gateway.
(gateway_name: &str, token: &str)
| 24 | |
| 25 | /// Store an edge authentication token for a gateway. |
| 26 | pub fn store_edge_token(gateway_name: &str, token: &str) -> Result<()> { |
| 27 | let path = edge_token_path(gateway_name)?; |
| 28 | ensure_parent_dir_restricted(&path)?; |
| 29 | std::fs::write(&path, token) |
| 30 | .into_diagnostic() |
| 31 | .wrap_err_with(|| format!("failed to write edge token to {}", path.display()))?; |
| 32 | // Restrict permissions to owner-only (0600). |
| 33 | set_file_owner_only(&path)?; |
| 34 | Ok(()) |
| 35 | } |
| 36 | |
| 37 | /// Load a stored edge authentication token for a gateway. |
| 38 | /// |