equinor / witsml-explorer

Witsml Explorer data management tool.
Apache License 2.0
45 stars 50 forks source link

Add credential verification #2248

Open janmarius opened 7 months ago

janmarius commented 7 months ago

Implement credential verification to ensure that the credentials entered are in the correct format and contain the correct URL format. Currently, this error is thrown when not in the correct format, this should also be more descriptive:

2024-02-22 12:31:02.638 +01:00 [INF] Executed endpoint '"HTTP: GET /api/witsml-servers => GetWitsmlServers"'
2024-02-22 12:31:02.638 +01:00 [FTL] Something went wrong: System.InvalidOperationException: This operation is not supported for a relative URI.
   at System.Uri.get_AbsoluteUri()
   at WitsmlExplorer.Api.Services.CredentialsService.<>c__DisplayClass16_0.<GetSystemCredentialsByToken>b__4(ServerCredentials n) in /build/Src/WitsmlExplorer.Api/Services/CredentialsService.cs:line 143
   at System.Linq.Enumerable.WhereListIterator`1.MoveNext()
eliasbruvik commented 7 months ago

I think the relevant file in this case is WitsmlSystemCredentials.cs, before adding items to the credential list. To ensure that the application won't just fail like it does today, I think we should just skip adding the items to the list, and then log an error with a fitting message.