fix: add more stable validation for harbor-cli login#810
Merged
Conversation
- add a skip-verify-client flag that allows for credendtial addition without validating against the server - client validation is based on 4xx and 5xx errors. - 4xx errors mean unauthorized - 5xx errors lead to more checks of other endpoints Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
Robot accounts get 412 from /users/current (undocumented in swagger). Old code treated all 4xx as auth failure. Now only 401/403 = auth failure. Other errors fall through to ListProjects + Ping checks if both pass, creds are valid. Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #810 +/- ##
=========================================
- Coverage 10.99% 9.09% -1.90%
=========================================
Files 173 272 +99
Lines 8671 13469 +4798
=========================================
+ Hits 953 1225 +272
- Misses 7612 12128 +4516
- Partials 106 116 +10 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
GetCurrentUserInfo as primary auth check (401/403 = bad creds). On other errors (412 robot, 5xx), fall back to ListProjects + Ping. ListProjects fallback also checks for 401/403 to catch bad creds that ListProjects won't silently pass. Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
Co-authored-by: Nucleo Fusion <148791547+NucleoFusion@users.noreply.github.com> Signed-off-by: Patrick Eschenbach <45457307+qcserestipy@users.noreply.github.com>
govet's inline check is overly aggressive—readability of named constants like reflect.Ptr outweighs micro-optimization gains. Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds a
--skip-verify-clientflag toharbor loginand improves error handling during client validation.Type of Change
Changes
--skip-verify-clientflag to skip credential validation against the Harbor server during loginListProjectsandPingendpoints and report which succeeded/failed