Skip to content

Commit

Permalink
Add hooks for SSO auth requests for future enterprise use
Browse files Browse the repository at this point in the history
  • Loading branch information
espadolini committed Mar 29, 2024
1 parent c0e381b commit bea0aa3
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion lib/auth/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,17 @@ func (g *GithubConverter) UpsertGithubConnector(ctx context.Context, connector t

// CreateGithubAuthRequest creates a new request for Github OAuth2 flow
func (a *Server) CreateGithubAuthRequest(ctx context.Context, req types.GithubAuthRequest) (*types.GithubAuthRequest, error) {
_, client, err := a.getGithubConnectorAndClient(ctx, req)
connector, client, err := a.getGithubConnectorAndClient(ctx, req)
if err != nil {
return nil, trace.Wrap(err)
}

if hook := GithubAuthRequestHook; hook != nil {
if err := hook(ctx, &req, connector); err != nil {
return nil, trace.Wrap(err)
}
}

req.StateToken, err = utils.CryptoRandomHex(TokenLenBytes)
if err != nil {
return nil, trace.Wrap(err)
Expand Down Expand Up @@ -1029,3 +1036,10 @@ var GithubScopes = []string{
// read:org grants read-only access to user's team memberships
"read:org",
}

// Hooks for future use in Enterprise-only code.
var (
GithubAuthRequestHook func(context.Context, *types.GithubAuthRequest, types.GithubConnector) error
OIDCAuthRequestHook func(context.Context, *types.OIDCAuthRequest, types.OIDCConnector) error
SAMLAuthRequestHook func(context.Context, *types.SAMLAuthRequest, types.SAMLConnector) error
)

0 comments on commit bea0aa3

Please sign in to comment.