Skip to content

Fix token auth annotation to use opt-in instead of opt-out#15998

Open
TheRealJon wants to merge 1 commit intoopenshift:mainfrom
TheRealJon:token-auth-annotation-bug
Open

Fix token auth annotation to use opt-in instead of opt-out#15998
TheRealJon wants to merge 1 commit intoopenshift:mainfrom
TheRealJon:token-auth-annotation-bug

Conversation

@TheRealJon
Copy link
Member

@TheRealJon TheRealJon commented Feb 5, 2026

Summary

Fixes regression where operators without explicit token-auth-aws: "true" annotation incorrectly show the ARN role field in the subscription form on AWS STS clusters.

Problem

Cluster Observability Operator (and similar operators) have features.operators.openshift.io/token-auth-aws: "false" but the ARN field was still showing in the subscription form on 4.21, even though it worked correctly in 4.20.

Root Cause

Regression introduced in commit a931fbd (Sep 9, 2024) during the "Fix JSON annotation parsing issue and harden related code" refactor.

Before refactor (correct opt-in behavior):

if (tokenAuthAWS === 'true' && isAWSSTSCluster(...)) {
  infrastructureFeatures.push(InfraFeatures.tokenAuth);
}

After refactor (buggy opt-out behavior):

const awsTokenAuthIsSupported =
  clusterIsAWSSTS && annotations[OLMAnnotation.TokenAuthAWS] !== 'false';

This changed the logic from opt-in to opt-out:

  • ❌ Missing annotation → defaults to supported (shows ARN field)
  • undefined !== 'false'true (shows ARN field)
  • 'false' !== 'false'false (hides ARN field)

Solution

Restore opt-in behavior by changing condition from !== 'false' to === 'true':

const awsTokenAuthIsSupported =
  clusterIsAWSSTS && annotations[OLMAnnotation.TokenAuthAWS] === 'true';

Now operators must explicitly opt-in by setting the annotation to "true" to show credential fields.

Changes

  • Fixed token auth logic for both AWS and Azure annotations in operator-hub-utils.ts
  • Updated 4 existing tests to include explicit 'true' annotations
  • Added 2 new regression tests:
    • Verifies TokenAuth excluded when annotation is "false"
    • Verifies TokenAuth excluded when annotation is missing

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Fixed token authentication feature gating logic for AWS STS and Azure workload identity federation clusters to require explicit 'true' configuration values instead of accepting any non-false values.
  • Tests

    • Added test coverage validating token authentication feature behavior across different cluster configurations and annotation states.

Restore correct opt-in behavior for token-auth-aws/azure annotations.
Operators must explicitly set the annotation to "true" to show ARN/credential
fields in subscription form on STS/WIF clusters.

Regression introduced in a931fbd changed logic from opt-in (=== 'true')
to opt-out (!== 'false'), causing operators without annotation or with
annotation set to "false" to incorrectly show credential fields.

This fix ensures Cluster Observability Operator and similar operators
with token-auth-aws: "false" don't show ARN field, matching 4.20 behavior.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@openshift-ci openshift-ci bot requested review from rhamilto and spadgett February 5, 2026 16:33
@openshift-ci openshift-ci bot added the component/olm Related to OLM label Feb 5, 2026
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Feb 5, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: TheRealJon

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 5, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 5, 2026

📝 Walkthrough

Walkthrough

This change updates the TokenAuth feature gating logic in the operator-hub utilities to enforce stricter validation. The implementation shifts from accepting any value except 'false' to requiring the explicit string 'true' for the awsTokenAuthIsSupported and azureTokenAuthIsSupported conditions. Corresponding test coverage is expanded to validate behavior across multiple scenarios: when annotations are explicitly true, false, or absent for AWS STS and Azure WIF clusters. All existing test inputs are updated to include the new TokenAuth annotations.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and clearly summarizes the main change: switching token auth annotation logic from opt-out (!== 'false') to opt-in (=== 'true') behavior.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Comment @coderabbitai help to get the list of available commands and usage tips.

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Feb 5, 2026

@TheRealJon: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-gcp-console fb282fe link true /test e2e-gcp-console

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. component/olm Related to OLM

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant