Skip to content

Conversation

@bitwiseman
Copy link
Contributor

Description

Follow on to #326. We shouldn't keep the app installation token as a bare String.
I don't think this is a huge deal given how Secret is actually stored and serialized, but this is more correct regardless.

Submitter checklist

  • Link to JIRA ticket in description, if appropriate.
  • Change is code complete and matches issue description
  • Automated tests have been added to exercise the changes
  • Reviewer's manual test instructions provided in PR description. See Reviewer's first task below.

Reviewer checklist

  • Run the changes and verify that the change matches the issue description
  • Reviewed the code
  • Verified that the appropriate tests have been written or valid explanation given

Documentation changes

  • Link to jenkins.io PR, or an explanation for why no doc changes are needed

Users/aliases to notify

@bitwiseman bitwiseman requested a review from dwnusbaum September 4, 2020 16:48

@SuppressWarnings("deprecation") // preview features are required for GitHub app integration, GitHub api adds deprecated to all preview methods
static AppInstallationToken generateAppInstallationToken(String appId, String appPrivateKey, String apiUrl, String owner) {
JenkinsJVM.checkJenkinsJVM();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method now only runs on a controller, let's enforce that.

long expiration = getExpirationSeconds(appInstallationToken);
AppInstallationToken token = new AppInstallationToken(appInstallationToken.getToken(),
AppInstallationToken token = new AppInstallationToken(
Secret.fromString(appInstallationToken.getToken()),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The app installation token only exists as a bare string inside this method.

@dwnusbaum
Copy link
Member

I don't think this is a huge deal given how Secret is actually stored and serialized

Yeah, I don't think this affects the security of the implementation, but if it makes things simpler/less error prone then it seems fine to me.

@bitwiseman bitwiseman requested a review from jglick September 4, 2020 17:57
Copy link
Member

@jglick jglick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure.

@bitwiseman bitwiseman merged commit bb55742 into jenkinsci:master Sep 8, 2020
@bitwiseman bitwiseman deleted the task/token-secret branch September 8, 2020 07:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants