NetDevPack / Security.Jwt

Jwt Manager. Set of components to deal with Jwt Stuff. Automate your key rotating, add support for jwks_uri. Store your cryptography keys in a secure place.
MIT License
271 stars 38 forks source link

CreationDate problem with use Ngpsql.EntityFrameworkCore.PostgreSQL > 6.0 #23

Closed eliezeralmeida closed 2 years ago

eliezeralmeida commented 2 years ago

More details: https://www.roji.org/postgresql-dotnet-timestamp-mapping

Details of problem:

From what I understand, basically the problem happens when you have a date with Kind other than UTC, to get around the problem a flag must be changed globally, but it is not a good practice, the best is to use the concept of "UTC Everywhere".

Checking the source code on line 14 of the KeyMaterial file, the Data value starts with Now, this causes the error because of Kind=Local.

Likely correction: KeyMaterial line 14: DateTime.UtcNow KeyMaterial line 37: DateTime.UtcNow

This will make Npgsql not throw excpetion on account of Kind other than UTC and also the dates will be bought in UTC ignoring infra setting.

Imagem do erro em um projeto .NET6 com PostgreSQL:

image

Conclusion

If these changes make sense for the project proposal, I can be making and submitting the pull request. I used google translate to create the text, in case something was confused in the translation I can send it in pt-br.

eliezeralmeida commented 2 years ago

In my project I resolved the problem adding one interceptor for transform dates to utc dates, but it would be nice to have the fix in the package.

image

brunobritodev commented 2 years ago

Hi @eliezeralmeida ,

It makes sense, go ahead and make a pr!

Thx

brunobritodev commented 2 years ago

Fixed at v6.0.6