Fix hash_application_secrets fallback not upgrading secret on access#1801
Fix hash_application_secrets fallback not upgrading secret on access#1801
Conversation
Co-authored-by: nbulaj <[email protected]>
hash_application_secrets upgrade issue|
@copilot should it be implemented using secret storable pattern? Like in |
Co-authored-by: nbulaj <[email protected]>
Good point. Moved the upgrade logic out of Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot shouldn't fallback happen before return unless app.secret_matches?(secret) is called? Since secret is hashed |
…flow Agent-Logs-Url: https://github.com/doorkeeper-gem/doorkeeper/sessions/4ed929bb-0df5-468c-8913-2d5909a973e9 Co-authored-by: nbulaj <[email protected]>
Yes, fixed in Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
| app | ||
| # Try the primary (active) secret strategy first. | ||
| if !secret.nil? && !app.secret.nil? && | ||
| secret_strategy.secret_matches?(secret.to_s, app.secret.to_s) |
There was a problem hiding this comment.
📝 [rubocop] <Layout/MultilineOperationIndentation> reported by reviewdog 🐶
Align the operands of a condition in an if statement spanning multiple lines.
| # to migrate the stored secret to the active strategy (mirrors the | ||
| # find_by_plaintext_token -> find_by_fallback_token pattern). | ||
| if fallback_secret_strategy && !secret.nil? && !app.secret.nil? && | ||
| fallback_secret_strategy.secret_matches?(secret.to_s, app.secret.to_s) |
There was a problem hiding this comment.
📝 [rubocop] <Layout/MultilineOperationIndentation> reported by reviewdog 🐶
Align the operands of a condition in an if statement spanning multiple lines.
hash_application_secrets fallback: :plaincould find applications stored with plain secrets, but unlike access tokens and grants, never upgraded those secrets to the active hashing strategy. The upgrade path throughupgrade_fallback_valuewas only wired up inAccessGrantMixinandAccessTokenMixin(viafind_by_plaintext_token), not for applications.Changes
application_mixin.rb—by_uid_and_secretnow explicitly tries the primary strategy first, then the fallback strategy with the upgrade embedded directly in the fallback path — mirroring thefind_by_plaintext_token→find_by_fallback_token→upgrade_fallback_valuepattern used by tokens and grants.secret_matches?remains a pure comparison predicate with no side effects:hashing_shared_context.rb— Added"with application hashing and fallback lookup enabled"shared context (configureshash_application_secrets fallback: :plain).application_spec.rb— Added test verifying that a plain secret is upgraded to SHA256 on first access viaby_uid_and_secret, and that subsequent lookups succeed via the hashed value.Original prompt
hash_application_secretsdoes not upgrade secret when accessed #1780📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.