Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fastly_api::apis::secret_store_api::client_key not returning a client key #10

Open
0rphon opened this issue May 29, 2024 · 0 comments
Open
Labels
bug Something isn't working

Comments

@0rphon
Copy link

0rphon commented May 29, 2024

it seems fastly_api::models::client_key::ClientKey has the wrong field name for the client key. the following should return a key, but instead returns none.

example (with my key omitted):

use fastly_api::apis::configuration::{ApiKey, Configuration};
use fastly_api::apis::secret_store_api::client_key;

#[tokio::main]
async fn main() {
    let mut config = Configuration {
        api_key: Some(ApiKey {
            prefix: None,
            key: "YOUR_FASTLY_TOKEN".into(),
        }),
        ..Default::default()
    };
    dbg!(client_key(&mut config).await);
}

output (with my exact values omitted):

[src/main.rs:13:5] client_key(&mut config).await = Ok(
    ClientKey {
        client_key: None,
        signature: Some(_),
        expires_at: Some(_),
    },
)

while the equivalent curl command curl -i -X POST "https://api.fastly.com/resources/stores/secret/client-key" -H "Fastly-Key: YOUR_FASTLY_TOKEN" -H "Accept: application/json" returns:

{
  "public_key": "omitted",
  "signature": "omitted",
  "expires_at": "omitted"
}

you'll notice the curl command returns the field public_key, while the rust call returns the field client_key. looking at the rust code we can see the same issue

#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)]
pub struct ClientKey {
/// A Base64-encoded X25519 public key that can be used with a [libsodium-compatible sealed box](https://libsodium.gitbook.io/doc/public-key_cryptography/sealed_boxes) to encrypt secrets before upload.
#[serde(rename = "client_key", skip_serializing_if = "Option::is_none")]
pub client_key: Option<String>,
/// A Base64-encoded signature of the client key. The signature is generated using the signing key and must be verified before using the client key.
#[serde(rename = "signature", skip_serializing_if = "Option::is_none")]
pub signature: Option<String>,
/// Date and time in ISO 8601 format.
#[serde(rename = "expires_at", skip_serializing_if = "Option::is_none")]
pub expires_at: Option<String>,
}

i would normally just fix this myself and PR it, but seeing how the library is generated from an openapi spec, i figured id just report it instead

@0rphon 0rphon added the bug Something isn't working label May 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant