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

[projects] try to authorize if necessary #5640

Merged
merged 1 commit into from
Sep 30, 2021
Merged

[projects] try to authorize if necessary #5640

merged 1 commit into from
Sep 30, 2021

Conversation

AlexTugarev
Copy link
Member

@AlexTugarev AlexTugarev commented Sep 10, 2021

This is an alternative solution to the PR #5484 where we simply use project owner's token on the backend to serve the project details. Here we will ask the current user to authorize with a provider on demand, otherwise it wont load the details.

Related Issue(s)

Fixes #5461

How to test

  1. set up a team with 2 members (user A connected with GitLab, and user B connected with GitHub)
  2. (user A) create a project, see the project details (Branches) are loaded
  3. (user B) try to load project details for the same project, see a modal that enables you to authorize a missing connection

Screen Shot 2021-09-10 at 15 15 59

Release Notes

[Teams & Projects] Ask for authorization when viewing a project of a provider without connection

@JanKoehnlein
Copy link
Contributor

@AlexTugarev please add a release note or NONE in the release-note block in the description of the PR to get rid of the do-not-merge/release-note-label-needed label. See https://www.notion.so/gitpod/Release-Notes-513a74fdd23b4cb1b3b3aefb1d34a3e0

@AlexTugarev AlexTugarev force-pushed the at/project-auth branch 5 times, most recently from 8333a76 to c83d0e6 Compare September 10, 2021 13:18
@AlexTugarev AlexTugarev marked this pull request as ready for review September 10, 2021 13:25
@AlexTugarev AlexTugarev requested review from gtsiolis and svenefftinge and removed request for JanKoehnlein September 10, 2021 13:35
Copy link
Contributor

@gtsiolis gtsiolis left a comment

Choose a reason for hiding this comment

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

Thanks for giving this a go @AlexTugarev! 🗳️

@@ -121,6 +171,20 @@ export default function () {

return <>
<Header title="Branches" subtitle={<h2 className="tracking-wide">View recent active branches for <a className="text-gray-500 hover:text-gray-800 font-semibold" href={project?.cloneUrl}>{project?.name}</a>.</h2>} />

{showAuthModal && (
Copy link
Contributor

Choose a reason for hiding this comment

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

issue: Do we also need to use the same auth flow when opening the configuration page as the user is stuck in detecting project configuration phase?

Copy link
Member Author

Choose a reason for hiding this comment

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

the plan is to replicate it on the config page once it's working nicely here.

@@ -121,6 +171,20 @@ export default function () {

return <>
<Header title="Branches" subtitle={<h2 className="tracking-wide">View recent active branches for <a className="text-gray-500 hover:text-gray-800 font-semibold" href={project?.cloneUrl}>{project?.name}</a>.</h2>} />

{showAuthModal && (
Copy link
Contributor

Choose a reason for hiding this comment

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

question: I have access to the Prebuilds page without authorizing with the provider which also includes commit information. Expected?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because this is all persisted on backend, yes.
Is there a problem with that?

Copy link
Contributor

Choose a reason for hiding this comment

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

Does not look like a problem! ✔️

components/dashboard/src/projects/Project.tsx Outdated Show resolved Hide resolved
@jankeromnes
Copy link
Contributor

jankeromnes commented Sep 24, 2021

/werft run

👍 started the job as gitpod-build-at-project-auth.12

@jankeromnes
Copy link
Contributor

jankeromnes commented Sep 24, 2021

Many thanks! Taking a look now 👀

Copy link
Contributor

@jankeromnes jankeromnes left a comment

Choose a reason for hiding this comment

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

Many thanks @AlexTugarev!

Code looks good to me so far (please see in-line comments), but I couldn't test the PR, as I couldn't get it deployed properly (see Slack)

Could you please rebase this Pull Request and re-deploy it with a GitHub App integration? 😬 🙏

@AlexTugarev
Copy link
Member Author

AlexTugarev commented Sep 24, 2021

Could you please rebase this Pull Request and re-deploy it with a GitHub App integration? 😬 🙏

@jankeromnes, this isn't necessary. please try with a second account created with GitHub and visiting a project created with a first account (GitLab.) there are not specifics to GitHub which would require to set up the GH App in here. (just updated the description ☝🏻 )

@AlexTugarev
Copy link
Member Author

AlexTugarev commented Sep 24, 2021

/werft run

👍 started the job as gitpod-build-at-project-auth.21

🤞🏻

@gtsiolis
Copy link
Contributor

gtsiolis commented Sep 29, 2021

For the Configurator, I couldn't find a spec. @gtsiolis does the current state look okay? 🙂

Thanks for noticing, @jankeromnes! There wasn't a spec for the configurator specifically but the current state looks good.

🍊 🍊 🍊 🍊

thought: I think using non-modal approach makes the flow less distruptive and more aligned with the rest of the product.

For example, we don't use a modal to ask for authorization when needed (e.g. workspace loading screen) and using a modal could require us to render empty pages behind the modal (e.g empty branches list) which could look strange in terms of UX.

Also, the already existing non-modal auth flow when adding a project, which is using the same pattern with the gray background to ask for user input or authorization, helps build a muscle memory across the product. 💭

New project auth Access branches auth
Screenshot 2021-09-29 at 3 14 24 PM (2) Screenshot 2021-09-29 at 3 14 19 PM (2)

I'd love to hear any feedback on this. Cc @AlexTugarev @jankeromnes

@jankeromnes
Copy link
Contributor

jankeromnes commented Sep 29, 2021

(Please also feel free to tick the completed checkboxes here and here, and to re-request a review when relevant 😊 happy to help!)

@AlexTugarev
Copy link
Member Author

@gtsiolis and @jankeromnes, what's left here to proceed?

@AlexTugarev
Copy link
Member Author

AlexTugarev commented Sep 30, 2021

/werft run

👍 started the job as gitpod-build-at-project-auth.34

@jankeromnes
Copy link
Contributor

jankeromnes commented Sep 30, 2021

@gtsiolis and @jankeromnes, what's left here to proceed?

From my side, nothing left! 🎉 Thanks a lot for following up. 🙏

I'm happy to take another look in about an hour and approve.

Copy link
Contributor

@jankeromnes jankeromnes left a comment

Choose a reason for hiding this comment

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

Perfection ✨ ☺️

Code looks good to me (especially with ?w=1) and works as advertised! 🎉

Screenshot 2021-09-30 at 14 40 47 Screenshot 2021-09-30 at 14 40 58

One small error, but seems unrelated to this PR (i.e. maybe a follow-up?) -- When creating a new project as a new Member (i.e. not an Owner), I see an alert about not being authorized to create the project, however the project is created anyway? 😳 That's confusing. And when being upgraded from Member to Owner, the error on creation no longer shows up.

Screenshot 2021-09-30 at 14 37 50 Screenshot 2021-09-30 at 14 38 35

To reproduce:

  1. set up a team with 2 members (user A connected with GitHub, invites as "Member" user B connected with GitLab)
  2. (user B) try create a project from a GitLab repository, see error alert
  3. (user B) going to the Projects list, see that the project was actually created anyway

@roboquat
Copy link
Contributor

LGTM label has been added.

Git tree hash: fcb8d1b6cdb18568cdad35f854f8ab6484525834

@gtsiolis
Copy link
Contributor

gtsiolis commented Sep 30, 2021

One small error, ...

Great catch, @jankeromnes! I was able to reproduce this on staging and production. Upvoting for a follow-up issue. ⚾

@AlexTugarev
Copy link
Member Author

/approve no-issue

@roboquat
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: AlexTugarev, jankeromnes

Associated issue: #5461

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

The pull request process is described 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

@roboquat roboquat merged commit b0e5bf6 into main Sep 30, 2021
@roboquat roboquat deleted the at/project-auth branch September 30, 2021 13:53
AlexTugarev added a commit that referenced this pull request Oct 1, 2021
roboquat pushed a commit that referenced this pull request Oct 1, 2021
@gtsiolis gtsiolis added feature: teams and projects [DEPRECATED] Please, use feature: organizations or feature: projects labels instead. component: dashboard team: webapp Issue belongs to the WebApp team labels Oct 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved component: dashboard feature: teams and projects [DEPRECATED] Please, use feature: organizations or feature: projects labels instead. release-note size/XXL team: webapp Issue belongs to the WebApp team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[configurator] Endless spinning when user has no access
5 participants