Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

logging errors when authentication fails #31

Open
ahus1 opened this issue Feb 10, 2016 · 2 comments
Open

logging errors when authentication fails #31

ahus1 opened this issue Feb 10, 2016 · 2 comments
Assignees
Milestone

Comments

@ahus1
Copy link
Contributor

ahus1 commented Feb 10, 2016

I was trying out the library and had some initial configuration problems. I found that errors were swallowed in this piece of code in KeycloakAuthenticationHandler.cs. I wonder if there could be a possibility to log these errors (and a short paragraph in the configuration guide where to find the log information). This would have saved me some time, and I would need that before going to any non-testing environment.

                    catch (Exception)
                    {
                        // ignored
                    }
@dylanplecki
Copy link
Owner

So to start a discussion on this topic, ASP.NET 4.5 has no formal support for file-based logging, and assumes every "fatal" error will be either gracefully handled or output as an HTTP/HTML -based error response. ASP.NET 5+ fixes with with its own logging solution, but currently this library isn't targeting that platform.

I wrote this library in the ASP.NET 4.5 mentality of "try to fix the problem if one comes up", but obviously this hides common-sense issues like configuration problems that would show up in logging immediately.

So the obvious solution here is to implement one of the various .NET logging libraries, dependent on a configuration option. So, default behavior may be the current behavior + log fatal errors to file using the logging framework. It can be configurable for no logging, or log-all and don't gracefully handle errors, etc.

I'll begin implementing this logging approach for the next major release, beginning in the next few days.

@dylanplecki dylanplecki added this to the v2.2.0 milestone Feb 11, 2016
@dylanplecki dylanplecki self-assigned this Feb 11, 2016
@ahus1
Copy link
Contributor Author

ahus1 commented Feb 12, 2016

I'm not a .NET guy, I am just trying to get Keycloak to work for our setup. Maybe suggesting logging was jumping to conclusions here. Compatibility with ASP.NET 4.5 and minimal dependencies might be very valuable to the other users of the library, probably even to us.

In my case the URLs for Keycloak in the configuration and in the access token didn't match. It was great that there was a configuration option DisableIssuerValidation that solved the problem for me. But it was only by debugging that I found the reason of the problem.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants