-
Notifications
You must be signed in to change notification settings - Fork 118
server, agent: GitHub app installation support for repository cloning #1165
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
base: master
Are you sure you want to change the base?
Conversation
… the initRepo function two tests break and this string concat needs to be pulled out (or otherwise undone) to work.
…x the Github Trigger tests.
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.
Still 👀 through it, got a couple of Qs
| } | ||
|
|
||
| /** | ||
| * Refresh repositories by their IDs. |
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.
The comment doesn't match the method.
|
|
||
| @Value.Immutable | ||
| @Value.Style(jdkOnly = true, redactedMask = "**redacted**") | ||
| interface CacheKey { |
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.
| interface CacheKey { | |
| record CacheKey(URI repoUri, int weight) |
maybe? Calculate the weight when the key is created. Get rid of immutables and there won't be anything secret to print in the first place.
| @Value.Immutable | ||
| @Value.Style(jdkOnly = true) | ||
| @JsonDeserialize(as = ImmutableGitHubAppAuthConfig.class) | ||
| public interface GitHubAppAuthConfig extends MappingAuthConfig { |
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.
Can this be a record as well? Do the sanity check in the constructor?
2c19b50 to
95340b7
Compare
|
Any chance to extract git.allowedSchemes into a separate PR? |
|
I’d even suggest splitting the server and agent parts into separate PRs... |
|
|
||
| <sql> | ||
| insert into ROLE_PERMISSIONS values ( | ||
| (select ROLE_ID from ROLES where ROLE_NAME = 'concordAdmin'), |
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.
I think only agents are going to need this permission? If so then should we create an agent role?
Original intent: There's already mitigation in the UI, however this would not stop a nefarious actor who sends a POST request without the UI; this is intended to cover that case.
The need for GitHub app support for cloning usurps these mitigations, so this PR now builds off that idea and incorporating the GitHub app's auth, with additional design considerations for similar auth patterns for other services (e.g. a GitLab auth provider).
The sequence for cloning with auth from a GitHub app installation is:
sequenceDiagram participant concord-agent participant concord-server participant token-cache concord-server->>+token-cache: get token for repo token-cache-->>token-cache: cached installation token for repo token-cache-->>token-cache: validate token expiration token-cache-->>+GitHub: or Generate new token GitHub-->>-token-cache: new 1-hour installation client token token-cache->>-concord-server: installation token concord-server->>+concord-server: clone repo concord-server->>+concord-agent: dispatch workflow concord-agent->>+concord-server: lookup token concord-server->>+token-cache: retrieve token token-cache-->>token-cache: cached installation token for repo token-cache-->>token-cache: validate token expiration token-cache-->>+GitHub: or Generate new token GitHub-->>-token-cache: new 1-hour installation client token token-cache->>-concord-server: installation token concord-server->>+concord-agent: installation token concord-agent->>+concord-agent: clone repo concord-agent->>+concord-agent: start workflow runner