Skip to content

feat: added skip-hash for basic auth for Konnect#1765

Merged
Prashansa-K merged 8 commits intomainfrom
feat/basic-auth-skip-hash
Sep 30, 2025
Merged

feat: added skip-hash for basic auth for Konnect#1765
Prashansa-K merged 8 commits intomainfrom
feat/basic-auth-skip-hash

Conversation

@Prashansa-K
Copy link
Contributor

@Prashansa-K Prashansa-K commented Sep 25, 2025

This feature introduces a flag to be used with sync
command to skip-hashing of basic-auth credential
passwords when using with Konnect.
An info field is also added for the same.

Linked PRs:
Kong/go-kong#576
Kong/go-database-reconciler#342

For #1747

@codecov-commenter
Copy link

codecov-commenter commented Sep 25, 2025

Codecov Report

❌ Patch coverage is 0% with 19 lines in your changes missing coverage. Please review.
✅ Project coverage is 32.71%. Comparing base (c9e1aa8) to head (a098a1f).

Files with missing lines Patch % Lines
cmd/common.go 0.00% 13 Missing ⚠️
cmd/gateway_apply.go 0.00% 3 Missing ⚠️
cmd/gateway_sync.go 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1765      +/-   ##
==========================================
- Coverage   32.79%   32.71%   -0.08%     
==========================================
  Files          73       73              
  Lines        8093     8112      +19     
==========================================
  Hits         2654     2654              
- Misses       5273     5292      +19     
  Partials      166      166              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

"thus gaining some performance with large configs.\n"+
"Usage of this flag without apt select-tags and default-lookup-tags can be problematic.\n"+
"This flag is not valid with Konnect.")
syncCmd.Flags().BoolVar(&dumpConfig.SkipHashForBasicAuth, "skip-hash-for-basic-auth",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we not want this flag for gateway apply?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will add

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, in cases where the basic auth has been synced before without the flag, using this flag leads to no diff and so no action - that is expected, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. That is expected.
The GET /basic-auth endpoint doesn't have any skip-hash param. So, there's no way of knowing if the returned password is a hash or not. Earlier too we didn't compare for passwords while syncing/diffing. So, I am retaining the same behaviour.

@Prashansa-K Prashansa-K force-pushed the feat/basic-auth-skip-hash branch from 067bc53 to 15b64a5 Compare September 29, 2025 07:00
@Prashansa-K Prashansa-K force-pushed the feat/basic-auth-skip-hash branch from 4baf58a to c14ff4f Compare September 29, 2025 07:57
return true
}

if targetContent.Info != nil && targetContent.Info.SkipHashForBasicAuth {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this block necessary? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A user can choose to pass a command-line flag or use the info block to trigger the skip-hash functionality. So, this block looks at the info block to see if there's a skip-hash there.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not blocking, for knowledge purposes - we don't write the bool to the Info field on dump though, correct? Is adding field to Info block a common approach users take?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't write the bool to the Info field on dump though, correct?

For this one, we can't. This is because the GET /basic-auth endpoint doesn't tell us if the password is a hash or not.
So, this particular thing is not valid for dump.

Is adding field to Info block a common approach users take?

Yes. The metadata remains a part of the config. So, it is "safer", as folks can forget to pass the CLI flag.

@Prashansa-K Prashansa-K merged commit bb5d676 into main Sep 30, 2025
97 of 115 checks passed
@Prashansa-K Prashansa-K deleted the feat/basic-auth-skip-hash branch September 30, 2025 07:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants