Skip to content
This repository has been archived by the owner on Oct 2, 2023. It is now read-only.

Not able to configure BitBucket collector due to password Encryption issue #1418

Closed
meet101 opened this issue May 24, 2017 · 8 comments
Closed

Comments

@meet101
Copy link

meet101 commented May 24, 2017

I am trying to configure BitBucket collector. I am running into issue while passing encryption key in api.properties and in dashboard.properties. I followed steps "Encryption for private repos" as mentioned in README.

  1. under core/target - I ran java -jar core-2.0.5-SNAPSHOT.jar com.capitalone.dashboard.util.Encryption
    It gave me secret key - xxxxxxxxx
  2. I entered that key in api/dashboard.properties (api.properties) as,
    dbname=dashboard
    dbusername=admin
    dbpassword=admin
    dbhost=127.0.0.1
    dbport=27017
    key=xxxxxxxxxxxxxxxxxxxxxxxxx
  3. In application.properties under collector/scm/bibucket, i copied that key and host as below, can someone please verify?

#Database HostName - default is localhost
dbhost=127.0.0.1

#Database Port - default is 27017
dbport=27017

#MongoDB replicaset
#dbreplicaset=[false if you are not using MongoDB replicaset]
#dbhostport=[host1:port1,host2:port2,host3:port3]

#Database Username - default is blank
dbusername=admin

#Database Password - default is blank
dbpassword=admin

#Logging File location
logging.file=./logs/bitbucket.log

#Collector schedule (required)
git.cron=0 0/5 * * * *

#mandatory:
git.host=https://xxxxx@bitbucket.org/
git.key=xxxxxxxxxxxxxxxxxxxxxx
git.api=/rest/api/1.0/

Maximum number of days to go back in time when fetching commits
git.commitThresholdDays=15
git.pageSize=25
git.product=cloud

is should be git.host and git.key or something else for bitbucket cloud?

When i run api and collector with above setting. I am getting errors in API as,
2017-05-24 15:09:26,598 ERROR o.a.c.c.C.[.[.[.[dispatcherServlet] - Servlet.service() for servlet [dispatcherServlet] in context with path [/api] threw exception
io.jsonwebtoken.SignatureException: JWT signature does not match locally computed signature. JWT validity cannot be asserted and should not be trusted.
at io.jsonwebtoken.impl.DefaultJwtParser.parse(DefaultJwtParser.java:342) ~[jjwt-0.6.0.jar!/:0.6.0]
at io.jsonwebtoken.impl.DefaultJwtParser.parse(DefaultJwtParser.java:458) ~[jjwt-0.6.0.jar!/:0.6.0]at io.jsonwebtoken.impl.DefaultJwtParser.parseClaimsJws(DefaultJwtParser.java:518) ~[jjwt-0.6.0.jar!/:0.6.0atcom.capitalone.dashboard.auth.token.TokenAuthenticationServiceImpl.getAuthentication(TokenAuthenticationServiceImpl.java:59) ~[api.jar!/:2.0.5-SNAPSHOT]

in bitbucket collector, I am getting 404 not found as,

2017-05-24 15:10:00,365 ERROR c.c.d.c.DefaultBitbucketCloudClient - 404 Not Found:https://bitbucket.org/rest/api/1.0/cket.org/awsagero/tdapi/commits?sha=master&since=2017-05-24T14:55Z
2017-05-24 15:10:00,370 INFO c.c.d.collector.CollectorTask - Repo Count 1 0s
2017-05-24 15:10:00,370 INFO c.c.d.collector.CollectorTask - New Commits 0 0s
2017-05-24 15:10:00,370 INFO c.c.d.collector.CollectorTask - Finished 0s

can someone please help?

@meet101
Copy link
Author

meet101 commented May 25, 2017

can someone please take a look into this issue?

@meet101
Copy link
Author

meet101 commented May 26, 2017

I tried to add git.key and github.key in application.properties as well as added key in api.properties which is generated from core by following documentation of Private repo password encryption under UI section.
Then i configure it in UI,
in my collector output, I am getting 400 bad request
2017-05-26 15:02:03,272 ERROR c.c.d.c.DefaultBitbucketCloudClient - 400 Bad Request:https://bitbucket.org/rest/api/1.0/cket.org/awsagero/testapi/commits?sha=master&since=2017-05-26T14:50Z
2017-05-26 15:02:03,274 INFO c.c.d.collector.CollectorTask - Repo Count 1 3s
2017-05-26 15:02:03,275 INFO c.c.d.collector.CollectorTask - New Commits 0 3s
2017-05-26 15:02:03,275 INFO c.c.d.collector.CollectorTask - Finished 3s

here is my application.properties,

dbname=hygieiadb
dbhost=127.0.0.1
dbport=27017
dbusername=admin
dbpassword=admin
logging.file=./logs/bitbucket.log
git.cron=0 0/2 * * * *
git.host=https://xxxxx@bitbucket.org/
git.api=/rest/api/1.0/

git.key=4DKrBLraYpKhC4pGJRCSRXMEcFekStx8
github.key=4DKrBLraYpKhC4pGJRCSRXMEcFekStx8
git.commitThresholdDays=15
git.pageSize=25
git.product=cloud

can someone check what am i doing wrong?
Thanks,

@meet101
Copy link
Author

meet101 commented May 26, 2017

Okay I finally find out the issue, Looks like URL hard-coded is wrong for bit bucket cloud. What i have done is,
in application.properties file, I added (found from here #496)
git.host = api.bitbucket.org/
git.api = /2.0/repositories/

then i tried to run and i got again error with,
2017-05-26 19:10:01,630 ERROR c.c.d.c.DefaultBitbucketCloudClient - 400 Bad Request:https://bitbucket.org/2.0/repositories/**cket.org**/awsagero/testapi/commits?sha=master&since=2017-05-26T18:58Z

  1. cket.org is wrong. Also,
  2. it's still looking for host https://bitbucket.org even if i passed api.bitbucket.org. in application.properties

I tried to browse URL https://api.bitbucket.org/2.0/repositories/awsagero/testapi/commits?sha=master&since=2017-05-26T18:54z
and it's asking me for authentication. once i pass my credentials, It's giving me the correct output as below,

Output i got from above URL.

{"pagelen": 30, "values": [{"hash": "bf9420418f08f9bf60d902e554ebb565ea2ab79c", "repository": {"links": {"self": {"href": "https://api.bitbucket.org/2.0/repositories/awsagero/testapi"}, "html": {"href": "https://bitbucket.org/awsagero/testapi"}, "avatar": {"href": "https://bitbucket.org/account/awsagero/avatar/32/"}}}}, "parents": [], "date": "2017-05-26T02:41:30+00:00", "message": "added all files\n", "type": "commit"}]}

I am thinking, team will need to find why it's adding cket.org and taking default host name even if we pass the diff. host name by git.host.

can you guys please confirm the above troubleshooting is correct or not? Also, can you please let me know where can i do this changes to fix the URL. or can you help to fix it? @softwareklinic @tabladrum @aryasunny.

@meet101
Copy link
Author

meet101 commented Jun 6, 2017

can someone please provide any advice, solution to this issue?

@meet101 meet101 closed this as completed Jun 6, 2017
@meet101
Copy link
Author

meet101 commented Jun 6, 2017

closed it by mistake,
@MarkRx, @satishc1 , @softwareklinic, @tabladrum , @srid99 - can you please take a look at the issue and provide solution/advice? I am still facing issue. Also, I did some research as mentioned above? Looks like something wrong with URL. is it correct or not?

I am getting this error
2017-06-06 17:52:00,112 ERROR c.c.d.c.DefaultBitbucketCloudClient - 401 Unauthorized:https://bitbucket.org/api/2.0/repositories/cket.org/awsagero/testapi/commits?sha=master&since=2017-05-23T17:52Z
2017-06-06 17:52:00,114 INFO c.c.d.collector.CollectorTask - Repo Count 1 0s
2017-06-06 17:52:00,115 INFO c.c.d.collector.CollectorTask - New Commits 0 0s
2017-06-06 17:52:00,115 INFO c.c.d.collector.CollectorTask - Finished 0s

if i take URL (https://bitbucket.org/api/2.0/repositories/cket.org/awsagero/testapi/commits?sha=master&since=2017-05-23T17:52Z) and remove "cket.org" (https://bitbucket.org/api/2.0/repositories/awsagero/testapi/commits?sha=master&since=2017-05-23T17:52Z) If i try it in browser. i am getting popup for username and password. by entering username and password, I am able to get all details from repo.

can you please let me know, why am i getting 'cket.org' in URL? how can i remove it?

Thanks

@meet101
Copy link
Author

meet101 commented Jun 8, 2017

no one is responding to this issue. closing this. will reopen a new issue.

@meet101 meet101 closed this as completed Jun 8, 2017
@RayanZahab
Copy link

RayanZahab commented Mar 6, 2019

I almost read every link about this collector online :) and this comment @meet101 led me to the solution:

  1. The link in the Hygieia widget : https://bitbucket.org/username/repoName
  2. In my dashboard.properties :

The 2 most tricky parameters:

git.host= api.bitbucket.org/
git.api = /api/2.0/repositories/

The rest required parameters

logging.file=./logs/bitbucket.log
git.cron=0 0/5 * * * *
git.commitThresholdDays=25
git.pageSize=25
git.product=cloud
bitbucket.key=[mykey]

@venkateshreddy53
Copy link

I tried to add git.key and github.key in application.properties as well as added key in api.properties which is generated from core by following documentation of Private repo password encryption under UI section.
Then when i run the bitbucket connector, i got below error.

bitbckt

please help @RayanZahab @meet101

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

No branches or pull requests

3 participants