Skip to content

Commit

Permalink
fixup! chore: Apply Bitbucket SAAS Oauth flow
Browse files Browse the repository at this point in the history
  • Loading branch information
vinokurig committed Jul 26, 2022
1 parent 942e979 commit 07c1d1c
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -238,13 +238,13 @@ che.oauth2.bitbucket.clientid_filepath=NULL
# Location of the file with Bitbucket client secret.
che.oauth2.bitbucket.clientsecret_filepath=NULL

# BitBucket OAuth authorization URI.
# Bitbucket OAuth authorization URI.
che.oauth.bitbucket.authuri= https://bitbucket.org/site/oauth2/authorize

# BitBucket OAuth token URI.
# Bitbucket OAuth token URI.
che.oauth.bitbucket.tokenuri= https://bitbucket.org/site/oauth2/access_token

# BitBucket OAuth redirect URIs.
# Bitbucket OAuth redirect URIs.
# Separate multiple values with comma, for example: URI,URI,URI
che.oauth.bitbucket.redirecturis= http://localhost:${CHE_PORT}/api/oauth/callback

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ public BitbucketOAuthAuthenticator(
clientId, clientSecret, redirectUris, authUri, tokenUri, new MemoryDataStoreFactory());
}

private static final String USER_URL = "https://api.bitbucket.org/2.0/user";

@Override
public User getUser(OAuthToken accessToken) throws OAuthAuthenticationException {
BitbucketUser user =
getJson("https://api.bitbucket.org/2.0/user", accessToken.getToken(), BitbucketUser.class);
BitbucketUser user = getJson(USER_URL, accessToken.getToken(), BitbucketUser.class);
return user;
}

Expand All @@ -52,8 +53,7 @@ public OAuthToken getToken(String userId) throws IOException {
if (token == null
|| token.getToken() == null
|| token.getToken().isEmpty()
|| getJson("https://api.bitbucket.org/2.0/user", token.getToken(), BitbucketUser.class)
== null) {
|| getJson(USER_URL, token.getToken(), BitbucketUser.class) == null) {
return null;
}
} catch (OAuthAuthenticationException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ private <T> T executeRequest(
* Checks if the provided url belongs to this client (Bitbucket)
*
* @param scmServerUrl the SCM url to verify
* @return If the provided url is recognized by the current client
* @return {@code true} If the provided url is recognized by the current client
*/
public boolean isConnected(String scmServerUrl) {
return this.scmServerUrl.equals(URI.create(scmServerUrl));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,7 @@
import org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto;
import org.eclipse.che.api.workspace.shared.dto.devfile.ProjectDto;

/**
* Provides Factory Parameters resolver for bitbucket repositories.
*
* @author Florent Benoit
*/
/** Provides Factory Parameters resolver for bitbucket repositories. */
@Singleton
public class BitbucketFactoryParametersResolver extends DefaultFactoryParameterResolver {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@
import org.eclipse.che.api.workspace.shared.dto.SourceStorageDto;
import org.eclipse.che.api.workspace.shared.dto.devfile.SourceDto;

/**
* Create {@link ProjectConfigDto} object from objects
*
* @author Florent Benoit
*/
/** Create {@link ProjectConfigDto} object from objects */
@Singleton
public class BitbucketSourceStorageBuilder {

Expand Down

0 comments on commit 07c1d1c

Please sign in to comment.