Skip to content

Redesign the OAUTH callback page #13127

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

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from

Conversation

MrFlashAccount
Copy link
Contributor

@MrFlashAccount MrFlashAccount commented May 20, 2025

Pull Request Description

Closes: https://github.com/enso-org/cloud-v2/issues/1874

This PR is based on the https://github.com/enso-org/cloud-v2/pull/1969 and shall be merged (and tested) in sync

Important Notes

Checklist

Please ensure that the following checklist has been satisfied before submitting the PR:

  • The documentation has been updated, if necessary.
  • Screenshots/screencasts have been attached, if there are any visual changes. For interactive or animated visual changes, a screencast is preferred.
  • All code follows the
    Scala,
    Java,
    TypeScript,
    and
    Rust
    style guides. In case you are using a language not listed above, follow the Rust style guide.
  • Unit tests have been written where possible.
  • If meaningful changes were made to logic or tests affecting Enso Cloud integration in the libraries,
    or the Snowflake database integration, a run of the Extra Tests has been scheduled.
    • If applicable, it is suggested to paste a link to a successful run of the Extra Tests.

import * as detect from 'enso-common/src/detect'
import './config'
Copy link
Contributor

Choose a reason for hiding this comment

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

I think config is run in script HTML tag, so should not be needed anywhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree, I initially added it because for some reason I had $config is not defined error. But it seems like it's gone

Copy link
Contributor Author

@MrFlashAccount MrFlashAccount May 20, 2025

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

So I always assumed that the separate <script> tag is needed for bazel. Calling @Frizi in to confirm.

As an alternative (if indeed needed), we could just add import as first in the test file.

Copy link
Contributor

Choose a reason for hiding this comment

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

subscribing to this thread because i also need a hacky workaround for this in one of my PRs:

https://github.com/enso-org/enso/pull/13130/files?w=1#diff-11c61cfd4d9ee97e82ff2eeb497f4d02f56c6e93211d104610f6f528ad681ba0R55-R60

const setFeatureFlag = useSetFeatureFlag()
useMount(() => {
if (typeof window !== 'undefined' && window.overrideFeatureFlags === undefined) {
setFeatureFlag('enableLocalBackend', $config.CLOUD_BUILD !== 'true')
}
})

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So I always assumed that the separate <script> tag is needed for bazel. Calling @Frizi in to confirm.

It's correct, I'm voting for including the config in setups for tests/storybook. @farmaazon @Frizi @somebody1234 WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

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

The split of config into a separate script is intentional for future work, though right now it is NOT being used in the build process. The intention is to eventually do a post-build config value replacing to guarantee that testing and production builds are exact same, and config is literally the only difference between them. We have a script that does it (envReplacer.mjs), but it is currently disabled to keep our build process simple while we still have legacy rust pipeline going. I would however like to keep the config script a separate chunk. All typing issues should be fixed purely on typescript level, since the variable is supposed to be treated as a global $config exposed on window before any other application code runs.

Copy link
Contributor

Choose a reason for hiding this comment

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

So as I understand, there is no problem in importing them for tests and storybooks, as those won't have any config replaced as a build step.

@@ -13,7 +13,7 @@ import * as lazyMemo from '#/hooks/useLazyMemoHooks'
import * as safeJsonParse from '#/utilities/safeJsonParse'
import { useRouterInReact } from '$/providers/react'
import { type RouteLocationOptions } from 'vue-router'
import { ZodSchema, type z } from 'zod'
import { type z } from 'zod'
Copy link
Contributor

Choose a reason for hiding this comment

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

import { type } -> import type {}? same with the import from vue-router above

@@ -78,6 +80,16 @@ export function DriveBarToolbar(props: DriveBarToolbarProps) {
const { isOffline } = useOffline()
const canDownload = useCanDownload()

const [credentialsModalOpen, setCredentialsModalOpen] = useSearchParamsState(
'credentialsModal_open',
Copy link
Contributor

Choose a reason for hiding this comment

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

stylistic nit: maybe consider credentialsModal.open as key if that is valid

Copy link
Contributor

@somebody1234 somebody1234 left a comment

Choose a reason for hiding this comment

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

CR ✅

@MrFlashAccount MrFlashAccount added CI: Keep up to date Automatically update this PR to the latest develop. CI: No changelog needed Do not require a changelog entry for this PR. g-dashboard labels May 21, 2025
@MrFlashAccount MrFlashAccount force-pushed the wip/sergeigarin/improve-credentials-page branch 2 times, most recently from b685ff2 to 0741de7 Compare May 23, 2025 10:39
Copy link

github-actions bot commented May 23, 2025

✨ GUI Checks Results

Summary

  • 🧹 Prettier: ✅ Passed
  • 🧰 GUI Checks: ❌ Failed
  • 📚 Storybook: ✅ Deployed

⚠️ Action Required: Please review the failed checks and fix them before merging.

See individual check results for more details.

ℹ️ Chromatic Tests Skipped

Chromatic visual regression tests were skipped for this PR.

To run the tests and deploy Storybook, add the CI: Run Chromatic label to this PR.

Note: We skip tests by default to optimize CI costs. Only run them when your UI changes are ready for review.

🎭 Playwright Test Results

Summary

  • ⏳ Duration: 0m 34s
  • ✅ Passed: 0 tests
  • 🔴 Failed: 0 tests
  • ⚠️ Flaky: 0 tests

📥 Download Detailed Report

All tests passed! Your changes look good.

👮 Lint GUI Results

Check Results

  • 🧠 Typecheck: ❌ Failed
  • 🧹 Lint: ❌ Failed
  • 🧪 Unit Tests: ✅ Passed

ESLint

15 Error(s):

app/gui/src/dashboard/data/serviceCredentials/utilities.ts line 14

  • Start Line: 14
  • End Line: 14
  • Message: Unexpected any value in conditional. An explicit comparison or type conversion is required.
  • From: [@typescript-eslint/strict-boolean-expressions]

app/gui/src/dashboard/data/serviceCredentials/utilities.ts line 14

  • Start Line: 14
  • End Line: 14
  • Message: Unsafe call of a(n) error type typed value.
  • From: [@typescript-eslint/no-unsafe-call]

app/gui/src/dashboard/data/serviceCredentials/utilities.ts line 14

  • Start Line: 14
  • End Line: 14
  • Message: Unsafe member access .endsWith on an error typed value.
  • From: [@typescript-eslint/no-unsafe-member-access]

app/gui/src/dashboard/pages/OAuthCallback.tsx line 32

  • Start Line: 32
  • End Line: 32
  • Message: Unsafe assignment of an error typed value.
  • From: [@typescript-eslint/no-unsafe-assignment]

app/gui/src/dashboard/pages/OAuthCallback.tsx line 32

  • Start Line: 32
  • End Line: 32
  • Message: Unsafe call of a(n) error type typed value.
  • From: [@typescript-eslint/no-unsafe-call]

app/gui/src/dashboard/pages/OAuthCallback.tsx line 43

  • Start Line: 43
  • End Line: 43
  • Message: Unsafe assignment of an error typed value.
  • From: [@typescript-eslint/no-unsafe-assignment]

app/gui/src/dashboard/pages/OAuthCallback.tsx line 43

  • Start Line: 43
  • End Line: 43
  • Message: Unsafe call of a(n) error type typed value.
  • From: [@typescript-eslint/no-unsafe-call]

app/gui/src/dashboard/pages/OAuthCallback.tsx line 43

  • Start Line: 43
  • End Line: 43
  • Message: Unsafe member access .get on an error typed value.
  • From: [@typescript-eslint/no-unsafe-member-access]

app/gui/src/dashboard/pages/OAuthCallback.tsx line 44

  • Start Line: 44
  • End Line: 44
  • Message: Unsafe assignment of an error typed value.
  • From: [@typescript-eslint/no-unsafe-assignment]

app/gui/src/dashboard/pages/OAuthCallback.tsx line 44

  • Start Line: 44
  • End Line: 44
  • Message: Unsafe call of a(n) error type typed value.
  • From: [@typescript-eslint/no-unsafe-call]

app/gui/src/dashboard/pages/OAuthCallback.tsx line 44

  • Start Line: 44
  • End Line: 44
  • Message: Unsafe member access .get on an error typed value.
  • From: [@typescript-eslint/no-unsafe-member-access]

app/gui/src/dashboard/pages/OAuthCallback.tsx line 45

  • Start Line: 45
  • End Line: 45
  • Message: Unsafe assignment of an error typed value.
  • From: [@typescript-eslint/no-unsafe-assignment]

app/gui/src/dashboard/pages/OAuthCallback.tsx line 45

  • Start Line: 45
  • End Line: 45
  • Message: Unsafe call of a(n) error type typed value.
  • From: [@typescript-eslint/no-unsafe-call]

app/gui/src/dashboard/pages/OAuthCallback.tsx line 45

  • Start Line: 45
  • End Line: 45
  • Message: Unsafe member access .get on an error typed value.
  • From: [@typescript-eslint/no-unsafe-member-access]

app/gui/src/dashboard/pages/OAuthCallback.tsx line 87

  • Start Line: 87

  • End Line: 87

  • Message: Unsafe assignment of an error typed value.

  • From: [@typescript-eslint/no-unsafe-assignment]

@MrFlashAccount MrFlashAccount force-pushed the wip/sergeigarin/improve-credentials-page branch from 4d9eb82 to c324a02 Compare May 26, 2025 08:13
@MrFlashAccount MrFlashAccount removed the CI: Keep up to date Automatically update this PR to the latest develop. label May 26, 2025
@PabloBuchu
Copy link
Contributor

  1. Are we able to add button "retry authentication"?
Screenshot 2025-05-26 at 14 04 32

@MrFlashAccount MrFlashAccount force-pushed the wip/sergeigarin/improve-credentials-page branch from f82d93a to c099e39 Compare May 29, 2025 09:12
@somebody1234
Copy link
Contributor

somebody1234 commented Jun 4, 2025

@PabloBuchu re: retry authentication, i guess we should leave it for another PR

@radeusgd would probably be the most appropriate to answer which steps it would involve specifically (i can handle implementation, just not familiar enough with the credential stuff to know how difficult it will be to allow for that)

@radeusgd
Copy link
Member

radeusgd commented Jun 6, 2025

@PabloBuchu re: retry authentication, i guess we should leave it for another PR

@radeusgd would probably be the most appropriate to answer which steps it would involve specifically (i can handle implementation, just not familiar enough with the credential stuff to know how difficult it will be to allow for that)

Even for successful authentication we wanted to have a refresh button to refresh expired credentials, so yeah that would be useful. I think it depends on how we want to do this. If we are fine with reading the secret data on client side (which feels a bit unsafe but tbh nothing stopping us from calling the s3cr3tz endpoint, the same is done in Libraries just a bit hidden in Java), then we can read the information that was stored from the filled-in form and re-run the logic for generating a (fresh) link for the redirect - then we can use the same logic that is used when creating a new token. For failed auth nothing more should be needed as the backend will handle the rest. For refreshing a successful token we also need to mark it as being refreshed - otherwise the backend would reject a new request (let's call it replay attack protection).

If we are not okay with reading the metadata stored in secret payload for refreshing the credential in the client, we'd probably need to move the logic for generating the URL onto the backend and modify both the create and refresh/retry endpoints to relate on that.

Please let me know if this clarifies or some further clarifications are needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI: No changelog needed Do not require a changelog entry for this PR. g-dashboard
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants