feat: Gateway: CRW-8927 - Simplify login in to the OCP cluster from the Gateway plugin#247
feat: Gateway: CRW-8927 - Simplify login in to the OCP cluster from the Gateway plugin#247vrubezhny wants to merge 31 commits intoredhat-developer:mainfrom
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #247 +/- ##
==========================================
+ Coverage 0.00% 21.09% +21.09%
==========================================
Files 4 98 +94
Lines 26 4134 +4108
Branches 0 736 +736
==========================================
+ Hits 0 872 +872
- Misses 26 3152 +3126
- Partials 0 110 +110 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
198f7c1 to
0efefa4
Compare
0efefa4 to
54a861b
Compare
|
A few changes made to the Authentication and Select Cluster Wizard:
Here's a POC demo for Auth via Username/Password onto a local CRC cluster (+DevSpaces installed): Username-Password-Authentication-POC.mp4 |
|
@vrubezhny is this ready to be reviewed or should I wait for you to finish it? |
|
Quick question: does this also work the same the other way around, if i follow the flow from dev spaces dashboard will it also automatically login? |
Yes we're going to add this to the Connection Provider that uses Join Link from the Che Dashboard. UPD: @TheChosenMok, I might have misunderstood the question... Connecting to a DevWorkspace from the Che Dashboard is just opening the JB's IDEA IDE app by joinLink - it doesn't have any auth information, so users will still have to authenticate with their credentials - so this Connect to Cluster dialog will still be appearing. |
54a861b to
4fbe99a
Compare
4fbe99a to
bdcbc17
Compare
|
Random drive-by comment : Most users aren't typing out the token themselves. They probably have it copied. Would it be possible to read the clipboard/copy buffer, detect if it is in the form of a token, and then autofocus the "Token" tab ? Maybe even autofilling the values ? You can also consider doing this in a separate issue as a nice-to-have after this is merged to reduce the amount of time spent on the PR. |
bdcbc17 to
5361033
Compare
I thought about doing this and I believe it should be quite possible to read the Clipboard contents and paste it into the token field... But we don't actually have a certain source for getting the information how and where do we need to connect to before we choose a Dev Workspace (I mean which tab to switch to initially and why) - like yes, we may have a Kube config with its current context, but it might not even exist... For the Connection Provider is the same. I mean... User must select/type in a cluster first, After that we should check that we don't have, for instance, client certificate set for the cluster (which usually, when set, tends to be the primary way to authenticate),and only after that we can start thinking on whether we have a token saved to the Clipboard or not... It's not like " hey! we have a token saved to the CB - let's connect using it" - cluster selection should be made first. So, if we accept having Kube config's current context as the primary source for this information, we can try detecting if it points to a "token"-like connection and then try reading the Clipboard. Otherwise this would be a dumb guessing of what a user really wants to connect to. Adding the Clipboard's saved token value as the source for making decision on what connection tab to choose may help, but also could add nothing but mess if such a choice will have no clear logic. I'd created the separate issues for the possible further improvements including the Clipboard usage after this "starting" PR gets approved. (The PR has already ~60 changed files and it could become a really difficult to keep rebasing and improving it until it's merged) PS: As the first approximation we can make it working for the token tab (so user must select a cluster, then switch to the Token tab explicitly): Screencast.From.2026-03-05.23-43-37.mp4 |
|
all is tested properly? can it enter into main? |
Yes, we're aiming to merge it into main, but at the moment the PR is under review. |
|
Impressive! I am testing, reviewing it, will need quite some time though. |
|
Here's a usecase that doesn't work for me (or I dont use it properly). Steps:
Result: I also get to the frozen wizard when using the tab "OpenShift OAuth": Steps:
Result: |
adietish
left a comment
There was a problem hiding this comment.
Impressive work!
Had first go at testing it, will do code review in a few.
| * Represents the final result after exchanging code for tokens. | ||
| */ | ||
| enum class AuthTokenKind { | ||
| SSO, |
| private val clientId: String, | ||
| private val redirectUri: URI, | ||
| private val providerMetadata: OIDCProviderMetadata, | ||
| private val sslContext: SSLContext |
There was a problem hiding this comment.
sslContext is never used
adietish
left a comment
There was a problem hiding this comment.
Suggested changes. Will work on some.
| class CreateContextWithClientCert( | ||
| clusterName: String, | ||
| clusterUrl: String, | ||
| private val clientCertPem: String, | ||
| private val clientKeyPem: String, | ||
| allConfigs: List<KubeConfig> | ||
| ) : KubeConfigUpdate(clusterName, clusterUrl, "", allConfigs) { | ||
|
|
||
| override fun apply() { | ||
| val config = allConfigs.firstOrNull() ?: return | ||
|
|
||
| val user = createUser(allConfigs) | ||
| val users = config.users ?: ArrayList() | ||
| users.add(user.toMap()) | ||
|
|
||
| val cluster = createCluster(allConfigs) | ||
| val clusters = config.clusters ?: ArrayList() | ||
| clusters.add(cluster.toMap()) | ||
|
|
||
| val context = createContext(user, cluster, allConfigs) | ||
| val contexts = config.contexts ?: ArrayList() | ||
| contexts.add(context.toMap()) | ||
|
|
||
| config.setContext(context.name) | ||
|
|
||
| save( | ||
| contexts, | ||
| clusters, | ||
| users, | ||
| config.preferences, | ||
| config.currentContext, | ||
| config.path | ||
| ) | ||
| } |
There was a problem hiding this comment.
Is nearly identical to CreateContext. Maybe both could share code.
|
|
||
| CoroutineScope(Dispatchers.IO).launch { | ||
| try { | ||
| val params: Parameters? = callbackServer.awaitCallback(OPENSHIFT_LOGIN_TIMEOUT_MS) |
There was a problem hiding this comment.
cannot cancel browser login
| val expiresAt: Long? = null | ||
| ) { | ||
| fun isExpired(now: Long = System.currentTimeMillis()): Boolean = | ||
| expiresAt?.let { now >= it } ?: false |
There was a problem hiding this comment.
if token is expired things error. There's no automatic refresh. Guess we should file this to a new enhancement issue?
- OpenShiftAuthCodeFlow, RedHatAuthCodeFlow: migrated all HttpClient.send() calls to sendAsync().await() to avoid thread blocking. - SandboxApi: converted methods to suspend functions and implemented sendAsync().await(). - DefaultTlsTrustManager: refactored the TlsTrustManager interface and implementation to move network probes and I/O to Dispatchers.IO. - IdeaSecureTokenStorage, JBPasswordSafeTokenStorage: moved PasswordSafe I/O operations to Dispatchers.IO. - DevSpacesServerStepView: Moved blocking KubeConfigUtils calls out of the UI thread using withContext(Dispatchers.IO). - OidcProviderMetadataResolver: Wrapped Nimbus SDK blocking calls with withContext(Dispatchers.IO).
…sionManager, RedHatAuthSessionManager
Signed-off-by: Andre Dietisheim <adietish@redhat.com>
Signed-off-by: Andre Dietisheim <adietish@redhat.com>
Signed-off-by: Andre Dietisheim <adietish@redhat.com>
Signed-off-by: Victor Rubezhny <vrubezhny@redhat.com>
…saging Signed-off-by: Andre Dietisheim <adietish@redhat.com>
Signed-off-by: Andre Dietisheim <adietish@redhat.com>
Signed-off-by: Andre Dietisheim <adietish@redhat.com>
Signed-off-by: Andre Dietisheim <adietish@redhat.com>
Signed-off-by: Andre Dietisheim <adietish@redhat.com>
…ve config with cert Signed-off-by: Andre Dietisheim <adietish@redhat.com>
Signed-off-by: Andre Dietisheim <adietish@redhat.com>
Signed-off-by: Andre Dietisheim <adietish@redhat.com>
@azatsarynnyy: Can you please error logs and your config (in private) so that I can try to replicate? |
Add support for both file paths and base64 data in certificate fields. Kubeconfig can use either certificate-authority-data (base64) or certificate-authority (file path). Same for client-certificate and client-key. Changes: Data model: - Add CertificateSource to track value, format (path vs data), and modification state - Auto-detect input type (path vs base64/PEM) in fromUserInput() - Expand ~ to absolute paths when storing Kubeconfig support: - KubeConfigCluster: use CertificateSource for certificateAuthority - KubeConfigUser: use CertificateSource for clientCertificate/clientKey - Read both -data and path fields when loading - Write correct field type when saving (preserve original format) - Cluster data class updated with CertificateSource fields SSL context: - OpenShiftClientFactory: add resolveCertificateSource() to read files - createTrustManager/createKeyManagers accept CertificateSource - Read file content when isFilePath=true before parsing - Deprecated old CharArray-based methods for backward compatibility UI: - Add Browse buttons to Certificate Authority, Client Certificate, Client Key fields - Auto-detect whether user entered path or data - Display certificate values from loaded configs (both formats) - Remove "(PEM)" from field labels (now format-agnostic) This allows connecting to clusters like minikube that use file paths in kubeconfig instead of embedded base64 data. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> Signed-off-by: Andre Dietisheim <adietish@redhat.com>
Signed-off-by: Andre Dietisheim <adietish@redhat.com>






fixes https://redhat.atlassian.net/browse/CRW-10338
This POC PR adds a possibility to authorize on...
POC Demo:
Openshift-Authentication-POC.mp4