-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just some refactoring to break the big function. same below to split getGithubUserAndTeams
f30da58
to
7e9fd6e
Compare
7e9fd6e
to
5ab9743
Compare
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.
First pass.
@@ -154,6 +164,13 @@ func (g *Generator) Generate(ctx context.Context, user types.User) (*userloginst | |||
return nil, trace.Wrap(err) | |||
} | |||
|
|||
// 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think we should put a limit here. A week feels like a reasonable compromise.
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 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. |
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.
A very nice idea.
@@ -537,7 +537,7 @@ func newGithubOAuth2Config(connector types.GithubConnector) oauth2.Config { | |||
|
|||
// 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ConnectorSpec is marked as Used only in test
teleport/integrations/operator/crdgen/testdata/protofiles/teleport/legacy/types/types.proto
Line 5197 in 6995108
GithubConnectorSpecV3 ConnectorSpec = 15 [(gogoproto.jsontag) = "connector_spec,omitempty"]; |
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 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 |
related:
GitHub OAuth flow for authenticated user overview
tsh
UX example:TODO
make -C integrations/operator crd