Closed treyhendon closed 1 month ago
I'm debugging through locally to try to find a solution. Posting here in case you know a quick fix. Thanks!
Are all base properties null?
The System.Text.Json custom converters seem to be problematic if used via attributes. (vs programmatically) I'll also debug further. https://github.com/dotnet/runtime/issues/46372
Any base property that didn't have a default in the class appears null, yes. I do see the value in the jsonString
from the API response.
I followed your comment in the ConnectionConfigModel
class and saw that .net issue about STJ. I was testing different forms of attribute references to see if I could force the base model to deserialize first, but so far no luck.
As an example, here's what I get in jsonString
:
{"allowed_roles":["api-sample","api-sample-migration"],"connection_details":{"connection_url":"postgresql://{{username}}:{{password}}@myserver.svc.cluster.local:5432/sample?sslmode=require","username":"myuser"},"password_policy":"","plugin_name":"postgresql-database-plugin","plugin_version":"","root_credentials_rotate_statements":[]}
I made a temp obj variable to capture the deserialzed value:
thanks , that is very helpful. I think it is not a deser issue. The structure of the connection object between the write and read seems to be different. The read structure is as follows: https://developer.hashicorp.com/vault/api-docs/secret/databases#sample-response
Thats the problem. I'll release a fix with the right model tomorrow.
Oh! I think I see it. The JSON structure is slightly different than expected.
{
"allowed_roles": [
"api-sample",
"api-sample-migration"
],
"connection_details": {
"connection_url": "postgresql://{{username}}:{{password}}@myserver.svc.cluster.local:5432/sample?sslmode=require",
"username": "myuser"
},
"password_policy": "",
"plugin_name": "postgresql-database-plugin",
"plugin_version": "",
"root_credentials_rotate_statements": []
}
Looks like ConnectionDetails
would hold ConnectionUrl
, Username
, Password
, etc
@treyhendon I prepared a local fix. Which version of .NET are you using? i'll give you a DLL for temp testing here, before releasing a nuget
I'm using .net 8. Thanks!
please use this dll and let me know. VaultSharp-1.17.5.1-For-Test-.NET 8.zip
I actually just pulled your master branch and was able to successfully test! I'll download the dll and try that as well. Thanks!
Ah cool. I forget that folks can easily build from the project as well.
I can also confirm the .net 8 dll is a success. Thanks again for such a quick response!
Cool, good to hear. I'll publish the official nuget in a day. It's my bad, I overlooked the read Api response model.
@treyhendon , here it is: https://www.nuget.org/packages/VaultSharp/1.17.5.1
https://github.com/rajanadar/VaultSharp/blob/4f906a91681a2f1d265065d1c43c1f726602afe4/src/VaultSharp/V1/SecretsEngines/Database/ConnectionConfigModelJsonConverter.cs#L109
PostgreSQLConnectionConfigModel
is properly being deserialized, but base properties fromConnectionConfigModel
(i.e. connection_url, username, password) are null in the returnedSecret<ConnectionConfigModel>
.