i8beef / HomeAutio.Mqtt.GoogleHome

MIT License
215 stars 29 forks source link

Can't authenticate, antiforgery error #133

Closed digiext closed 2 years ago

digiext commented 2 years ago

I can get the main webpage to come up with the login box but when I enter the username and password in the appsettings.Production.json file I get a 400 page with the following errors in my log:

[15:21:05 INF] Antiforgery token validation failed. The antiforgery token could not be decrypted.

Microsoft.AspNetCore.Antiforgery.AntiforgeryValidationException: The antiforgery token could not be decrypted. ---> System.Security.Cryptography.CryptographicException: The key {19ec21d6-9ce4-47d7-aaef-076479b8256f} was not found in the key ring. at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingBasedDataProtector.UnprotectCore(Byte[] protectedData, Boolean allowOperationsOnRevokedKeys, UnprotectStatus& status) at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingBasedDataProtector.DangerousUnprotect(Byte[] protectedData, Boolean ignoreRevocationErrors, Boolean& requiresMigration, Boolean& wasRevoked) at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingBasedDataProtector.Unprotect(Byte[] protectedData) at Microsoft.AspNetCore.Antiforgery.DefaultAntiforgeryTokenSerializer.Deserialize(String serializedToken) --- End of inner exception stack trace --- at Microsoft.AspNetCore.Antiforgery.DefaultAntiforgeryTokenSerializer.Deserialize(String serializedToken) at Microsoft.AspNetCore.Antiforgery.DefaultAntiforgery.DeserializeTokens(HttpContext httpContext, AntiforgeryTokenSet antiforgeryTokenSet, AntiforgeryToken& cookieToken, AntiforgeryToken& requestToken) at Microsoft.AspNetCore.Antiforgery.DefaultAntiforgery.ValidateTokens(HttpContext httpContext, AntiforgeryTokenSet antiforgeryTokenSet) at Microsoft.AspNetCore.Antiforgery.DefaultAntiforgery.ValidateRequestAsync(HttpContext httpContext) at Microsoft.AspNetCore.Mvc.ViewFeatures.Filters.ValidateAntiforgeryTokenAuthorizationFilter.OnAuthorizationAsync(AuthorizationFilterContext context) [15:21:05 INF] Authorization failed for the request at filter 'Microsoft.AspNetCore.Mvc.ViewFeatures.Filters.ValidateAntiforgeryTokenAuthorizationFilter'.

I notice that it say the key is not in the ring but I am not sure how or where to enter this key. This does not match any of the GUIDs I used in my config files.

Any help would be appreciated.

i8beef commented 2 years ago

You don't define the key. The app generates the encryption keys for antiforgery tokens on startup. Are you seeing the app restarting on you in the logs, maybe because of an incomplete setup process, and thus another crash?

digiext commented 2 years ago

I don't see the app restarting in the logs. All I see every minute is Removing expired grants written to the log.

This is running in a docker container on an Unraid server if that makes any difference.

i8beef commented 2 years ago

All I see every minute is Removing expired grants written to the log.

Normal.

Try clearing your cookies first / looking at it in an incognito tab so you have a fresh experience.

If that doesn't work, I'll probably need to see your Docker command and proxy setup.

digiext commented 2 years ago

A restart of the docker container after 3 days of letting it sit seems to have resolved the issue. It is working correctly now and I am able to control my devices. Thank you for your time and awesome software!