Store an OIDC token bundle for a gateway.
(gateway_name: &str, bundle: &OidcTokenBundle)
| 41 | |
| 42 | /// Store an OIDC token bundle for a gateway. |
| 43 | pub fn store_oidc_token(gateway_name: &str, bundle: &OidcTokenBundle) -> Result<()> { |
| 44 | let path = oidc_token_path(gateway_name)?; |
| 45 | ensure_parent_dir_restricted(&path)?; |
| 46 | let json = serde_json::to_string_pretty(bundle) |
| 47 | .into_diagnostic() |
| 48 | .wrap_err("failed to serialize OIDC token bundle")?; |
| 49 | std::fs::write(&path, json) |
| 50 | .into_diagnostic() |
| 51 | .wrap_err_with(|| format!("failed to write OIDC token to {}", path.display()))?; |
| 52 | set_file_owner_only(&path)?; |
| 53 | Ok(()) |
| 54 | } |
| 55 | |
| 56 | /// Load a stored OIDC token bundle for a gateway. |
| 57 | /// |
no test coverage detected