Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OCM-4969 | feat: Add deprecation warning for login using offline token and disable oauth tokens for FedRAMP #1821

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

tirthct
Copy link
Contributor

@tirthct tirthct commented Mar 4, 2024

Changed

  • Add deprecation warning for login using offline token
  • Disable oauth tokens for FedRAMP

Tested

  • Warning message should be displayed in case of offline tokens : tested

@openshift-ci openshift-ci bot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Mar 4, 2024
Copy link
Contributor

openshift-ci bot commented Mar 4, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: tirthct
Once this PR has been reviewed and has the lgtm label, please assign gdbranco for approval. For more information see the Kubernetes Code Review Process.

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

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

Copy link
Contributor

openshift-ci bot commented Mar 4, 2024

Hi @tirthct. Thanks for your PR.

I'm waiting for a openshift member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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/test-infra repository.

cmd/login/cmd.go Outdated
cfg = new(config.Config)
}

if (cfg.FedRAMP || fedramp.HasFlag(cmd) || fedramp.IsGovRegion(arguments.GetRegion())) && (args.useAuthCode || args.useDeviceCode) {
Copy link
Member

Choose a reason for hiding this comment

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

We want to avoid using the stored configuration for this check. It will prevent someone from switching between govcloud and commercial environments if "fedramp": "true" is stored in their configuration.

Copy link
Contributor

Choose a reason for hiding this comment

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

@tirthct @tylercreller Can we combine this statement into a function and write a unit test for it e.g something like fedramp.IsLoginMethodSupported()

cheers,

Rob

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@robpblake turns out we don't need the extra conditions except for fedramp.HasFlag() check. So just kept that instead of creating a whole new method.
Fixed the condition

cmd/login/cmd.go Outdated
@@ -325,6 +335,10 @@ func run(cmd *cobra.Command, argv []string) {
clientID = args.clientID
}
}
} else {
if !args.useDeviceCode && !args.useDeviceCode {
Copy link
Member

Choose a reason for hiding this comment

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

We should specifically target displaying this message only if the offline token is provided. In this case we would display the warning message for client credentials, which we don't want.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ack. Added offline token condition.

cmd/login/cmd.go Outdated
r.Reporter.Errorf("Failed to load config file: %v", err)
os.Exit(1)
}
if cfg == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

@tirthct You don't need this check as the config.Load() method will always return an empty Config if one doesn't exist.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think that check would be working properly. I removed it and it stopped me from logging in:
image

Not looking into that in this PR this change is already in the master branch for long, but def something to look into.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

PS. ignore the double warnings. For some reason my machine sometimes does that.
@tylercreller has verified and confirmed the message is only shown once

cmd/login/cmd.go Outdated
cfg = new(config.Config)
}

if (cfg.FedRAMP || fedramp.HasFlag(cmd) || fedramp.IsGovRegion(arguments.GetRegion())) && (args.useAuthCode || args.useDeviceCode) {
Copy link
Contributor

Choose a reason for hiding this comment

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

@tirthct @tylercreller Can we combine this statement into a function and write a unit test for it e.g something like fedramp.IsLoginMethodSupported()

cheers,

Rob

@robpblake
Copy link
Contributor

/ok-to-test

@openshift-ci openshift-ci bot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Mar 5, 2024
@tirthct
Copy link
Contributor Author

tirthct commented Mar 5, 2024

#1821 (comment)

We removed that combined condition, so a separate function is no longer needed

Copy link

codecov bot commented Mar 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 21.12%. Comparing base (40561a0) to head (0d5e3e7).
Report is 351 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1821      +/-   ##
==========================================
+ Coverage   20.81%   21.12%   +0.30%     
==========================================
  Files          87       89       +2     
  Lines       15108    15177      +69     
==========================================
+ Hits         3145     3206      +61     
- Misses      11722    11730       +8     
  Partials      241      241              

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

@tylercreller
Copy link
Member

Hold this PR until we get the green-light from PM

@tirthct tirthct marked this pull request as draft March 11, 2024 17:45
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 11, 2024
@tirthct
Copy link
Contributor Author

tirthct commented Mar 11, 2024

Hold this PR until we get the green-light from PM

@tylercreller : Converted to draft

@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 13, 2024
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 21, 2024
@robpblake
Copy link
Contributor

@tirthct What's the status of this PR please?

cheers,
Rob

@tirthct
Copy link
Contributor Author

tirthct commented Apr 10, 2024

@tylercreller should we merge this?

@tylercreller
Copy link
Member

@tirthct @robpblake We are still waiting for the appropriate time to merge this. There are internal processes that need to happen before we can ship this.

Copy link
Contributor

openshift-ci bot commented May 11, 2024

@tirthct: all tests passed!

Full PR test history. Your PR dashboard.

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
do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. ok-to-test Indicates a non-member PR verified by an org member that is safe to test.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants