Skip to content
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

GitHub source authentication works differently #2199

Closed
rix0rrr opened this issue Apr 8, 2019 · 5 comments · Fixed by #2252
Closed

GitHub source authentication works differently #2199

rix0rrr opened this issue Apr 8, 2019 · 5 comments · Fixed by #2252
Assignees
Labels
@aws-cdk/aws-codebuild Related to AWS CodeBuild bug This issue is a bug.

Comments

@rix0rrr
Copy link
Contributor

rix0rrr commented Apr 8, 2019

In our GitHubSource, oauthToken is required, but it doesn't actually do anything.

You're supposed to authenticate the whole of CodeBuild against all of your repositories using OAuth in the console. Afterwards, you don't have to pass a token value, you just have to set auth-type to "OAUTH" and it'll work.

For reference, the following seems to work fine:

new GitHubSource({
      owner: 'rix0rrr',
      repo: 'somerepoihave',
      oauthToken: cdk.SecretValue.plainText(''),
 })

@skinny85, any clue?

@rix0rrr rix0rrr added bug This issue is a bug. @aws-cdk/aws-codebuild Related to AWS CodeBuild labels Apr 8, 2019
@skinny85
Copy link
Contributor

skinny85 commented Apr 8, 2019

Perhaps it's only needed for the webhook...?

@rix0rrr , can you try the above with webhook: true, and see what happens? (i.e., is a CodeBuild build triggered by a push to the repository)

@rix0rrr
Copy link
Contributor Author

rix0rrr commented Apr 8, 2019

I did this with webhook: true, fwiw

@skinny85
Copy link
Contributor

skinny85 commented Apr 8, 2019

And did it work? (were builds triggered by just pushing to the repository?)

@rix0rrr
Copy link
Contributor Author

rix0rrr commented Apr 9, 2019

Yep. Looks like we've been thinking about this all wrong.

Before connecting to repos, you're supposed to call ImportSourceCredentials for GitHub, using a token you get from doing an OAuth browser flow or a Personal Access Token. CodeBuild will store this token somewhere on their end.

After that, you create a project and set auth.type=OAUTH, which will lead them to use the token they have stored server side.

Until CloudFormation grows support for ImportSourceCredentials or we write a custom lambda, there's no way to do this unattended.

codebuild

@rix0rrr
Copy link
Contributor Author

rix0rrr commented Apr 9, 2019

That means the action is to get rid of oauthToken and document this better.

Kaixiang-AWS added a commit to Kaixiang-AWS/aws-cdk that referenced this issue Apr 12, 2019
Auth field should not be set since it's ignored by CodeBuild
https://docs.aws.amazon.com/codebuild/latest/APIReference/API_ProjectSource.html#CodeBuild-Type-ProjectSource-auth

BREAKING CHANGE: customers who use GitHub, GitHubEnterprise or Bitbucket as source
will need to remove the oauthToken field as it's no longer available

Fixes aws#2199
rix0rrr pushed a commit that referenced this issue Apr 16, 2019
Auth field should not be set since it's ignored by CodeBuild
https://docs.aws.amazon.com/codebuild/latest/APIReference/API_ProjectSource.html#CodeBuild-Type-ProjectSource-auth

BREAKING CHANGE: customers who use GitHub, GitHubEnterprise or Bitbucket as source
will need to remove the oauthToken field as it's no longer available

Fixes #2199
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-codebuild Related to AWS CodeBuild bug This issue is a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants