Skip to content

Issues with BitBucket oauth plugin when connecting to gerrit #120

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
VahagnBleyan opened this issue Feb 19, 2019 · 2 comments
Open

Issues with BitBucket oauth plugin when connecting to gerrit #120

VahagnBleyan opened this issue Feb 19, 2019 · 2 comments
Labels

Comments

@VahagnBleyan
Copy link

VahagnBleyan commented Feb 19, 2019

I used stable-2.16 branch and built gerrit-oauth-provider plugin with bazel, then copied newly generated oauth.jar to plugins dir and re-initialized gerrit.
Gerrit version is 2.16.5

On bitbucket side I set the callback url to http://gerrit.domain.com:8080/oauth
After log in I see "Server Error" - http://gerrit.domain.com:8080/oauth?state=V_mJ7zl_bdAD_0ZCHANGEDAEo_q_T3D9IMRRBSZyUe9A&code=Qq3d3nCHANGEDcYsGx

Now I'm getting this error when trying to sign in to gerrit site with BitBucket oauth

[2019-02-19 09:01:17,126] [HTTP-76] WARN  org.eclipse.jetty.server.HttpChannel : /oauth
java.lang.IllegalStateException: This token object was not constructed by scribe and does not have a rawResponse
        at org.scribe.model.Token.getRawResponse(Token.java:54)
        at com.googlesource.gerrit.plugins.oauth.BitbucketOAuthService.getAccessToken(BitbucketOAuthService.java:113)
        at com.google.gerrit.httpd.auth.oauth.OAuthSession.login(OAuthSession.java:105)
        at com.google.gerrit.httpd.auth.oauth.OAuthWebFilter.doFilter(OAuthWebFilter.java:105)
        at com.google.gerrit.httpd.RunAsFilter.doFilter(RunAsFilter.java:121)
        at com.google.gerrit.httpd.GwtCacheControlFilter.doFilter(GwtCacheControlFilter.java:72)
        at com.google.gerrit.httpd.AllRequestFilter$FilterProxy$1.doFilter(AllRequestFilter.java:133)
        at com.google.gerrit.httpd.AllRequestFilter$FilterProxy.doFilter(AllRequestFilter.java:135)
        at com.google.gerrit.httpd.RequestMetricsFilter.doFilter(RequestMetricsFilter.java:57)
        at com.google.gerrit.httpd.RequestContextFilter.doFilter(RequestContextFilter.java:69)
        at com.google.inject.servlet.ManagedFilterPipeline.dispatch(ManagedFilterPipeline.java:121)
        at com.google.inject.servlet.GuiceFilter.doFilter(GuiceFilter.java:133)
        at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1610)
        at com.googlesource.gerrit.plugins.ootb.FirstTimeRedirect.doFilter(FirstTimeRedirect.java:63)
        at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1610)
        at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:540)
        at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:255)
        at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1588)
        at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:255)
        at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1345)
        at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:203)
        at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:480)
        at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1557)
        at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:201)
        at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1247)
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:144)
        at org.eclipse.jetty.server.handler.RequestLogHandler.handle(RequestLogHandler.java:56)
        at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
        at org.eclipse.jetty.server.Server.handle(Server.java:502)
        at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:364)
        at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:260)
        at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:305)
        at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103)
        at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:118)
        at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:333)
        at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:310)
        at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:168)
        at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:126)
        at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:366)
        at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:765)
        at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:683)
        at java.lang.Thread.run(Thread.java:748)

Here is my gerrit.config file

[gerrit]
        basePath = git
        serverId = 1545cb5a-e63e-4df1-8d02-abe3b2205730
        canonicalWebUrl = http://gerrit.domain.com:8080/
[database]
        type = mysql
        hostname = localhost
        database = reviewdb
        username = gerrit
[noteDb "changes"]
        disableReviewDb = true
        primaryStorage = note db
        read = true
        sequence = true
        write = true
[container]
        javaOptions = "-Dflogger.backend_factory=com.google.common.flogger.backend.log4j.Log4jBackendFactory#getInstance"
        javaOptions = "-Dflogger.logging_context=com.google.gerrit.server.logging.LoggingContext#getInstance"
        user = gerrit
        javaHome = /usr/lib/jvm/java-8-oracle/jre
[index]
        type = LUCENE
[auth]
        type = OAUTH
        gitBasicAuthPolicy = OAUTH
[receive]
        enableSignedPush = false
[sendemail]
        smtpServer = localhost
[sshd]
        listenAddress = *:29418
[httpd]
        listenUrl = http://*:8080/
[cache]
        directory = cache
[plugin "gerrit-oauth-provider-bitbucket-oauth"]
        client-id = KebjCHANGED33nHrv
        fix-legacy-user-id = true

Any idea where to check and how to fix this ?

Thanks

@davido davido added the bug label Feb 19, 2019
@davido
Copy link
Owner

davido commented Feb 19, 2019

I think this is because of this "fix": [1]. Given that the raw response field is not set in the Token instance, it cannot be accessed using to.getRawResponse() method. The easiest fix for now is to say:

return new OAuthToken(to.getToken(), to.getSecret(), " ");

instead.

@VahagnBleyan
Copy link
Author

Worked with that "fix".
Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants