-
Notifications
You must be signed in to change notification settings - Fork 70
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
chore: Add an ability to manually configure bitbucket oAuth token #313
Conversation
Signed-off-by: Igor Vinokur <ivinokur@redhat.com>
...factory/src/main/java/org/eclipse/che/api/factory/server/scm/PersonalAccessTokenManager.java
Outdated
Show resolved
Hide resolved
@@ -49,7 +49,6 @@ public String computeAuthorizationHeader(String userId, String requestMethod, St | |||
|
|||
@Override | |||
public String getLocalAuthenticateUrl() { | |||
throw new RuntimeException( | |||
"The fallback noop authenticator cannot be used for authentication. Make sure OAuth is properly configured."); | |||
return "Empty URL"; |
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.
Why not to keep throwing RuntimeException ?
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.
To avoid the exception when the NoopOAuthAuthenticator
is used to create an API client with an empty authenticator:
Line 114 in 17c82bb
personalAccessToken.getScmProviderUrl(), new NoopOAuthAuthenticator()); |
.../org/eclipse/che/api/factory/server/bitbucket/BitbucketServerPersonalAccessTokenFetcher.java
Outdated
Show resolved
Hide resolved
.../org/eclipse/che/api/factory/server/scm/kubernetes/KubernetesPersonalAccessTokenManager.java
Outdated
Show resolved
Hide resolved
.../org/eclipse/che/api/factory/server/bitbucket/BitbucketServerPersonalAccessTokenFetcher.java
Outdated
Show resolved
Hide resolved
...-gitlab/src/main/java/org/eclipse/che/api/factory/server/gitlab/GitlabOAuthTokenFetcher.java
Outdated
Show resolved
Hide resolved
@@ -57,9 +67,49 @@ public GitlabUrlParser( | |||
} | |||
} | |||
|
|||
private boolean userTokenExists(String url) { |
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.
Duplicates?
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.
Unfortunately I can't easyaly combine this functions into one common, as they are located in separate maven modules.
...-factory-gitlab/src/main/java/org/eclipse/che/api/factory/server/gitlab/GitlabUrlParser.java
Outdated
Show resolved
Hide resolved
...et-server/src/main/java/org/eclipse/che/api/factory/server/bitbucket/BitbucketURLParser.java
Outdated
Show resolved
Hide resolved
...et-server/src/main/java/org/eclipse/che/api/factory/server/bitbucket/BitbucketURLParser.java
Outdated
Show resolved
Hide resolved
...et-server/src/main/java/org/eclipse/che/api/factory/server/bitbucket/BitbucketURLParser.java
Outdated
Show resolved
Hide resolved
…rg/eclipse/che/api/factory/server/bitbucket/BitbucketURLParser.java Co-authored-by: Anatolii Bazko <abazko@redhat.com>
…rg/eclipse/che/api/factory/server/bitbucket/BitbucketURLParser.java Co-authored-by: Anatolii Bazko <abazko@redhat.com>
...api-auth-bitbucket/src/main/java/org/eclipse/che/security/oauth1/NoopOAuthAuthenticator.java
Outdated
Show resolved
Hide resolved
@@ -49,7 +49,6 @@ public String computeAuthorizationHeader(String userId, String requestMethod, St | |||
|
|||
@Override | |||
public String getLocalAuthenticateUrl() { | |||
throw new RuntimeException( | |||
"The fallback noop authenticator cannot be used for authentication. Make sure OAuth is properly configured."); | |||
return "Noop URL"; |
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.
should be const. In general, why do we need a dummy implementation in the case if no Bitbucket Server
integration is configured? Could you please add more details in the Javadocs for this class?
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.
should be const.
This string is used only once, not sure we need a separate const for that.
In general, why do we need a dummy implementation in the case if no Bitbucket Server
integration is configured? Could you please add more details in the Javadocs for this class?
It is needed to initialise an empty BitbucketServerApiClient
which returns false
on isConnected()
reqests. This is needed to check if bitbucket oAuth is configured or not. Updated the javadoc.
LOG.debug("not a valid url {} for current fetcher ", personalAccessToken.getScmProviderUrl()); | ||
return Optional.empty(); | ||
// If BitBucket oAuth is not configured check the manually added user namespace token. | ||
HttpBitbucketServerApiClient apiClient = |
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'm a bit lost in the flow, why are we trying to check the token if BitBucket server is not configured?
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.
The main idea of the PR is to be able to use manually added user namespace secrets with tokeen for the oAuth flow in case when oAuth is not configured by the admin.
@@ -57,9 +68,55 @@ public GitlabUrlParser( | |||
} | |||
} | |||
|
|||
private boolean isUserTokenExists(String repositoryUrl) { |
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.
grammatically it should be isUserTokenExist
also, since there is isPresent
call, consider changing the name to isUserTokenPresent
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.
done
Signed-off-by: Igor Vinokur ivinokur@redhat.com
What does this PR do?
Read user namespace oauth token before checking the oAuth configuration in case when user manually added a bitbucket oAuth secret to the user namespace.
Screenshot/screencast of this PR
What issues does this PR fix or reference?
eclipse-che/che#21189
How to test this PR?
quay.io/ivinokur/che-server:next
image.PR Checklist
As the author of this Pull Request I made sure that:
What issues does this PR fix or reference
andHow to test this PR
completedReviewers
Reviewers, please comment how you tested the PR when approving it.