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

RFD 0178: GitHub proxy #44527

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open

RFD 0178: GitHub proxy #44527

wants to merge 11 commits into from

Conversation

@greedy52 greedy52 added the rfd Request for Discussion label Jul 22, 2024
@greedy52 greedy52 force-pushed the rfd/0178-github-proxy branch 6 times, most recently from 6bd61fe to 62b8ace Compare August 16, 2024 16:52
@greedy52 greedy52 self-assigned this Aug 16, 2024
@greedy52 greedy52 added the no-changelog Indicates that a PR does not require a changelog entry label Aug 16, 2024
@greedy52 greedy52 marked this pull request as ready for review August 16, 2024 18:15
Copy link
Contributor

@smallinsky smallinsky left a comment

Choose a reason for hiding this comment

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

First quick pass.

rfd/0178-github-proxy.md Outdated Show resolved Hide resolved
Comment on lines 404 to 409
#### RBAC on GitHub proxy server

Existing RBAC for a SSH node is used. Teleport users that require the GitHub
proxy should be granted through existing `node_labels` (or
`node_labels_expression`) that match the GitHub proxy server. And GitHub
usernames are specified in existing `logins`.
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a thought:

The GitHub organization node allows access to repositories with built-in permissions.

I wonder if there is a way to delegate permission management for GitHub via Teleport's RBAC model and enforce RBAC checks at the protocol level.

For instance, using an RBAC role to define the repositories and operations a user is allowed to perform, and enforcing this at the GitHub protocol level so if we can audit GH action we can model the GH RBAC in teleport.

Copy link
Contributor Author

@greedy52 greedy52 Aug 19, 2024

Choose a reason for hiding this comment

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

For instance, using an RBAC role to define the repositories and operations a user is allowed to perform, and enforcing this at the GitHub protocol level so if we can audit GH action we can model the GH RBAC in teleport.

I think the repo and action (fetch vs push) are the only ones we can control.

Like you said in other comments, today we are relying on the Organization that has existing GitHub users. Users can still perform actions through Web UI.


## Details

### UX - User stories
Copy link
Contributor

@smallinsky smallinsky Aug 19, 2024

Choose a reason for hiding this comment

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

Right now, the GitHub Proxy seems to be a good fit for automation flows like CI, but missing support for GitHub web UI access will be a blocker for day-to-day user workflows. Alternatively, we could rely on two access models, such as GitHub SSO and Teleport GitHub Proxy, but this raises the question: why use the GitHub Proxy when a user already has access to GitHub via SSO?

Copy link
Contributor Author

@greedy52 greedy52 Aug 19, 2024

Choose a reason for hiding this comment

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

RBAC should be controlled with GitHub IAM integrartion. The proxy is more like an addon to it. As mentioned in the stories, the benefit using the GitHub Proxy include per-session MFA, audit log (e.g. generating reporting using Access Monitoring). I can certainly add specific stories for those like I want to generate an audit report that xxx

@marcoandredinis marcoandredinis removed their request for review August 23, 2024 16:53
Copy link
Collaborator

@r0mant r0mant left a comment

Choose a reason for hiding this comment

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

I think that role spec and internal representation of Github's "server" need a bit more work. Reusing part of SSH implementation since git is essentially SSH protocol is one thing but from the UX and configuration perspective it is very confusing that it relies on access controls designed for SSH nodes, feels like leaking implementation details.

It would also be helpful to see an end-to-end MVP in action that showcases your user scenarios e.g. a demo where:

  • An admin goes to Integrations tab and sets up Github integration.
  • A user logs into Teleport and uses git to interact with the repository.

rfd/0178-github-proxy.md Show resolved Hide resolved
Comment on lines 95 to 96
labels:
"github-organization": "my-org"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need this both in the labels and in the spec?

Copy link
Contributor Author

@greedy52 greedy52 Aug 27, 2024

Choose a reason for hiding this comment

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

this is for RBAC. it will be a lot better to switch to repo-specific RBAC! will update!

Comment on lines 111 to 114
logins:
- {{external.github_usernames}}
node_labels:
"github-organization": "my-org"
Copy link
Collaborator

Choose a reason for hiding this comment

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

It is fairly confusing to use node_labels and logins for Github access. I understand we're relying on a lot of SSH implementation under the hood but from user's perspective this is very confusing.

First of all - why do we need "logins"? There will never be a list here as each user will have a single Github username in 99% of cases, can we just take it directly from the user's traits?

For the labels - instead of using node labels can we piggy-back on the role spec proposed in Github IAM RFD and extend the repo_permissions section with something like this:

spec:
  allow:
    repo_permissions:
    - orgs:
      - goteleport

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe I am overthinking this. How do we plan to differentiate between different types of Git hostings? For example, both GitHub and GitLab can have organizations.

For the proxying purpose, what do you think something like this?

spec:
  allow:
    github_organizations:
    - my-org

Copy link
Collaborator

Choose a reason for hiding this comment

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

We can just call it github_permissions rather than generic repo_permissions I think. So:

  allow:
    github_permissions:
      orgs:
      - gravitational
      repos:
      - teleport
      - teleport.e
      roles:
      - push

Comment on lines 275 to 276
kind: node
sub_kind: openssh-github
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this will increase the amount of work we need to do to treat these node resources specially. If we use node resource, we'll probably have to take a special care then to filter it out from things like "tsh ls" and web UI listing of nodes, etc. Can we use a different resource type instead? cc @rosstimothy @espadolini

Copy link
Contributor Author

@greedy52 greedy52 Aug 27, 2024

Choose a reason for hiding this comment

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

I think it will be more work to make existing transport take another resource kind (but still types.Server) but i agree it's cleaner that way. Let me look into that.

#### Recordings and events

Regular SSH recordings for the GitHub proxy server will be disabled. "Git
Command" events will replace the "Command Executation" events:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
Command" events will replace the "Command Executation" events:
Command" events will replace the "Command Execution" events:

@greedy52 greedy52 force-pushed the rfd/0178-github-proxy branch 2 times, most recently from 13657ca to 01d410d Compare September 17, 2024 18:35
@viktor-doyensec-teleport
Copy link

viktor-doyensec-teleport commented Sep 19, 2024

Hi team!

I completed the review of the RDF. The concerns outlined in the "Security" section are valid. Both suggested alternatives would help prevent potential account impersonation, and the listed trade-offs are accurate.

I have, however, a questions regarding the "Alternative 2" proposal. Have you looked into the extension:id@github.com extension when signing user certificates? It seems to be a more stable/immutable way of identifying GitHub users.

From my limited testing, changing an account's username does not have impact its ID.

Given that, a variant of the "Alternative 2" flow might be:

  1. Require the user to go through the GitHub OAuth flow
  2. Store the user's GitHub account ID in an account trait
  3. Use the GitHub account ID to sign a user certificate

Once the GitHub account ID is stored, the OAuth flow should no longer be required. This should help smooth out the UX and reduce the number of times the user needs to perform the OAuth flow. If the user wishes to use another GitHub account later on, the ID can be overwritten by requiring the user to go through the above flow once more.

Let me know what are your thoughts on this.

@greedy52 greedy52 mentioned this pull request Oct 25, 2024
@greedy52 greedy52 requested a review from r0mant November 11, 2024 19:13
@greedy52 greedy52 mentioned this pull request Nov 11, 2024
12 tasks

<img src="./assets/0178-enroll-step3.png" width="600" />

3. Next Alice creates a Git server resource and a Teleport role for Teleport
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is too low-level for the enrollment flow, we should just create this server resource internally automatically.

Comment on lines +187 to +190
The first `git` command (including the `clone`) will open a browser window to
trigger the GitHub OAuth flow for Teleport to grab Bob's GitHub ID and
username. Once Bob sees "Login Successful" from the brower and goes back to his
terminal.
Copy link
Collaborator

Choose a reason for hiding this comment

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

What would the flow be in a non-interactive/headless scenario? I.e. if you want to do this from a development box where there is no browser.

Comment on lines +321 to +329
To be more specific, the current GitHub SSO flow initiates an unauthenticated
HTTP call to Teleport to create a GitHub auth request. Once the Auth service
verifies the GitHub callback, it creates a new user associated with a GitHub
connector.

In contrast, the new flow uses an authenticated gRPC call to Teleport to create
the GitHub auth request. Once the Auth service verifies the GitHub callback, it
attaches the GitHub identity information directly to the authenticated user who
initiated the request.
Copy link
Collaborator

@r0mant r0mant Nov 11, 2024

Choose a reason for hiding this comment

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

To follow up on my question above, sounds like this should work for scenarios where you do tsh login from a development box and not your laptop as well, correct? Have you tested this scenario? Can we give them a link to click instead of opening the browser?

Copy link
Contributor Author

@greedy52 greedy52 Nov 12, 2024

Choose a reason for hiding this comment

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

As discussed in person, one mitigation we decided to do is to preserve github identity info so user only needs to do OAuth flow once on their laptop.

I found today user login state is refreshed upon new user login. I have updated the refresh logic to preserve the github identity info during refresh so that another login wouldn't void the GitHub OAuth flow. We might need a way to properly void the GitHub identity saved though. I might add a tctl call later or adjust tsh git login.

The other alternative is port-forwarding. For example, from user's laptop:

(local)$ tsh ssh -L 8080:localhost:8080 bob@remote-box
(remote)$ tsh login xxxx
(remote)$ tsh git login --github-org my-org --callback-addr localhost:8080

Then bob can open the URL on his laptop's browser to finish the flow.

I will update the RFD to reflect this.

Comment on lines 643 to 647
In the design described above, GitHub usernames are provided through an user
trait. For local users, only Teleport "admins" can set the traits as modifying
users is considered an admin action. For external users, only "admins" of the
external identity provider, say an Okta admin, can configure the values of the
traits.
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is no longer true so probably should be removed or marked as discarded design.

Copy link
Collaborator

@r0mant r0mant left a comment

Choose a reason for hiding this comment

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

lgtm once you've made the changes we discussed in the latest feedback round

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-changelog Indicates that a PR does not require a changelog entry rfd Request for Discussion size/md
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants