-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
fix(scaffolder): remove waiting until all fields are filled in before requesting user credentials #24881
fix(scaffolder): remove waiting until all fields are filled in before requesting user credentials #24881
Conversation
… requesting user credentials Signed-off-by: Benjamin Janssens <benji.janssens@gmail.com>
Changed Packages
|
I'm not sure that we can do this, because when we request user credentials, they have the Not sure if this could potentially break something, maybe not for GitHub but for other providers there could be a chance. What providers have you tested this with? |
I want to call out also, this is another reason why I want to look at doing something like this: #16996 |
@benjdlambert ah, I see what you mean. I'm currently testing this with Bitbucket, where I didn't encounter any issues with it, but I can see the danger of it. Maybe it's a better idea to make sure the dialog only pops up after the user leaves the last field for now? Or, maybe even better, add a button or when the button to the next step is pressed (if possible)? |
Hey @benjidotsh! It could be tricky to have a control of popup from the button, as the invocation of it resides in the picker. |
Hey @acierto, yeah, I know, but I think we could add a prop to the picker component that acts as a handler for controlling the dialog. But maybe using an on blur event is enough - then we don't have to escape the picker component. |
Thanks for the contribution! |
@benjdlambert @acierto I dug a little deeper and, unless I'm missing something, I noticed that we only use the host part of the URL anyways. I changed the code to only pass and check for the host for authentication, which inherently fixes the goal of this PR. |
Signed-off-by: Benjamin Janssens <benji.janssens@gmail.com>
Signed-off-by: Benjamin Janssens <benji.janssens@gmail.com>
abfec75
to
bad9449
Compare
Signed-off-by: Benjamin Janssens <benji.janssens@gmail.com>
Signed-off-by: Benjamin Janssens <benji.janssens@gmail.com>
Signed-off-by: Benjamin Janssens <benji.janssens@gmail.com>
Signed-off-by: Benjamin Janssens <benji.janssens@gmail.com>
c19bafb
to
a05727d
Compare
Signed-off-by: Benjamin Janssens <benji.janssens@gmail.com>
Signed-off-by: Benjamin Janssens <benji.janssens@gmail.com>
Signed-off-by: Benjamin Janssens <benji.janssens@gmail.com>
I think the test |
Signed-off-by: Benjamin Janssens <benji.janssens@gmail.com>
@benjdlambert can you maybe take a look at this PR again? 😇 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey 👋 thanks for this!
Just wanna get some additional feedback here, thinking that we might want to solve this a different way.
I'm thinking that the secret for the actual job could be handled with something like #16996 and that a token for your other PR #25132 could be generated without waiting for all fields to be filled out of course.
@@ -93,7 +93,7 @@ export interface ScmAuthTokenOptions extends AuthRequestOptions { | |||
gitlab?: string[]; | |||
}; | |||
}; | |||
url: string; | |||
host: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, i'm not sure that we can make this change as it is now as it's a breaking change.
I wonder if we could perhaps support a union of either { url: string } | { host: string }
instead.
The idea I guess is that there could be different credentials issued for different URLs, not just for VCS providers, but imagine a URL where you have a different token depending on path.
@Rugvip whats your thoughts here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. I don't think it's absolutely necessary to even use host
- I just refactored this because it looked like we only used the host part anyways. Even though I updated the usage of it everywhere in the code, I can imagine that an API change is not ideal for other plugins.
The idea I guess is that there could be different credentials issued for different URLs, not just for VCS providers, but imagine a URL where you have a different token depending on path.
I'm not sure what you mean with this part though. You're talking about potential use cases of ScmAuthTokenOptions
that require URLs instead of hosts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No sorry , I'm talking about the getCredentials
method. So lets say for GitHub for instance you have two different GitHub Apps configured in config. One of them is installed in the organization blob
whilst the other is installed in the organization boop
.
If I'm just requesting a token for github.com
then the getCredentials
method has no idea which app to select as it doesn't have context in the URL as to which org we're trying to reach right? I think thats the motivation behind keeping the URL as you can do url: 'https://github.com/blob/my-repo'
to get a token for my-repo
with the org blob
.
That's why I think we can't remove it all at least.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I understand, but how it is implemented right now it completely ignores everything but the host anyways, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah wait sorry, you're right, I'm getting confused here between frontend and backend. It's the GithubCredentialsProvider
that does that work, and that's backend only.
Ok, maybe there's room for us to do this, but yeah, unsure about the breaking change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I can implement this without changing the API. I'll look into it!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, should be done!
It doesn't differ too much from the original code and simplifies the PR a lot since the only thing we do is not pass the workspace and repository that go unused anyways.
@benjdlambert I agree #16996 would be the ideal solution, but I think that might be a huge undertaking. In the meantime it could be a good idea to just "fix" the existing implementation by making |
Signed-off-by: Benjamin Janssens <benji.janssens@gmail.com>
Signed-off-by: Benjamin Janssens <benji.janssens@gmail.com>
Signed-off-by: Benjamin Janssens <benji.janssens@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, thanks for the work here! Let's go with this! 🙏
Thank you for contributing to Backstage! The changes in this pull request will be part of the |
Hey, I just made a Pull Request!
When using
RepoUrlPicker
with itsrequestUserCredentials
option, the dialog only appears after all fields have a value. This results in the dialog appearing while typing in the last value, which can lead to a frustrating experience.This pull request removes this check, which shows the dialog as soon as the
RepoUrlPicker
is displayed.✔️ Checklist
Signed-off-by
line in the message. (more info)