-
Notifications
You must be signed in to change notification settings - Fork 385
Cache app installation token #291
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
Merged
bitwiseman
merged 5 commits into
jenkinsci:master
from
jglick:GitHubAppCredentials.cachedToken
Apr 13, 2020
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
60d07a0
Cache app installation token
jglick 9da1f5a
Back to 8m
jglick 6d8b52a
Refresh the token when it is halfway toward expiration (4m), to be on…
jglick 023cdca
SpotBugs
jglick 5cb7140
Merge branch 'master' of github.com:jenkinsci/github-branch-source-pl…
jglick File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This token is valid for an hour not 10 minutes, and the
expires_atfield should be looked at (in case it changes in the future) https://github.com/jglick/github-branch-source-plugin-1/blob/GitHubAppCredentials.cachedToken/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubAppCredentials.java#L125-L129The generated JWT that's used to get this token can only be valid for up to 10 minutes, but the retrieved token is an hour (I didn't see any documentation on this but I just tried it out locally).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, this is shows the same.
https://github.com/github-api/github-api/blob/3cbddf1de9e6a0f261a55247a54f8afdfd168fef/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/createToken/mappings/mapping-app-installations-3755540-access_tokens-7W6Uy.json#L22
https://github.com/github-api/github-api/blob/3cbddf1de9e6a0f261a55247a54f8afdfd168fef/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/createToken/__files/body-app-installations-3755540-access_tokens-7W6Uy.json#L3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I guess you are saying that we could potentially stretch out the interval between token refreshes to, say, 55m? Would be nice to see some docs on this though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but probably better to look at expires_at in case they change it, I had a look and couldn't see any docs on it