zapadi/redmine-netcore-api

basic http auth not working

Xelbair opened this issue · 5 comments

Http auth works fine when you are using API key, yet it always return 401 Unauthorized when you use basic auth, tested for multiple users.

var auth = RedmineApi.Core.Authentication.BasicAuthentication.Create(username, password);
var manager = new RedmineManager(_uri, auth, MimeType.Json);
var user = await manager.Get<User>("current", new System.Collections.Specialized.NameValueCollection { });

This is not a problem with redmine server configuration, because it works perfectly fine via curl. Tested on version from NuGet.

Oh i forgot to mention, tested on .net core 2.1.602

After debugging a bit over the code, it looks like Authentication variable is used only in one place - the method SetAuthentication(AuthenticationHeaderValue authenticationHeaderValue)

It's value is never used in the codebase at all - at least according to visual studio references. The fix should probably be applied in Build Method of DefaultRedmineHttpSettings, or in the RedmineHttpClient in a way similar to passing the apiKey.

I tried hacking around to pass it through to RedmineHttpClient, managed to get a proper response code(200), but now i get NotImplementedException in RedmineJsonSerializer class - looks like JSON deserialization isn't implemented - which is kinda weird because it seems to work perfectly fine when using apiKey in NuGet version.

I'll dig a bit more into this tomorrow.

Oh silly me, JSON serialization is working as intended, but on dev branch, not on master!

I should be able to adapt my changes to dev branch so it has consistent style, and submit mi first ever pull request to open source project :)

Created PR #9

Oh silly me, JSON serialization is working as intended, but on dev branch, not on master!

I should be able to adapt my changes to dev branch so it has consistent style, and submit mi first ever pull request to open source project :)

The json serialization works only on dev branch for now.
Your PR was accepted and merged :).