GitHub proxy part 5: OAuth flow to retrieve GitHub identity#49849
GitHub proxy part 5: OAuth flow to retrieve GitHub identity#49849
Conversation
| // Auth was successful, return session, certificate, etc. to caller. | ||
| return a.makeGithubAuthResponse(ctx, req, userState, userResp, params.SessionTTL) | ||
| } | ||
|
|
||
| func (a *Server) makeGithubAuthResponse( |
There was a problem hiding this comment.
just some refactoring to break the big function. same below to split getGithubUserAndTeams
f30da58 to
7e9fd6e
Compare
7e9fd6e to
5ab9743
Compare
|
|
||
| // Preserve states like GitHub identities across logins. | ||
| // TODO(greedy52) implement a way to remove the identity or find a way to | ||
| // avoid keeping the identity forever. |
There was a problem hiding this comment.
Should we set some kind of TTL corresponding to the TTL returned by Github for the auth request?
There was a problem hiding this comment.
I don't think Github provide any meaningful TTL for the identity itself. we might need to introduce something like role.max_external_identity_ttl = 168h
There was a problem hiding this comment.
Yes, I think we should put a limit here. A week feels like a reasonable compromise.
Tener
left a comment
There was a problem hiding this comment.
I did another round and I feel comfortable enough approving this. Notably I was already familiar with trickier areas of this PR but it still required above-average effort due to accumulated complexity.
| // TODO(greedy52) make "github-org" optional. Most likely there is only a | ||
| // single Git server configured anyway so do a "list" op then use the | ||
| // organization from that Git server. If more than one Git servers are | ||
| // found, prompt the user to pick one. |
| // ValidateGithubAuthCallback validates Github auth callback redirect | ||
| func (a *Server) validateGithubAuthCallback(ctx context.Context, diagCtx *SSODiagContext, q url.Values) (*authclient.GithubAuthResponse, error) { | ||
| logger := log.WithFields(logrus.Fields{teleport.ComponentKey: "github"}) | ||
| logger := a.logger.With(teleport.ComponentKey, "github") |
There was a problem hiding this comment.
I feel like validateGithubAuthCallback and friends could benefit from refactoring. Right now is probably not the best time, but the original code didn't anticipate the use-cases that have been added with time and it shows. Possibly the opportunity for this will arrive in the future?
| } | ||
|
|
||
| in.Request.ConnectorID = uuid | ||
| in.Request.ConnectorSpec = spec |
There was a problem hiding this comment.
The ConnectorSpec is marked as Used only in test
There was a problem hiding this comment.
i did update api/proto/teleport/legacy/types/types.proto to indicate that ConnectorSpec is for both flows (basically the spec is used when not using "native" GitHub connector). I had a comment in PR description that i need to run make -C integrations/operator crd before merge.
3ee441e to
c20d7ef
Compare
|
🤖 Vercel preview here: https://docs-4q81q907q-goteleport.vercel.app/docs |
|
🤖 Vercel preview here: https://docs-ie4zozxl8-goteleport.vercel.app/docs |
* GitHub proxy part 5: OAuth flow to retrieve GitHub identity * review comments round1 * review comments round 2 and update tsh git list * make -C integrations/operator crd * make -C integrations/terraform docs * fix flaky test
* GitHub proxy part 5: OAuth flow to retrieve GitHub identity * review comments round1 * review comments round 2 and update tsh git list * make -C integrations/operator crd * make -C integrations/terraform docs * fix flaky test
* GitHub Proxy part 1: github integration resource (#48999) * github integration resource * fix lib/web * revert withSecrets * use static credentials * address review comments * fix ut * GitHub Proxy part 2: git_server resource, service, and RBAC (#49393) * git_server resource and role.allow.github_permissions * implicit RO on KindGitServer * review comments * fix ut * make -C integrations/operator crd * fix ut again * make crds-up-to-date and make -C integrations/terraform docs * GitHub proxy part 1.5: integration in web ui (#49561) * GitHub proxy part 1.5: integration in web ui * fix lint * GitHub Proxy part 3.5: caching PluginStaticCredentials (#49472) * GitHub Proxy part 3.5: caching PluginStaticCredentials * fix lint * GitHub proxy part 2.5: git_server cache (#49564) * GitHub proxy part 2.5: git_server cache * revert event * fix getAll * review comments * GitHub Proxy part 3: gen github user cert and export CA (#49396) * GitHub Proxy part 3: gen github user cert and export CA * address pr comment * minor refactor * use cache * fix build and cache * GitHub proxy part 4: `tsh git ls` with unified resource (#49596) * GitHub proxy part 4: tsh git ls * fix ut * update username note * fix * GitHub proxy part 5: OAuth flow to retrieve GitHub identity (#49849) * GitHub proxy part 5: OAuth flow to retrieve GitHub identity * review comments round1 * review comments round 2 and update tsh git list * make -C integrations/operator crd * make -C integrations/terraform docs * fix flaky test * GitHub proxy part 6.5: tsh git ssh/clone/config (#50044) * GitHub proxy part 6.5: tsh git ssh/clone/config * review comments * fix test * fix ut for lookpath * fix logger and update dependency version * go mod tidy for integrations * GitHub proxy part 7: audit events (#49923) * GitHub proxy part 7: audit events * make Git Command consistent * fix typo * GitHub proxy: git command recorder (#50505) * GitHub proxy: recording git command * address review * review comments * allow flags after repository for git-upload-pack * GitHub proxy part 6: proxing Git using SSH transport (#49980) * GitHub proxy part 6: proxing Git using SSH transport * better command parsing and update suite * refactor * revert unnecearrty files * address review comments * ut fix * revert localsite_test.go * change special suffix to teleport-github-org for routing * fix routing ut * minor typo edit * fix ut after sshca change * add UT to sshutils * minor review comments * fix api ut because of special suffix change * GitServerReadOnlyClient * downgrade error to warning * run go mod tidy. not sure why it's needed * rename mock.go to mock_test.go * GitHub Proxy: complete audit event flow and add an enterprise guard (#51049) * fix lint and remove accidently checked-in binary * Fix flaky git.TestForwardServer test (#51112)
…ional#49849) * GitHub proxy part 5: OAuth flow to retrieve GitHub identity * review comments round1 * review comments round 2 and update tsh git list * make -C integrations/operator crd * make -C integrations/terraform docs * fix flaky test
related:
GitHub OAuth flow for authenticated user overview
sequenceDiagram participant tsh participant client browser participant Proxy participant Auth participant GitHub tsh->>Proxy: GitServerClient().CreateGitHubAuthRequest Proxy->>Auth: CreateGitHubAuthRequest tsh->> client browser: open client browser->> GitHub: redirect GitHub<<->>Proxy: callback Proxy<<->>Auth: verify callback and generate new cert with GitHub user ID client browser->>tsh: new cert with GitHub user IDtshUX example:TODO
make -C integrations/operator crd